mirror of
https://github.com/kenzok8/small-package
synced 2025-01-08 13:27:36 +08:00
update 2022-07-18 20:24:49
This commit is contained in:
parent
015a57594a
commit
f10b991b71
@ -1 +1 @@
|
||||
{"en":{"%{ num } download":["%{ num } download","%{ num } downloads"],"%{ num } like":["%{ num } like","%{ num } likes"],"all app":"all app","app backup":"app backup","are you sure you want to uninstall %{name}?":"are you sure you want to uninstall %{name}?","author":"author","backup fail":"backup fail","backup now":"backup now","backup now backs up installed software (unlimited installation sources) to external storage":"backup now backs up installed software (unlimited installation sources) to external storage","backup now will download a list of iStore installed software":"backup now will download a list of iStore installed software","backup success":"backup success","backuping":"backuping","By download":"By download","By rating":"By rating","checking for latest version":"checking for latest version","choose":"choose","choose backup file":"choose backup file","click to download":"click to download","click to update":"click to update","closed":"closed","customize":"customize","default":"default","do not refresh this page during plugin installation/uninstallation":"do not refresh this page during plugin installation/uninstallation","download":"Download","explain":"explain","external storage directory":"external storage directory","from this page, you can upload plugin packages to install plugins":"from this page, you can upload plugin packages to install plugins","Icon is gone":"Icon is gone","install":"install","installation failed, error code":"installation failed, error code","installation is complete, please close the current window":"installation is complete, please close the current window","installed":"installed","installing plugin":"installing plugin","last version":"last version","light backup":"light backup","like":"like","liked":"liked","loading data":"loading data","local backup":"local backup","maintain":"maintain","manual install":"manual install","monitor":"Monitor","multimedia":"Multimedia","nas":"NAS","net":"Net","networking":"Networking","no files selected":"no files selected","no internet required for recovery":"no internet required for recovery","offline install":"offline install","offline installation failed with error code":"offline installation failed with error code","offline installation is successful, please close the current window":"offline installation is successful, please close the current window","open":"open","order":"order","please enter an absolute path starting with %{name}":"please enter an absolute path starting with %{name}","please enter the path, give up the input, please clear the input box":"please enter the path, give up the input, please clear the input box","please enter the search keyword":"please enter the search keyword","please fill in the external storage directory":"please fill in the external storage directory","please select a backup file to restore":"please select a backup file to restore","restore backup":"restore backup","restore now":"restore now","restoring backup":"restoring backup","select or drag and drop files":"select or drag and drop files","service":"Service","support .ipk plug-in, .run self-extracting format":"support .ipk plug-in, .run self-extracting format","system":"System","tag":"Tag","the backup was restored fail":"the backup was restored fail","the backup was restored success":"the backup was restored success","the is last version":"the is last version","the update is success, please close the current window":"the update is success, please close the current window","there are no backup files in this path":"there are no backup files in this path","tool":"Tool","uninstall":"uninstall","uninstall failed, error code":"uninstall failed, error code","uninstallation succeeded, please close the current window":"uninstallation succeeded, please close the current window","uninstalling plugin":"uninstalling plugin","update date":"update date","update error":"update error","update failed with error code":"update failed with error code","update success":"update success","updateing":"updateing","updating plugin":"updating plugin","upgrade":"upgrade","upload software list and install from iStore when restoring backup":"upload software list and install from iStore when restoring backup","uploading plugin":"uploading plugin","website":"website","you have already liked":"you have already liked"}}
|
||||
{"en":{"%{ num } download":["%{ num } download","%{ num } downloads"],"%{ num } like":["%{ num } like","%{ num } likes"],"all app":"all app","app backup":"app backup","are you sure you want to uninstall %{name}?":"are you sure you want to uninstall %{name}?","author":"author","backup fail":"backup fail","backup fail with error code":"backup fail with error code","backup now":"backup now","backup now backs up installed software (unlimited installation sources) to external storage":"backup now backs up installed software (unlimited installation sources) to external storage","backup now will download a list of iStore installed software":"backup now will download a list of iStore installed software","backup success":"backup success","backuping":"backuping","By download":"By download","By rating":"By rating","checking for latest version":"checking for latest version","choose":"choose","choose backup file":"choose backup file","click to download":"click to download","click to update":"click to update","closed":"closed","customize":"customize","default":"default","download":"Download","explain":"explain","external storage directory":"external storage directory","from this page, you can upload plugin packages to install plugins":"from this page, you can upload plugin packages to install plugins","Icon is gone":"Icon is gone","install":"install","installation failed, error code":"installation failed, error code","installed":"installed","last version":"last version","light backup":"light backup","like":"like","liked":"liked","loading data":"loading data","local backup":"local backup","maintain":"maintain","manual install":"manual install","monitor":"Monitor","multimedia":"Multimedia","nas":"NAS","net":"Net","networking":"Networking","no files selected":"no files selected","no internet required for recovery":"no internet required for recovery","offline install":"offline install","offline installation failed with error code":"offline installation failed with error code","open":"open","order":"order","please enter an absolute path starting with %{name}":"please enter an absolute path starting with %{name}","please enter the path, give up the input, please clear the input box":"please enter the path, give up the input, please clear the input box","please enter the search keyword":"please enter the search keyword","please fill in the external storage directory":"please fill in the external storage directory","please select a backup file to restore":"please select a backup file to restore","restore backup":"restore backup","restore failed with error code":"restore failed with error code","restore now":"restore now","select or drag and drop files":"select or drag and drop files","service":"Service","support .ipk plug-in, .run self-extracting format":"support .ipk plug-in, .run self-extracting format","system":"System","tag":"Tag","the is last version":"the is last version","there are no backup files in this path":"there are no backup files in this path","tool":"Tool","uninstall":"uninstall","uninstall failed, error code":"uninstall failed, error code","update date":"update date","update error":"update error","update failed with error code":"update failed with error code","update success, reloading":"update success, reloading","updateing":"updateing","upgrade":"upgrade","upload software list and install from iStore when restoring backup":"upload software list and install from iStore when restoring backup","uploading":"uploading","website":"website","you have already liked":"you have already liked"}}
|
@ -1 +1 @@
|
||||
{"zh-cn":{"%{ num } download":["%{ num } 次下载","%{ num } 次下载"],"%{ num } like":["%{ num } 次点赞","%{ num } 次点赞"],"all app":"全部软件","app backup":"软件备份","are you sure you want to uninstall %{name}?":"确定要卸载 %{name} 吗?","author":"作者","backup fail":"备份失败","backup now":"立即备份","backup now backs up installed software (unlimited installation sources) to external storage":"立即备份将备份已安装软件(不限安装来源)到外部存储","backup now will download a list of iStore installed software":"立即备份将下载iStore已安装的软件列表","backup success":"备份成功","backuping":"正在备份","By download":"按下载","By rating":"按评分","checking for latest version":"正在检查最新版本","choose":"请选择","choose backup file":"选择备份文件","click to download":"点此下载","click to update":"点我更新","closed":"关闭","customize":"自定义","default":"默认","do not refresh this page during plugin installation/uninstallation":"插件安装/卸载过程中请勿刷新此页面","download":"下载","explain":"说明","external storage directory":"外部存储目录","from this page, you can upload plugin packages to install plugins":"通过本页,你可以上传插件包来安装插件","Icon is gone":"图标出走啦","install":"安装","installation failed, error code":"安装失败,错误码","installation is complete, please close the current window":"安装完成,请关闭当前窗口","installed":"已安装","installing plugin":"正在安装插件","last version":"最新版本","light backup":"轻量备份","like":"点赞","liked":"已点赞","loading data":"正在努力的获取数据","local backup":"本地备份","maintain":"维护","manual install":"手动安装","monitor":"监控","multimedia":"多媒体","nas":"NAS","net":"网络","networking":"组网","no files selected":"未选择任何文件","no internet required for recovery":"恢复时不需要网络","offline install":"离线安装","offline installation failed with error code":"离线安装失败,错误码","offline installation is successful, please close the current window":"离线安装成功,请关闭当前窗口","open":"打开","order":"排序","please enter an absolute path starting with %{name}":"请输入 %{name} 开头的绝对路径","please enter the path, give up the input, please clear the input box":"请输入路径,放弃输入请清空输入框","please enter the search keyword":"请输入搜索关键词","please fill in the external storage directory":"请填写外部存储目录","please select a backup file to restore":"请选择要恢复的备份文件","restore backup":"恢复备份","restore now":"立即恢复","restoring backup":"正在恢复备份","select or drag and drop files":"选择或拖放文件","service":"服务","support .ipk plug-in, .run self-extracting format":"支持 .ipk 插件,.run 自解压格式","system":"系统","tag":"标签","the backup was restored fail":"恢复备份失败","the backup was restored success":"恢复备份成功","the is last version":"当前已经是最新版本","the update is success, please close the current window":"更新成功,请关闭当前窗口","there are no backup files in this path":"此路径下没有备份文件","tool":"工具","uninstall":"卸载","uninstall failed, error code":"卸载失败,错误码","uninstallation succeeded, please close the current window":"卸载完成,请关闭当前窗口","uninstalling plugin":"正在卸载插件","update date":"更新日期","update error":"更新失败","update failed with error code":"更新失败,错误代码","update success":"更新成功","updateing":"正在更新中","updating plugin":"正在更新插件","upgrade":"更新","upload software list and install from iStore when restoring backup":"复备份时上传软件列表并从iStore安装","uploading plugin":"正在上传插件","website":"官网","you have already liked":"您已经点赞过啦"}}
|
||||
{"zh-cn":{"%{ num } download":["%{ num } 次下载","%{ num } 次下载"],"%{ num } like":["%{ num } 次点赞","%{ num } 次点赞"],"all app":"全部软件","app backup":"软件备份","are you sure you want to uninstall %{name}?":"确定要卸载 %{name} 吗?","author":"作者","backup fail":"备份失败","backup fail with error code":"备份失败,错误代码","backup now":"立即备份","backup now backs up installed software (unlimited installation sources) to external storage":"立即备份将备份已安装软件(不限安装来源)到外部存储","backup now will download a list of iStore installed software":"立即备份将下载iStore已安装的软件列表","backup success":"备份成功","backuping":"正在备份","By download":"按下载","By rating":"按评分","checking for latest version":"正在检查最新版本","choose":"请选择","choose backup file":"选择备份文件","click to download":"点此下载","click to update":"点我更新","closed":"关闭","customize":"自定义","default":"默认","download":"下载","explain":"说明","external storage directory":"外部存储目录","from this page, you can upload plugin packages to install plugins":"通过本页,你可以上传插件包来安装插件","Icon is gone":"图标出走啦","install":"安装","installation failed, error code":"安装失败,错误码","installed":"已安装","last version":"最新版本","light backup":"轻量备份","like":"点赞","liked":"已点赞","loading data":"正在努力的获取数据","local backup":"本地备份","maintain":"维护","manual install":"手动安装","monitor":"监控","multimedia":"多媒体","nas":"NAS","net":"网络","networking":"组网","no files selected":"未选择任何文件","no internet required for recovery":"恢复时不需要网络","offline install":"离线安装","offline installation failed with error code":"离线安装失败,错误码","open":"打开","order":"排序","please enter an absolute path starting with %{name}":"请输入 %{name} 开头的绝对路径","please enter the path, give up the input, please clear the input box":"请输入路径,放弃输入请清空输入框","please enter the search keyword":"请输入搜索关键词","please fill in the external storage directory":"请填写外部存储目录","please select a backup file to restore":"请选择要恢复的备份文件","restore backup":"恢复备份","restore failed with error code":"恢复失败,错误代码","restore now":"立即恢复","select or drag and drop files":"选择或拖放文件","service":"服务","support .ipk plug-in, .run self-extracting format":"支持 .ipk 插件,.run 自解压格式","system":"系统","tag":"标签","the is last version":"当前已经是最新版本","there are no backup files in this path":"此路径下没有备份文件","tool":"工具","uninstall":"卸载","uninstall failed, error code":"卸载失败,错误码","update date":"更新日期","update error":"更新失败","update failed with error code":"更新失败,错误代码","update success, reloading":"更新成功,重新加载页面","updateing":"正在更新中","upgrade":"更新","upload software list and install from iStore when restoring backup":"复备份时上传软件列表并从iStore安装","uploading":"上传中","website":"官网","you have already liked":"您已经点赞过啦"}}
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -71,7 +71,7 @@ config PACKAGE_$(PKG_NAME)_INCLUDE_Xray
|
||||
|
||||
config PACKAGE_$(PKG_NAME)_INCLUDE_Trojan
|
||||
bool "Include Trojan"
|
||||
default n
|
||||
default y if i386||x86_64||arm||aarch64
|
||||
|
||||
config PACKAGE_$(PKG_NAME)_INCLUDE_NaiveProxy
|
||||
bool "Include NaiveProxy"
|
||||
|
@ -161,7 +161,7 @@ gen_config_file(){
|
||||
tcp|udp|nf) smode=nat;;
|
||||
socks) smode=client;;
|
||||
esac
|
||||
lua $BIN_DIR/gentrojanconfig $1 $smode $lport $serv_ip $threads >$config_file
|
||||
lua $BIN_DIR/gen_config $1 $smode $lport $ssport $serv_ip >$config_file
|
||||
sed -i 's/\\//g' $config_file
|
||||
;;
|
||||
esac
|
||||
|
@ -296,7 +296,7 @@ local hysteria = {
|
||||
protocol = server.hysteria_protocol,
|
||||
up_mbps = tonumber(server.uplink_capacity),
|
||||
down_mbps = tonumber(server.downlink_capacity),
|
||||
socks5 = (proto:find("tcp") and tonumber(socks_port) and tonumber(socks_port) ~= "0") and {
|
||||
socks5 = (proto:find("tcp") and tonumber(socks_port) and tonumber(socks_port) ~= 0) and {
|
||||
listen = "0.0.0.0:" .. tonumber(socks_port),
|
||||
timeout = 300,
|
||||
disable_udp = false
|
||||
|
@ -7,16 +7,16 @@ 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_DEPENDS:=+curl +opkg +luci-base +tar +coreutils +coreutils-stat +libuci-lua +mount-utils +luci-lib-taskd
|
||||
LUCI_PKGARCH:=all
|
||||
|
||||
PKG_VERSION:=0.1.10-7
|
||||
PKG_VERSION:=0.1.11-1
|
||||
# PKG_RELEASE MUST be empty for luci.mk
|
||||
PKG_RELEASE:=
|
||||
|
||||
ISTORE_UI_VERSION:=0.1.10
|
||||
ISTORE_UI_RELEASE:=7
|
||||
PKG_HASH:=ba784985b9b3aa90c704c03b16611922e7df2e1f0e18c4a4ec9bff0e09688426
|
||||
ISTORE_UI_VERSION:=0.1.11
|
||||
ISTORE_UI_RELEASE:=1
|
||||
PKG_HASH:=e78b07c257c38892f028faeaea3a64ee47e11137523e1c046df95c87be7abf90
|
||||
|
||||
PKG_SOURCE_URL_FILE:=v$(ISTORE_UI_VERSION)-$(ISTORE_UI_RELEASE).tar.gz
|
||||
PKG_SOURCE:=istore-ui-$(PKG_SOURCE_URL_FILE)
|
||||
|
@ -1,6 +1,7 @@
|
||||
module("luci.controller.store", package.seeall)
|
||||
|
||||
local myopkg = "is-opkg"
|
||||
local is_backup = "/usr/libexec/istore/backup"
|
||||
local page_index = {"admin", "store", "pages"}
|
||||
|
||||
function index()
|
||||
@ -24,25 +25,26 @@ function index()
|
||||
entry({"admin", "store", "check_self_upgrade"}, call("check_self_upgrade"))
|
||||
entry({"admin", "store", "do_self_upgrade"}, post("do_self_upgrade"))
|
||||
|
||||
entry({"admin", "store", "get_support_backup_features"}, call("get_support_backup_features"))
|
||||
entry({"admin", "store", "light_backup"}, post("light_backup"))
|
||||
entry({"admin", "store", "get_light_backup_file"}, call("get_light_backup_file"))
|
||||
entry({"admin", "store", "local_backup"}, post("local_backup"))
|
||||
entry({"admin", "store", "light_restore"}, post("light_restore"))
|
||||
entry({"admin", "store", "local_restore"}, post("local_restore"))
|
||||
entry({"admin", "store", "get_backup_app_list_file_path"}, call("get_backup_app_list_file_path"))
|
||||
entry({"admin", "store", "get_backup_app_list"}, call("get_backup_app_list"))
|
||||
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"))
|
||||
|
||||
for _, action in ipairs({"update", "install", "upgrade", "remove"}) do
|
||||
store_api(action, true)
|
||||
end
|
||||
for _, action in ipairs({"status", "installed"}) do
|
||||
store_api(action, false)
|
||||
end
|
||||
if nixio.fs.access("/usr/libexec/istore/backup") then
|
||||
entry({"admin", "store", "get_support_backup_features"}, call("get_support_backup_features"))
|
||||
entry({"admin", "store", "light_backup"}, post("light_backup"))
|
||||
entry({"admin", "store", "get_light_backup_file"}, call("get_light_backup_file"))
|
||||
entry({"admin", "store", "local_backup"}, post("local_backup"))
|
||||
entry({"admin", "store", "light_restore"}, post("light_restore"))
|
||||
entry({"admin", "store", "local_restore"}, post("local_restore"))
|
||||
entry({"admin", "store", "get_backup_app_list_file_path"}, call("get_backup_app_list_file_path"))
|
||||
entry({"admin", "store", "get_backup_app_list"}, call("get_backup_app_list"))
|
||||
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
|
||||
|
||||
local function user_id()
|
||||
@ -74,7 +76,7 @@ local function vue_lang()
|
||||
return lang
|
||||
end
|
||||
|
||||
local function is_exec(cmd)
|
||||
local function is_exec(cmd, async)
|
||||
local nixio = require "nixio"
|
||||
local os = require "os"
|
||||
local fs = require "nixio.fs"
|
||||
@ -93,6 +95,9 @@ local function is_exec(cmd)
|
||||
return 255, "", "Lock failed: " .. msg
|
||||
end
|
||||
|
||||
if async then
|
||||
cmd = "/etc/init.d/tasks task_add istore " .. luci.util.shellquote(cmd)
|
||||
end
|
||||
local r = os.execute(cmd .. " >/var/log/istore.stdout 2>/var/log/istore.stderr")
|
||||
local e = fs.readfile("/var/log/istore.stderr")
|
||||
local o = fs.readfile("/var/log/istore.stdout")
|
||||
@ -115,7 +120,13 @@ function redirect_index()
|
||||
end
|
||||
|
||||
function store_index()
|
||||
luci.template.render("store/main", {prefix=luci.dispatcher.build_url(unpack(page_index)),id=user_id(),lang=vue_lang()})
|
||||
local fs = require "nixio.fs"
|
||||
local features = { "_lua_force_array_" }
|
||||
if fs.access("/usr/libexec/istore/backup") then
|
||||
features[#features+1] = "backup"
|
||||
end
|
||||
|
||||
luci.template.render("store/main", {prefix=luci.dispatcher.build_url(unpack(page_index)),id=user_id(),lang=vue_lang(),features=features})
|
||||
end
|
||||
|
||||
function store_dev()
|
||||
@ -169,17 +180,15 @@ end
|
||||
|
||||
-- Internal action function
|
||||
local function _action(exe, cmd, ...)
|
||||
local os = require "os"
|
||||
local fs = require "nixio.fs"
|
||||
|
||||
local pkg = ""
|
||||
for k, v in pairs({...}) do
|
||||
pkg = pkg .. " '" .. v:gsub("'", "") .. "'"
|
||||
pkg = pkg .. " " .. luci.util.shellquote(v)
|
||||
end
|
||||
|
||||
local c = "%s %s %s" %{ exe, cmd, pkg }
|
||||
|
||||
return is_exec(c)
|
||||
return is_exec(c, true)
|
||||
end
|
||||
|
||||
function store_action(param)
|
||||
@ -241,11 +250,6 @@ function store_action(param)
|
||||
code, out, err = _action(myopkg, action, unpack(pkgs))
|
||||
else -- remove
|
||||
code, out, err = _action(myopkg, action, unpack(pkgs))
|
||||
if code ~= 0 then
|
||||
code, out0, err0 = _action(myopkg, action, unpack(pkgs))
|
||||
out = out .. out0
|
||||
err = err .. err0
|
||||
end
|
||||
fs.unlink("/tmp/luci-indexcache")
|
||||
end
|
||||
end
|
||||
@ -295,15 +299,15 @@ function store_upload()
|
||||
out = ""
|
||||
if finished then
|
||||
if string.lower(string.sub(path, -4, -1)) == ".run" then
|
||||
code, out, err = _action("sh", "-c", "ls -l \"%s\"; md5sum \"%s\" 2>/dev/null; chmod 755 \"%s\" && \"%s\"" %{ path, path, path, path })
|
||||
code, out, err = _action("sh", "-c", "ls -l \"%s\"; md5sum \"%s\" 2>/dev/null; chmod 755 \"%s\" && \"%s\"; RET=$?; rm -f \"%s\"; exit $RET" %{ path, path, path, path, path })
|
||||
else
|
||||
code, out, err = _action("opkg", "install", path)
|
||||
code, out, err = _action("sh", "-c", "opkg install \"%s\"; RET=$?; rm -f \"%s\"; exit $RET" %{ path, path })
|
||||
end
|
||||
else
|
||||
code = 500
|
||||
err = "upload failed!"
|
||||
end
|
||||
nixio.fs.unlink(path)
|
||||
--nixio.fs.unlink(path)
|
||||
local ret = {
|
||||
code = code,
|
||||
stdout = out,
|
||||
@ -355,8 +359,8 @@ end
|
||||
function get_support_backup_features()
|
||||
local jsonc = require "luci.jsonc"
|
||||
local error_ret = {code = 500, msg = "Unknown"}
|
||||
local success_ret = {code = 200,msg = "Unknown"}
|
||||
local r,o,e = is_exec(myopkg .. " get_support_backup_features")
|
||||
local success_ret = {code = 200, msg = "Unknown"}
|
||||
local r,o,e = is_exec(is_backup .. " get_support_backup_features")
|
||||
if r ~= 0 then
|
||||
error_ret.msg = e
|
||||
luci.http.prepare_content("application/json")
|
||||
@ -374,7 +378,7 @@ function light_backup()
|
||||
local jsonc = require "luci.jsonc"
|
||||
local error_ret = {code = 500, msg = "Unknown"}
|
||||
local success_ret = {code = 200,msg = "Unknown"}
|
||||
local r,o,e = is_exec(myopkg .. " backup")
|
||||
local r,o,e = is_exec(is_backup .. " backup")
|
||||
|
||||
if r ~= 0 then
|
||||
error_ret.msg = e
|
||||
@ -432,13 +436,13 @@ function local_backup()
|
||||
code,out,err = is_exec("findmnt -T " .. path .. " -o TARGET|sed -n 2p")
|
||||
if out:gsub("[\r\n]", "") == "/" or out:gsub("[\r\n]", "") == "/tmp" then
|
||||
-- error
|
||||
error_ret = {code = 500, msg = "Path Error,Can not be / or tmp."}
|
||||
error_ret = {code = 500, stderr = "Path Error,Can not be / or tmp."}
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(error_ret)
|
||||
else
|
||||
-- update local backup path
|
||||
update_local_backup_path(path)
|
||||
code,out,err = is_exec(myopkg .. " backup " .. path)
|
||||
code,out,err = _action(is_backup, "backup", path)
|
||||
ret = {
|
||||
code = code,
|
||||
stdout = out,
|
||||
@ -449,7 +453,7 @@ function local_backup()
|
||||
end
|
||||
else
|
||||
-- error
|
||||
error_ret = {code = 500, msg = "Path Unknown"}
|
||||
error_ret = {code = 500, stderr = "Path Unknown"}
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(error_ret)
|
||||
end
|
||||
@ -481,8 +485,9 @@ function light_restore()
|
||||
|
||||
if finished then
|
||||
is_exec("rm /etc/istore/app.list;tar -xzf " .. path .. " -C /")
|
||||
nixio.fs.unlink(path)
|
||||
if nixio.fs.access("/etc/istore/app.list") then
|
||||
code,out,err = is_exec(myopkg .. " restore")
|
||||
code,out,err = _action(is_backup, "restore")
|
||||
ret = {
|
||||
code = code,
|
||||
stdout = out,
|
||||
@ -491,14 +496,12 @@ function light_restore()
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(ret)
|
||||
else
|
||||
local error_ret = {code = 500, msg = "File is error!"}
|
||||
local error_ret = {code = 500, stderr = "File is error!"}
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(error_ret)
|
||||
end
|
||||
-- remove file
|
||||
is_exec("rm " .. path)
|
||||
else
|
||||
ret = {code = 500, msg = "upload failed!"}
|
||||
ret = {code = 500, stderr = "upload failed!"}
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(ret)
|
||||
end
|
||||
@ -509,7 +512,7 @@ function local_restore()
|
||||
local path = luci.http.formvalue("path")
|
||||
local code, out, err, ret
|
||||
if path ~= "" then
|
||||
code,out,err = is_exec(myopkg .. " restore " .. path)
|
||||
code,out,err = _action(is_backup, "restore", path)
|
||||
ret = {
|
||||
code = code,
|
||||
stdout = out,
|
||||
@ -519,7 +522,7 @@ function local_restore()
|
||||
luci.http.write_json(ret)
|
||||
else
|
||||
-- error
|
||||
error_ret = {code = 500, msg = "Path Unknown"}
|
||||
error_ret = {code = 500, stderr = "Path Unknown"}
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(error_ret)
|
||||
end
|
||||
@ -530,7 +533,7 @@ function get_backup_app_list_file_path()
|
||||
local jsonc = require "luci.jsonc"
|
||||
local error_ret = {code = 500, msg = "Unknown"}
|
||||
local success_ret = {code = 200,msg = "Unknown"}
|
||||
local r,o,e = is_exec(myopkg .. " get_backup_app_list_file_path")
|
||||
local r,o,e = is_exec(is_backup .. " get_backup_app_list_file_path")
|
||||
if r ~= 0 then
|
||||
error_ret.msg = e
|
||||
luci.http.prepare_content("application/json")
|
||||
@ -548,7 +551,7 @@ function get_backup_app_list()
|
||||
local jsonc = require "luci.jsonc"
|
||||
local error_ret = {code = 500, msg = "Unknown"}
|
||||
local success_ret = {code = 200,msg = "Unknown"}
|
||||
local r,o,e = is_exec(myopkg .. " get_backup_app_list")
|
||||
local r,o,e = is_exec(is_backup .. " get_backup_app_list")
|
||||
if r ~= 0 then
|
||||
error_ret.msg = e
|
||||
luci.http.prepare_content("application/json")
|
||||
@ -572,7 +575,7 @@ function get_available_backup_file_list()
|
||||
if path ~= "" then
|
||||
-- update local backup path
|
||||
update_local_backup_path(path)
|
||||
r,o,e = is_exec(myopkg .. " get_available_backup_file_list " .. path)
|
||||
r,o,e = is_exec(is_backup .. " get_available_backup_file_list " .. path)
|
||||
if r ~= 0 then
|
||||
error_ret.msg = e
|
||||
luci.http.prepare_content("application/json")
|
||||
|
@ -1,4 +1,7 @@
|
||||
<%+header%>
|
||||
<%
|
||||
local jsonc = require "luci.jsonc"
|
||||
%>
|
||||
<script>
|
||||
(function(){
|
||||
var vue_prefix="<%=prefix%>";
|
||||
@ -16,6 +19,7 @@
|
||||
window.vue_lang = '<%=lang%>';
|
||||
window.token = "<%=token%>";
|
||||
window.device_id = {arch:"<%=id.arch%>",uid:"<%=id.uid%>",version:"<%=id.version%>"};
|
||||
window.istore_features = <%=jsonc.stringify(features)%>;
|
||||
})();
|
||||
</script>
|
||||
<h2 name="content"><%:iStore%>
|
||||
@ -26,5 +30,32 @@
|
||||
<link rel="stylesheet" href="/luci-static/istore/style.css?v=<%=id.version%>">
|
||||
<div id="app">
|
||||
</div>
|
||||
<%+tasks/embed%>
|
||||
|
||||
<script>
|
||||
(function() {
|
||||
let beforeunloadRegistered = false;
|
||||
window.istore_log = function(flush_menu_onclose) {
|
||||
if (flush_menu_onclose && !beforeunloadRegistered) {
|
||||
beforeunloadRegistered = true;
|
||||
window.addEventListener("beforeunload", function(event) {
|
||||
try { window.L.ui.menu.flushCache() } catch (e) { }
|
||||
return true;
|
||||
});
|
||||
}
|
||||
taskd.show_log("istore", true);
|
||||
};
|
||||
})();
|
||||
<%
|
||||
local taskd = require "luci.model.tasks"
|
||||
local status = taskd.status("istore")
|
||||
if status.running then
|
||||
-%>
|
||||
window.istore_log(true);
|
||||
<%
|
||||
end
|
||||
%>
|
||||
</script>
|
||||
|
||||
<script type="module" crossorigin src="/luci-static/istore/index.js?v=<%=id.version%>"></script>
|
||||
<%+footer%>
|
@ -1,14 +1,10 @@
|
||||
#!/bin/sh
|
||||
#set -x
|
||||
#IS_DEBUG=1
|
||||
|
||||
IS_ROOT=/tmp/is-root
|
||||
DL_DIR=${IS_ROOT}/tmp/dl
|
||||
LISTS_DIR_O=/tmp/opkg-lists
|
||||
LISTS_DIR=${IS_ROOT}${LISTS_DIR_O}
|
||||
OPKG_CONF_DIR=${IS_ROOT}/etc/opkg
|
||||
APP_LIST_FILE=/etc/istore/app.list
|
||||
BACKUP_CONFIG_FILE=/etc/config/istore
|
||||
FEEDS_SERVER=https://istore.linkease.com/repo
|
||||
ARCH=`jsonfilter -i /etc/.app_store.id -e '$.arch'`
|
||||
|
||||
@ -126,249 +122,8 @@ new_upgrade() {
|
||||
wrapped_in_update upgrade "$@"
|
||||
}
|
||||
|
||||
opkg_list_installed_packages() {
|
||||
target=$1
|
||||
case $target in
|
||||
"preinstalled")
|
||||
OPKG_INFO_DIR="/rom/usr/lib/opkg/info"
|
||||
;;
|
||||
"userinstalled")
|
||||
OPKG_INFO_DIR="/overlay/upper/usr/lib/opkg/info"
|
||||
;;
|
||||
"allinstalled")
|
||||
OPKG_INFO_DIR="/usr/lib/opkg/info"
|
||||
;;
|
||||
*)
|
||||
echo "invalid target"
|
||||
exit
|
||||
;;
|
||||
esac
|
||||
(cd $OPKG_INFO_DIR && find . -depth -maxdepth 1 -name "*.list" -type f | sed 's#^\./\(.*\)\.list$#\1#g')
|
||||
}
|
||||
|
||||
ipk_build() {
|
||||
PKG_NAME_TEMP=$1
|
||||
IPK_OUTPUT_DIR=$2
|
||||
|
||||
UCI_BAK_DIR="/etc/istore/uci-defaults_bak/"
|
||||
UCI_DEF_DIR="etc/uci-defaults"
|
||||
OPKG_INFO_DIR="/usr/lib/opkg/info/"
|
||||
|
||||
[ -n "${PKG_NAME_TEMP}" ] || exit 1
|
||||
#get real pkg name in opkg
|
||||
PKG_NAME_TEMP=`cat ${IS_ROOT}/all_installed_package.list | sort -u | grep "^${PKG_NAME_TEMP}" | head -n 1`
|
||||
[ -n "${PKG_NAME_TEMP}" ] || exit 1
|
||||
|
||||
PKG_NAME=`cat ${OPKG_INFO_DIR}${PKG_NAME_TEMP}.control | grep "^Package: " | cut -d ' ' -f2`
|
||||
PKG_VER=`cat ${OPKG_INFO_DIR}${PKG_NAME}.control | grep "^Version: " | cut -d ' ' -f2`
|
||||
PKG_ARCH=`cat ${OPKG_INFO_DIR}${PKG_NAME}.control | grep "^Architecture: " | cut -d ' ' -f2`
|
||||
IPK_FILE_NAME="${PKG_NAME}_${PKG_VER}_${PKG_ARCH}"
|
||||
|
||||
rm -rf ${IS_ROOT}/${IPK_FILE_NAME}
|
||||
mkdir -p ${IS_ROOT}/${IPK_FILE_NAME}
|
||||
|
||||
#(1)make CONTROL dir; (2)copy control file to dir
|
||||
cd ${IS_ROOT}/${IPK_FILE_NAME}
|
||||
mkdir -p CONTROL
|
||||
for control_file in `ls ${OPKG_INFO_DIR}${PKG_NAME}.* | grep -v ".list$"`; do
|
||||
file=${control_file##*/}
|
||||
suffix=${file##*.}
|
||||
cp ${control_file} CONTROL/${suffix}
|
||||
done
|
||||
|
||||
#(1)make DATA depend dir; (2)copy uci-defaults_bak file to dir; (3)copy other file to dir
|
||||
for pkgfile in `cat ${OPKG_INFO_DIR}${PKG_NAME}.list | cut -b 2-`; do
|
||||
file=${pkgfile##*/}
|
||||
path=${pkgfile%/*}
|
||||
mkdir -p ${path}
|
||||
if [ `echo "${path}" | grep "^${UCI_DEF_DIR}"` ]; then
|
||||
cp "${UCI_BAK_DIR}${file}" "${pkgfile}"
|
||||
else
|
||||
cp "/${pkgfile}" "${pkgfile}"
|
||||
fi
|
||||
done
|
||||
|
||||
#call ipkg-build script to build ipk
|
||||
ipkg-build ${IS_ROOT}/${IPK_FILE_NAME} ${IPK_OUTPUT_DIR}
|
||||
echo "${IPK_FILE_NAME}.ipk" >> ${IPK_OUTPUT_DIR}/appdepipk.list
|
||||
|
||||
[ -n "${IS_DEBUG}" ] || rm -rf ${IS_ROOT}/${IPK_FILE_NAME}
|
||||
}
|
||||
|
||||
# if arg is NULL, use light backup, otherwise use local backup
|
||||
backup() {
|
||||
[ -n "$1" ] && BACKUP_PATH=$1
|
||||
|
||||
#1.add all istore self data to sysupgrade config file,
|
||||
#sysupgrade will backup/restore it auto when flash new firmware
|
||||
echo "/etc/.app_store.id" > /lib/upgrade/keep.d/luci-app-store
|
||||
cat /usr/lib/opkg/info/luci-app-store.list >> /lib/upgrade/keep.d/luci-app-store
|
||||
echo "/etc/rc.d/S45istore" >> /lib/upgrade/keep.d/luci-app-store
|
||||
echo "/etc/istore/uci-defaults_bak" >> /lib/upgrade/keep.d/luci-app-store
|
||||
echo "${APP_LIST_FILE}" >> /lib/upgrade/keep.d/luci-app-store
|
||||
echo "${BACKUP_CONFIG_FILE}" >> /lib/upgrade/keep.d/luci-app-store
|
||||
|
||||
#write user installed package list to file
|
||||
opkg_list_installed_packages "userinstalled" 2>/dev/null | sort -u > ${IS_ROOT}/user_installed_package.list
|
||||
|
||||
#write installed package list by istore feed to file
|
||||
cat ${IS_ROOT}/user_installed_package.list | \
|
||||
grep '^app-meta-' > ${IS_ROOT}/istore_installed_package.list
|
||||
|
||||
#if no input backup path, only back app.list
|
||||
mkdir -p /etc/istore
|
||||
cp ${IS_ROOT}/istore_installed_package.list ${APP_LIST_FILE}
|
||||
echo "backup installed package list to ${APP_LIST_FILE}"
|
||||
|
||||
if [ ! -n "${BACKUP_PATH}" ]; then
|
||||
echo "backup success"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ ! -d "${BACKUP_PATH}" ] && ! mkdir -p "${BACKUP_PATH}" ; then
|
||||
echo "invalid backup path, can not backup ipk"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#write all installed package list to file
|
||||
opkg_list_installed_packages "allinstalled" 2>/dev/null | sort -u > ${IS_ROOT}/all_installed_package.list
|
||||
|
||||
#write system pre installed package list to file
|
||||
opkg_list_installed_packages "preinstalled" 2>/dev/null | sort -u > ${IS_ROOT}/pre_installed_package.list
|
||||
|
||||
#write installed packages and depends list by istore feed to file by depend sequence
|
||||
appdep_list=""
|
||||
temp_list=`cat ${IS_ROOT}/istore_installed_package.list | sed 's/^/\t/'`
|
||||
while [ -n "${temp_list}" ]
|
||||
do
|
||||
#get real pkg name
|
||||
for PKG_NAME_TEMP in ${temp_list}; do
|
||||
REAL_PKG_NAME=`cat ${IS_ROOT}/all_installed_package.list | sort -u | grep "^${PKG_NAME_TEMP}" | head -n 1`
|
||||
if [ "${REAL_PKG_NAME}" != "${PKG_NAME_TEMP}" ]; then
|
||||
temp_list=`echo "${temp_list}" | sed 's/^\t'"${PKG_NAME_TEMP}"'$/\t'"${REAL_PKG_NAME}"'/'`
|
||||
fi
|
||||
done
|
||||
|
||||
appdep_list=`echo -e "${temp_list}\n${appdep_list}"`
|
||||
[ -n "${IS_DEBUG}" ] && echo -e "temp_list:\n""${temp_list}"
|
||||
[ -n "${IS_DEBUG}" ] && echo -e "appdep_list:\n""${appdep_list}"
|
||||
|
||||
temp_list=`echo "${temp_list}" | xargs opkg depends | grep -v "depends on:" | grep -v " (>= " | grep -v " (= " | sort -u`
|
||||
done
|
||||
|
||||
appdep_list_all=`echo "${appdep_list}" | cut -f2 | grep -v "^$" | awk '!seen[$0]++'`
|
||||
[ -n "${IS_DEBUG}" ] && echo -e "appdep_list_all:\n""${appdep_list_all}"
|
||||
echo "${appdep_list_all}" > ${IS_ROOT}/appdep.list
|
||||
|
||||
#3.rebuild all istore installed package to ipk and backup to userdata partation
|
||||
|
||||
# 4. create dir
|
||||
date=$(date +%Y-%m%d-%H%M)
|
||||
if [ ! -d "$BACKUP_PATH/backup_istore_$date" ];then
|
||||
mkdir $BACKUP_PATH/backup_istore_$date
|
||||
fi
|
||||
cp ${IS_ROOT}/istore_installed_package.list $BACKUP_PATH/backup_istore_$date/app.list
|
||||
cp ${IS_ROOT}/appdep.list $BACKUP_PATH/backup_istore_$date/appdep.list
|
||||
|
||||
#only backup non pre installed ipk
|
||||
cp ${IS_ROOT}/appdep.list ${IS_ROOT}/appdep_strip.list
|
||||
for pre_installed_pkg in `cat ${IS_ROOT}/appdep.list ${IS_ROOT}/pre_installed_package.list | sort -n | uniq -d`; do
|
||||
sed -i '/^'"$pre_installed_pkg"'$/d' ${IS_ROOT}/appdep_strip.list
|
||||
done
|
||||
|
||||
rm -f $BACKUP_PATH/backup_istore_$date/appdepipk.list
|
||||
echo "build ipk"
|
||||
for pkg_name in `cat ${IS_ROOT}/appdep_strip.list`; do
|
||||
ipk_build ${pkg_name} $BACKUP_PATH/backup_istore_$date
|
||||
done
|
||||
|
||||
# 5. create tar.gz file,and remove fir
|
||||
cd $BACKUP_PATH
|
||||
echo "write backup file to $BACKUP_PATH/backup_istore_$date.backup.tar.gz"
|
||||
tar -czf $BACKUP_PATH/backup_istore_$date.backup.tar.gz backup_istore_$date
|
||||
rm -rf $BACKUP_PATH/backup_istore_$date
|
||||
echo "backup success"
|
||||
}
|
||||
|
||||
# if arg is NULL, use light backup, otherwise use local backup
|
||||
restore() {
|
||||
if [ -n "$1" ]; then
|
||||
BACKUP_PATH_FILE=$1
|
||||
else
|
||||
echo "install package by ${APP_LIST_FILE}"
|
||||
update
|
||||
for app in `cat ${APP_LIST_FILE}`; do
|
||||
#skip resotre istore self
|
||||
[ "A${app}" == "A""luci-app-store" ] && continue
|
||||
opkg_wrap install ${app}
|
||||
done
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ ! -f "${BACKUP_PATH_FILE}" ];then
|
||||
echo "invalid backup file, can not restore ipk"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#1. Unzip file to dir
|
||||
BACKUP_PATH_FILE_NAME=${BACKUP_PATH_FILE##*/}
|
||||
BACKUP_PATH=/tmp/${BACKUP_PATH_FILE_NAME%.backup.tar.gz*}
|
||||
if [ -d "$BACKUP_PATH" ];then
|
||||
rm -rf $BACKUP_PATH
|
||||
fi
|
||||
mkdir -p $BACKUP_PATH
|
||||
echo "unpack input file..."
|
||||
# fix tar path error
|
||||
tar -zxf ${BACKUP_PATH_FILE} -C /tmp/
|
||||
|
||||
echo "check file"
|
||||
if [ ! -f "${BACKUP_PATH}/appdep.list" ];then
|
||||
echo "no available appdep.list, can not restore ipk"
|
||||
exit 1
|
||||
fi
|
||||
echo "check success"
|
||||
|
||||
#2. install ipk by backup path
|
||||
echo "restore begin"
|
||||
for app in `cat ${BACKUP_PATH}/appdepipk.list`; do
|
||||
opkg_wrap install ${BACKUP_PATH}/${app}
|
||||
done
|
||||
|
||||
#3. rm dir
|
||||
rm -rf ${BACKUP_PATH}
|
||||
echo "restore success"
|
||||
}
|
||||
|
||||
get_support_backup_features() {
|
||||
echo "light_backup"
|
||||
#istore custom img mean support local_backup
|
||||
if [ -f /etc/istore_img_flag ];then
|
||||
echo "local_backup"
|
||||
fi
|
||||
}
|
||||
|
||||
get_backup_app_list_file_path() {
|
||||
echo "${APP_LIST_FILE}"
|
||||
}
|
||||
|
||||
get_backup_app_list() {
|
||||
if [ ! -f "${APP_LIST_FILE}" ];then
|
||||
echo "no app.list, can not get backup app list"
|
||||
exit 1
|
||||
fi
|
||||
cat ${APP_LIST_FILE}
|
||||
}
|
||||
|
||||
get_available_backup_file_list() {
|
||||
if [ -n "$1" ]; then
|
||||
for backup_file in `ls $1/*.backup.tar.gz`; do
|
||||
filename=${backup_file##*/}
|
||||
echo "${filename}"
|
||||
done
|
||||
else
|
||||
echo "input backup path is null"
|
||||
exit 1
|
||||
fi
|
||||
remove() {
|
||||
opkg_wrap --autoremove --force-removal-of-dependent-packages remove "$@"
|
||||
}
|
||||
|
||||
usage() {
|
||||
@ -382,12 +137,6 @@ usage() {
|
||||
echo " list-upgradable List installed and upgradable packages"
|
||||
echo " check_self_upgrade Check iStore upgrade"
|
||||
echo " do_self_upgrade Upgrade iStore"
|
||||
echo " backup [dir] Backup all installed package(s) to [directory]"
|
||||
echo " restore [dir] Restore package(s) by [directory]"
|
||||
echo " get_support_backup_features get device support backup features"
|
||||
echo " get_backup_app_list_file_path get light backup app list file path"
|
||||
echo " get_backup_app_list get light backup app list"
|
||||
echo " get_available_backup_file_list get local available backup file list"
|
||||
echo " opkg sys opkg wrap"
|
||||
}
|
||||
|
||||
@ -404,7 +153,7 @@ case $action in
|
||||
new_upgrade "$@"
|
||||
;;
|
||||
"remove")
|
||||
opkg_wrap --autoremove --force-removal-of-dependent-packages remove "$@"
|
||||
remove "$@" || remove "$@"
|
||||
;;
|
||||
"info")
|
||||
opkg_wrap info "$@"
|
||||
@ -418,24 +167,6 @@ case $action in
|
||||
"do_self_upgrade")
|
||||
do_self_upgrade
|
||||
;;
|
||||
"get_support_backup_features")
|
||||
get_support_backup_features
|
||||
;;
|
||||
"backup")
|
||||
backup "$@"
|
||||
;;
|
||||
"restore")
|
||||
restore "$@"
|
||||
;;
|
||||
"get_backup_app_list_file_path")
|
||||
get_backup_app_list_file_path
|
||||
;;
|
||||
"get_backup_app_list")
|
||||
get_backup_app_list
|
||||
;;
|
||||
"get_available_backup_file_list")
|
||||
get_available_backup_file_list "$@"
|
||||
;;
|
||||
"opkg")
|
||||
opkg_wrap "$@"
|
||||
;;
|
||||
|
295
luci-app-store/root/usr/libexec/istore/backup
Executable file
295
luci-app-store/root/usr/libexec/istore/backup
Executable file
@ -0,0 +1,295 @@
|
||||
#!/bin/sh
|
||||
#set -x
|
||||
#IS_DEBUG=1
|
||||
|
||||
IS_ROOT=/tmp/is-backup
|
||||
APP_LIST_FILE=/etc/istore/app.list
|
||||
BACKUP_CONFIG_FILE=/etc/config/istore
|
||||
|
||||
action=${1}
|
||||
shift
|
||||
|
||||
|
||||
is_init() {
|
||||
mkdir -p ${IS_ROOT}
|
||||
}
|
||||
|
||||
opkg_list_installed_packages() {
|
||||
target=$1
|
||||
case $target in
|
||||
"preinstalled")
|
||||
OPKG_INFO_DIR="/rom/usr/lib/opkg/info"
|
||||
;;
|
||||
"userinstalled")
|
||||
OPKG_INFO_DIR="/overlay/upper/usr/lib/opkg/info"
|
||||
;;
|
||||
"allinstalled")
|
||||
OPKG_INFO_DIR="/usr/lib/opkg/info"
|
||||
;;
|
||||
*)
|
||||
echo "invalid target"
|
||||
exit
|
||||
;;
|
||||
esac
|
||||
(cd $OPKG_INFO_DIR && find . -depth -maxdepth 1 -name "*.list" -type f | sed 's#^\./\(.*\)\.list$#\1#g')
|
||||
}
|
||||
|
||||
ipk_build() {
|
||||
PKG_NAME_TEMP=$1
|
||||
IPK_OUTPUT_DIR=$2
|
||||
|
||||
UCI_BAK_DIR="/etc/istore/uci-defaults_bak/"
|
||||
UCI_DEF_DIR="etc/uci-defaults"
|
||||
OPKG_INFO_DIR="/usr/lib/opkg/info/"
|
||||
|
||||
[ -n "${PKG_NAME_TEMP}" ] || exit 1
|
||||
#get real pkg name in opkg
|
||||
PKG_NAME_TEMP=`cat ${IS_ROOT}/all_installed_package.list | sort -u | grep "^${PKG_NAME_TEMP}" | head -n 1`
|
||||
[ -n "${PKG_NAME_TEMP}" ] || exit 1
|
||||
|
||||
PKG_NAME=`cat ${OPKG_INFO_DIR}${PKG_NAME_TEMP}.control | grep "^Package: " | cut -d ' ' -f2`
|
||||
PKG_VER=`cat ${OPKG_INFO_DIR}${PKG_NAME}.control | grep "^Version: " | cut -d ' ' -f2`
|
||||
PKG_ARCH=`cat ${OPKG_INFO_DIR}${PKG_NAME}.control | grep "^Architecture: " | cut -d ' ' -f2`
|
||||
IPK_FILE_NAME="${PKG_NAME}_${PKG_VER}_${PKG_ARCH}"
|
||||
|
||||
rm -rf ${IS_ROOT}/${IPK_FILE_NAME}
|
||||
mkdir -p ${IS_ROOT}/${IPK_FILE_NAME}
|
||||
|
||||
#(1)make CONTROL dir; (2)copy control file to dir
|
||||
cd ${IS_ROOT}/${IPK_FILE_NAME}
|
||||
mkdir -p CONTROL
|
||||
for control_file in `ls ${OPKG_INFO_DIR}${PKG_NAME}.* | grep -v ".list$"`; do
|
||||
file=${control_file##*/}
|
||||
suffix=${file##*.}
|
||||
cp ${control_file} CONTROL/${suffix}
|
||||
done
|
||||
|
||||
#(1)make DATA depend dir; (2)copy uci-defaults_bak file to dir; (3)copy other file to dir
|
||||
for pkgfile in `cat ${OPKG_INFO_DIR}${PKG_NAME}.list | cut -b 2-`; do
|
||||
file=${pkgfile##*/}
|
||||
path=${pkgfile%/*}
|
||||
mkdir -p ${path}
|
||||
if [ `echo "${path}" | grep "^${UCI_DEF_DIR}"` ]; then
|
||||
cp "${UCI_BAK_DIR}${file}" "${pkgfile}"
|
||||
else
|
||||
cp "/${pkgfile}" "${pkgfile}"
|
||||
fi
|
||||
done
|
||||
|
||||
#call ipkg-build script to build ipk
|
||||
/usr/libexec/istore/ipkg-build ${IS_ROOT}/${IPK_FILE_NAME} ${IPK_OUTPUT_DIR}
|
||||
echo "${IPK_FILE_NAME}.ipk" >> ${IPK_OUTPUT_DIR}/appdepipk.list
|
||||
|
||||
[ -n "${IS_DEBUG}" ] || rm -rf ${IS_ROOT}/${IPK_FILE_NAME}
|
||||
}
|
||||
|
||||
# if arg is NULL, use light backup, otherwise use local backup
|
||||
backup() {
|
||||
[ -n "$1" ] && BACKUP_PATH=$1
|
||||
|
||||
#1.add all istore self data to sysupgrade config file,
|
||||
#sysupgrade will backup/restore it auto when flash new firmware
|
||||
echo "/etc/.app_store.id" > /lib/upgrade/keep.d/luci-app-store
|
||||
cat /usr/lib/opkg/info/luci-app-store.list >> /lib/upgrade/keep.d/luci-app-store
|
||||
echo "/etc/rc.d/S45istore" >> /lib/upgrade/keep.d/luci-app-store
|
||||
echo "/etc/istore/uci-defaults_bak" >> /lib/upgrade/keep.d/luci-app-store
|
||||
echo "${APP_LIST_FILE}" >> /lib/upgrade/keep.d/luci-app-store
|
||||
echo "${BACKUP_CONFIG_FILE}" >> /lib/upgrade/keep.d/luci-app-store
|
||||
|
||||
#write user installed package list to file
|
||||
opkg_list_installed_packages "userinstalled" 2>/dev/null | sort -u > ${IS_ROOT}/user_installed_package.list
|
||||
|
||||
#write installed package list by istore feed to file
|
||||
cat ${IS_ROOT}/user_installed_package.list | \
|
||||
grep '^app-meta-' > ${IS_ROOT}/istore_installed_package.list
|
||||
|
||||
#if no input backup path, only back app.list
|
||||
mkdir -p /etc/istore
|
||||
cp ${IS_ROOT}/istore_installed_package.list ${APP_LIST_FILE}
|
||||
echo "backup installed package list to ${APP_LIST_FILE}"
|
||||
|
||||
if [ ! -n "${BACKUP_PATH}" ]; then
|
||||
echo "backup success"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ ! -d "${BACKUP_PATH}" ] && ! mkdir -p "${BACKUP_PATH}" ; then
|
||||
echo "invalid backup path, can not backup ipk"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#write all installed package list to file
|
||||
opkg_list_installed_packages "allinstalled" 2>/dev/null | sort -u > ${IS_ROOT}/all_installed_package.list
|
||||
|
||||
#write system pre installed package list to file
|
||||
opkg_list_installed_packages "preinstalled" 2>/dev/null | sort -u > ${IS_ROOT}/pre_installed_package.list
|
||||
|
||||
#write installed packages and depends list by istore feed to file by depend sequence
|
||||
appdep_list=""
|
||||
temp_list=`cat ${IS_ROOT}/istore_installed_package.list | sed 's/^/\t/'`
|
||||
while [ -n "${temp_list}" ]
|
||||
do
|
||||
#get real pkg name
|
||||
for PKG_NAME_TEMP in ${temp_list}; do
|
||||
REAL_PKG_NAME=`cat ${IS_ROOT}/all_installed_package.list | sort -u | grep "^${PKG_NAME_TEMP}" | head -n 1`
|
||||
if [ "${REAL_PKG_NAME}" != "${PKG_NAME_TEMP}" ]; then
|
||||
temp_list=`echo "${temp_list}" | sed 's/^\t'"${PKG_NAME_TEMP}"'$/\t'"${REAL_PKG_NAME}"'/'`
|
||||
fi
|
||||
done
|
||||
|
||||
appdep_list=`echo -e "${temp_list}\n${appdep_list}"`
|
||||
[ -n "${IS_DEBUG}" ] && echo -e "temp_list:\n""${temp_list}"
|
||||
[ -n "${IS_DEBUG}" ] && echo -e "appdep_list:\n""${appdep_list}"
|
||||
|
||||
temp_list=`echo "${temp_list}" | xargs opkg depends | grep -v "depends on:" | grep -v " (>= " | grep -v " (= " | sort -u`
|
||||
done
|
||||
|
||||
appdep_list_all=`echo "${appdep_list}" | cut -f2 | grep -v "^$" | awk '!seen[$0]++'`
|
||||
[ -n "${IS_DEBUG}" ] && echo -e "appdep_list_all:\n""${appdep_list_all}"
|
||||
echo "${appdep_list_all}" > ${IS_ROOT}/appdep.list
|
||||
|
||||
#3.rebuild all istore installed package to ipk and backup to userdata partation
|
||||
|
||||
# 4. create dir
|
||||
date=$(date +%Y-%m%d-%H%M)
|
||||
if [ ! -d "$BACKUP_PATH/backup_istore_$date" ];then
|
||||
mkdir $BACKUP_PATH/backup_istore_$date
|
||||
fi
|
||||
cp ${IS_ROOT}/istore_installed_package.list $BACKUP_PATH/backup_istore_$date/app.list
|
||||
cp ${IS_ROOT}/appdep.list $BACKUP_PATH/backup_istore_$date/appdep.list
|
||||
|
||||
#only backup non pre installed ipk
|
||||
cp ${IS_ROOT}/appdep.list ${IS_ROOT}/appdep_strip.list
|
||||
for pre_installed_pkg in `cat ${IS_ROOT}/appdep.list ${IS_ROOT}/pre_installed_package.list | sort -n | uniq -d`; do
|
||||
sed -i '/^'"$pre_installed_pkg"'$/d' ${IS_ROOT}/appdep_strip.list
|
||||
done
|
||||
|
||||
rm -f $BACKUP_PATH/backup_istore_$date/appdepipk.list
|
||||
echo "build ipk"
|
||||
for pkg_name in `cat ${IS_ROOT}/appdep_strip.list`; do
|
||||
ipk_build ${pkg_name} $BACKUP_PATH/backup_istore_$date
|
||||
done
|
||||
|
||||
# 5. create tar.gz file,and remove fir
|
||||
cd $BACKUP_PATH
|
||||
echo "write backup file to $BACKUP_PATH/backup_istore_$date.backup.tar.gz"
|
||||
tar -czf $BACKUP_PATH/backup_istore_$date.backup.tar.gz backup_istore_$date
|
||||
rm -rf $BACKUP_PATH/backup_istore_$date
|
||||
echo "backup success"
|
||||
}
|
||||
|
||||
# if arg is NULL, use light backup, otherwise use local backup
|
||||
restore() {
|
||||
if [ -n "$1" ]; then
|
||||
BACKUP_PATH_FILE=$1
|
||||
else
|
||||
echo "install package by ${APP_LIST_FILE}"
|
||||
is-opkg update
|
||||
for app in `cat ${APP_LIST_FILE}`; do
|
||||
#skip resotre istore self
|
||||
[ "A${app}" == "A""luci-app-store" ] && continue
|
||||
is-opkg install ${app}
|
||||
done
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ ! -f "${BACKUP_PATH_FILE}" ];then
|
||||
echo "invalid backup file, can not restore ipk"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#1. Unzip file to dir
|
||||
BACKUP_PATH_FILE_NAME=${BACKUP_PATH_FILE##*/}
|
||||
BACKUP_PATH=/tmp/${BACKUP_PATH_FILE_NAME%.backup.tar.gz*}
|
||||
if [ -d "$BACKUP_PATH" ];then
|
||||
rm -rf $BACKUP_PATH
|
||||
fi
|
||||
mkdir -p $BACKUP_PATH
|
||||
echo "unpack input file..."
|
||||
# fix tar path error
|
||||
tar -zxf ${BACKUP_PATH_FILE} -C /tmp/
|
||||
|
||||
echo "check file"
|
||||
if [ ! -f "${BACKUP_PATH}/appdep.list" ];then
|
||||
echo "no available appdep.list, can not restore ipk"
|
||||
exit 1
|
||||
fi
|
||||
echo "check success"
|
||||
|
||||
#2. install ipk by backup path
|
||||
echo "restore begin"
|
||||
( cd ${BACKUP_PATH}; opkg install `cat ${BACKUP_PATH}/appdepipk.list` )
|
||||
|
||||
#3. rm dir
|
||||
rm -rf ${BACKUP_PATH}
|
||||
echo "restore success"
|
||||
}
|
||||
|
||||
get_support_backup_features() {
|
||||
echo "light_backup"
|
||||
#istore custom img mean support local_backup
|
||||
if [ -f /etc/istore_img_flag ];then
|
||||
echo "local_backup"
|
||||
fi
|
||||
}
|
||||
|
||||
get_backup_app_list_file_path() {
|
||||
echo "${APP_LIST_FILE}"
|
||||
}
|
||||
|
||||
get_backup_app_list() {
|
||||
if [ ! -f "${APP_LIST_FILE}" ];then
|
||||
echo "no app.list, can not get backup app list"
|
||||
exit 1
|
||||
fi
|
||||
cat ${APP_LIST_FILE}
|
||||
}
|
||||
|
||||
get_available_backup_file_list() {
|
||||
if [ -n "$1" ]; then
|
||||
for backup_file in `ls $1/*.backup.tar.gz`; do
|
||||
filename=${backup_file##*/}
|
||||
echo "${filename}"
|
||||
done
|
||||
else
|
||||
echo "input backup path is null"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
usage() {
|
||||
echo "usage: backup sub-command [arguments...]"
|
||||
echo "where sub-command is one of:"
|
||||
echo " backup [dir] Backup all installed package(s) to [directory]"
|
||||
echo " restore [dir] Restore package(s) by [directory]"
|
||||
echo " get_support_backup_features get device support backup features"
|
||||
echo " get_backup_app_list_file_path get light backup app list file path"
|
||||
echo " get_backup_app_list get light backup app list"
|
||||
echo " get_available_backup_file_list get local available backup file list"
|
||||
}
|
||||
|
||||
is_init >/dev/null 2>&1
|
||||
|
||||
case $action in
|
||||
"get_support_backup_features")
|
||||
get_support_backup_features
|
||||
;;
|
||||
"backup")
|
||||
backup "$@"
|
||||
;;
|
||||
"restore")
|
||||
restore "$@"
|
||||
;;
|
||||
"get_backup_app_list_file_path")
|
||||
get_backup_app_list_file_path
|
||||
;;
|
||||
"get_backup_app_list")
|
||||
get_backup_app_list
|
||||
;;
|
||||
"get_available_backup_file_list")
|
||||
get_available_backup_file_list "$@"
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
;;
|
||||
esac
|
Loading…
Reference in New Issue
Block a user