update 2024-06-19 20:10:56

This commit is contained in:
actions-user 2024-06-19 20:10:56 +08:00
parent 8d4618ff23
commit fa4537f8c3
7 changed files with 97 additions and 16 deletions

View File

@ -37,8 +37,9 @@
2. 安装软件
```
POST /cgi-bin/luci/admin/store/install
token=xxx&package=upnp
token=xxx&package=upnp&autoconf=1&path=/mnt/nvme&enable=1
autoconf=1&path=/mnt/nvme&enable=1 是可选参数,表示安装完以后是否自动配置插件
{"code":0, "stdout":"", "stderr":""}
```
@ -148,3 +149,13 @@
{"code":500, "msg":"Unable to execute block utility"}
{"code":200, "data":{"sda1":{"dev":"\/dev\/sda1","uuid":"f54566dd-ec58-4e24-9451-bbf75834add3","version":"1.0","type":"ext4","size":"238.46 GB"},"mmcblk0p2":{"dev":"\/dev\/mmcblk0p2","uuid":"dba3d0dc-f072-4e81-a0ac-ac35197fb286","version":"1.0","label":"etc","mount":"\/overlay","type":"ext4","size":"6.87 GB"},"mmcblk0p1":{"dev":"\/dev\/mmcblk0p1","uuid":"8f9564a1-68006e25-c4c26df6-de88ef16","version":"4.0","mount":"\/rom","type":"squashfs","size":"127.99 MB"}}}
```
3. 检查插件是否已经配置过
```
GET /cgi-bin/luci/admin/store/configured?uci=ddnsto
uci参数是uci配置文件的名称不是包名不过大部分情况下都是一致的。
{"code":200}
{"code":200, "configured":true}
```

View File

@ -8,10 +8,10 @@ include $(TOPDIR)/rules.mk
LUCI_TITLE:=LuCI based ipk store
LUCI_DESCRIPTION:=luci-app-store is a ipk store developed by LinkEase team
LUCI_DEPENDS:=+curl +opkg +luci-base +tar +coreutils +coreutils-stat +libuci-lua +mount-utils +luci-lib-taskd
LUCI_EXTRA_DEPENDS:=luci-lib-taskd (>=1.0.17)
LUCI_EXTRA_DEPENDS:=luci-lib-taskd (>=1.0.19)
LUCI_PKGARCH:=all
PKG_VERSION:=0.1.17-1
PKG_VERSION:=0.1.19-0
# PKG_RELEASE MUST be empty for luci.mk
PKG_RELEASE:=

View File

@ -26,6 +26,9 @@ function index()
entry({"admin", "store", "do_self_upgrade"}, post("do_self_upgrade"))
entry({"admin", "store", "toggle_docker"}, post("toggle_docker"))
entry({"admin", "store", "toggle_arch"}, post("toggle_arch"))
entry({"admin", "store", "get_block_devices"}, call("get_block_devices"))
entry({"admin", "store", "configured"}, call("configured"))
for _, action in ipairs({"update", "install", "upgrade", "remove"}) do
store_api(action, true)
@ -45,7 +48,6 @@ function index()
entry({"admin", "store", "get_available_backup_file_list"}, call("get_available_backup_file_list"))
entry({"admin", "store", "set_local_backup_dir_path"}, post("set_local_backup_dir_path"))
entry({"admin", "store", "get_local_backup_dir_path"}, call("get_local_backup_dir_path"))
entry({"admin", "store", "get_block_devices"}, call("get_block_devices"))
end
end
@ -69,7 +71,7 @@ local function user_id()
return id
end
local function user_config()
local function user_config()
local uci = require "luci.model.uci".cursor()
local data = {
@ -213,6 +215,10 @@ local function _action(exe, cmd, ...)
return is_exec(c, true)
end
function validate_pkgname(val)
return (val ~= nil and val:match("^[a-zA-Z0-9_]+$") ~= nil)
end
function store_action(param)
local metadir = "/usr/lib/opkg/meta"
local metapkgpre = "app-meta-"
@ -225,6 +231,10 @@ function store_action(param)
if action == "status" then
local pkg = luci.http.formvalue("package")
if not validate_pkgname(pkg) then
luci.http.status(400, "Bad Request")
return
end
local metapkg = metapkgpre .. pkg
local meta = {}
local metadata = fs.readfile(metadir .. "/" .. pkg .. ".json")
@ -277,10 +287,25 @@ function store_action(param)
ret = data
else
local pkg = luci.http.formvalue("package")
if not validate_pkgname(pkg) then
luci.http.status(400, "Bad Request")
return
end
local metapkg = pkg and (metapkgpre .. pkg) or ""
if action == "update" or pkg then
if action == "update" or action == "install" then
code, out, err = _action(myopkg, action, metapkg)
if action == "install" and "1" == luci.http.formvalue("autoconf") then
local autoenv = "AUTOCONF=" .. pkg
local autopath = luci.http.formvalue("path")
local autoenable = luci.http.formvalue("enable")
if autopath ~= nil then
autoenv = autoenv .. " path=" .. luci.util.shellquote(autopath)
end
autoenv = autoenv .. " enable=" .. autoenable
code, out, err = _action(myopkg, luci.util.shellquote(autoenv), action, metapkg)
else
code, out, err = _action(myopkg, action, metapkg)
end
else
local meta = json_parse(fs.readfile(metadir .. "/" .. pkg .. ".json"))
local pkgs = {}
@ -368,6 +393,17 @@ function store_upload()
luci.http.write_json(ret)
end
function configured()
local uci = luci.http.formvalue("uci")
if not validate_pkgname(uci) then
luci.http.status(400, "Bad Request")
return
end
local configured = nixio.fs.access("/etc/config/" .. uci)
luci.http.prepare_content("application/json")
luci.http.write_json({code=200, configured=configured})
end
local function split(str,reps)
local resultStrList = {}
string.gsub(str,'[^'..reps..']+',function (w)
@ -467,7 +503,7 @@ local function update_local_backup_path(path)
local f=io.open("/etc/config/istore","a+")
f:write("config istore \'istore\'\n\toption local_backup_path \'\'")
f:flush()
f:close()
f:close()
end
if path ~= local_backup_path then
@ -626,7 +662,7 @@ function get_available_backup_file_list()
if path ~= "" then
-- update local backup path
update_local_backup_path(path)
r,o,e = is_exec(is_backup .. " get_available_backup_file_list " .. path)
r,o,e = is_exec(is_backup .. " get_available_backup_file_list " .. luci.util.shellquote(path))
if r ~= 0 then
error_ret.msg = e
luci.http.prepare_content("application/json")

View File

@ -36,7 +36,7 @@
<script>
(function() {
let beforeunloadRegistered = false;
window.istore_log = function(flush_menu_onclose) {
window.istore_log = function(flush_menu_onclose, onExit) {
if (flush_menu_onclose && !beforeunloadRegistered) {
beforeunloadRegistered = true;
window.addEventListener("beforeunload", function(event) {
@ -44,7 +44,7 @@
return true;
});
}
taskd.show_log("istore", true);
taskd.show_log("istore", true, onExit);
};
})();
<%

View File

@ -2,6 +2,13 @@
# this script MUST supports executting without luci-app-store installed,
# so we can use this script to install luci-app-store itself
action=${1}
shift
if [ "${action:0:9}" = "AUTOCONF=" ]; then
export "ISTORE_${action}"
exec "$0" "$@"
fi
IS_ROOT=/tmp/is-root
DL_DIR=${IS_ROOT}/tmp/dl
LISTS_DIR_O=/tmp/opkg-lists
@ -18,9 +25,6 @@ ISTORE_PKG=luci-app-store
ISTORE_DEP_PKGS="luci-lib-taskd luci-lib-xterm taskd"
ISTORE_INDEX=https://istore.linkease.com/repo/all/store/Packages.gz
action=${1}
shift
is_init() {
mkdir -p ${DL_DIR} ${LISTS_DIR} ${IS_ROOT}/etc ${IS_ROOT}/var
@ -189,6 +193,35 @@ remove() {
opkg_wrap --autoremove --force-removal-of-dependent-packages remove "$@"
}
autoconf_to_env() {
local autoconf path enable
eval "local autoconf=$ISTORE_AUTOCONF"
export -n ISTORE_AUTOCONF
export -n ISTORE_DONT_START
export -n ISTORE_CONF_DIR
export -n ISTORE_CACHE_DIR
export -n ISTORE_PUBLIC_DIR
export -n ISTORE_DL_DIR
ISTORE_AUTOCONF=$autoconf
if [ -n "$path" ]; then
export ISTORE_CONF_DIR="$path/Configs"
export ISTORE_CACHE_DIR="$path/Caches"
export ISTORE_PUBLIC_DIR="$path/Public"
export ISTORE_DL_DIR="$ISTORE_PUBLIC_DIR/Downloads"
fi
[ "$enable" = 0 ] && export ISTORE_DONT_START="1"
}
try_autoconf() {
[ -n "$ISTORE_AUTOCONF" ] || return 0
autoconf_to_env
[ -n "$ISTORE_AUTOCONF" ] || return 1
echo "Auto configure $ISTORE_AUTOCONF"
/usr/libexec/istorea/${ISTORE_AUTOCONF}.sh
}
usage() {
echo "usage: is-opkg sub-command [arguments...]"
echo "where sub-command is one of:"
@ -212,7 +245,7 @@ case $action in
;;
"install")
check_space
wrapped_in_update opkg_wrap_mirrors install "$@"
wrapped_in_update opkg_wrap_mirrors install "$@" && try_autoconf
;;
"upgrade")
new_upgrade "$@"

View File

@ -11,7 +11,7 @@ LUCI_DEPENDS:=+luci-lib-xterm +taskd
LUCI_EXTRA_DEPENDS:=taskd (>=1.0.3-1)
LUCI_PKGARCH:=all
PKG_VERSION:=1.0.18
PKG_VERSION:=1.0.19
PKG_RELEASE:=
PKG_MAINTAINER:=jjm2473 <jjm2473@gmail.com>

View File

@ -77,7 +77,7 @@
container.querySelector(".dialog-icon-close").hidden = true;
term.write(content);
};
const show_log = function(task_id, nohide) {
const show_log = function(task_id, nohide, onExit) {
let showing = true;
let running = true;
const dialog = create_dialog({title:task_id, nohide, onhide:function(){showing=false;}});
@ -113,6 +113,7 @@
if (data.exit_code) {
container.classList.add('tasks_failed');
}
onExit && onExit(data.exit_code);
}
// last pull
return showing;