mirror of
https://github.com/caiwx86/small-packages.git
synced 2026-08-03 13:29:24 +08:00
update 2026-06-16 17:21:41
This commit is contained in:
parent
19b8fe19fc
commit
0bae71881b
@ -2,8 +2,8 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
import { access, popen, readfile } from 'fs';
|
||||
import { get_paths, merge_exists, get_users, get_groups, get_cgroups, load_profile, save_profile } from '/etc/momo/ucode/include.uc';
|
||||
import { popen } from 'fs';
|
||||
import { get_paths, merge_exists, get_users, get_groups, get_cgroups, load_profile } from '/etc/momo/ucode/include.uc';
|
||||
|
||||
const methods = {
|
||||
get_paths: {
|
||||
|
||||
@ -19,6 +19,12 @@ const callRCInit = rpc.declare({
|
||||
expect: { '': {} }
|
||||
});
|
||||
|
||||
const callFileWrite = rpc.declare({
|
||||
object: 'file',
|
||||
method: 'write',
|
||||
params: ['path', 'data', 'append', 'mode']
|
||||
});
|
||||
|
||||
const callNikkiVersion = rpc.declare({
|
||||
object: 'luci.nikki',
|
||||
method: 'version',
|
||||
@ -98,6 +104,31 @@ return baseclass.extend({
|
||||
return callRCInit('nikki', 'restart');
|
||||
},
|
||||
|
||||
writefile: function (path, data, mode) {
|
||||
data = (data != null) ? String(data) : '';
|
||||
mode = (mode != null) ? mode : 0o644;
|
||||
|
||||
const encoder = new TextEncoder();
|
||||
const decoder = new TextDecoder();
|
||||
const chunkSize = 8 * 1024;
|
||||
|
||||
const bytes = encoder.encode(data);
|
||||
|
||||
if (bytes.length <= chunkSize) {
|
||||
return callFileWrite(path, data, false, mode);
|
||||
}
|
||||
|
||||
let promise = Promise.resolve();
|
||||
for(let offset = 0; offset < bytes.length; offset += chunkSize) {
|
||||
const chunkBytes = bytes.slice(offset, Math.min(offset + chunkSize, bytes.length));
|
||||
const chunk = decoder.decode(chunkBytes);
|
||||
const append = offset > 0;
|
||||
promise = promise.then(() => callFileWrite(path, chunk, append, mode));
|
||||
}
|
||||
|
||||
return promise;
|
||||
},
|
||||
|
||||
version: function () {
|
||||
return callNikkiVersion();
|
||||
},
|
||||
@ -183,11 +214,11 @@ return baseclass.extend({
|
||||
},
|
||||
|
||||
clearAppLog: function () {
|
||||
return fs.write(this.appLogPath);
|
||||
return this.writefile(this.appLogPath, '');
|
||||
},
|
||||
|
||||
clearCoreLog: function () {
|
||||
return fs.write(this.coreLogPath);
|
||||
return this.writefile(this.coreLogPath, '');
|
||||
},
|
||||
|
||||
debug: function () {
|
||||
|
||||
@ -62,11 +62,11 @@ return view.extend({
|
||||
o.wrap = false;
|
||||
o.write = function (section_id, formvalue) {
|
||||
const path = m.lookupOption('_file', section_id)[0].formvalue(section_id);
|
||||
return fs.write(path, formvalue);
|
||||
return nikki.writefile(path, formvalue);
|
||||
};
|
||||
o.remove = function (section_id) {
|
||||
const path = m.lookupOption('_file', section_id)[0].formvalue(section_id);
|
||||
return fs.write(path);
|
||||
return nikki.writefile(path);
|
||||
};
|
||||
|
||||
return m.render();
|
||||
|
||||
@ -7,11 +7,11 @@ 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-lib-ipkg +tar +libuci-lua +mount-utils +luci-lib-taskd
|
||||
LUCI_DEPENDS:=+curl +opkg +tar +libuci-lua +mount-utils +luci-lib-taskd
|
||||
LUCI_EXTRA_DEPENDS:=luci-lib-taskd (>=1.0.19)
|
||||
LUCI_PKGARCH:=all
|
||||
|
||||
PKG_VERSION:=0.1.32-1
|
||||
PKG_VERSION:=0.1.34-1
|
||||
# PKG_RELEASE MUST be empty for luci.mk
|
||||
PKG_RELEASE:=
|
||||
|
||||
|
||||
@ -254,10 +254,8 @@ local function get_installed_and_cache()
|
||||
local metadir = "/usr/lib/opkg/meta"
|
||||
local cachedir = "/tmp/cache/istore"
|
||||
local cachefile = cachedir .. "/installed.json"
|
||||
local metapkgpre = "app-meta-"
|
||||
local nixio = require "nixio"
|
||||
local fs = require "nixio.fs"
|
||||
local ipkg = require "luci.model.ipkg"
|
||||
local jsonc = require "luci.jsonc"
|
||||
local result = {}
|
||||
local lock, msg = flock("/var/lock/istore-installed.lock", "lock")
|
||||
@ -274,7 +272,8 @@ local function get_installed_and_cache()
|
||||
local pkg
|
||||
for pkg in itr do
|
||||
if pkg:match("^.*%.json$") then
|
||||
local metadata = fs.readfile(metadir .. "/" .. pkg)
|
||||
local metafile = metadir .. "/" .. pkg
|
||||
local metadata = fs.readfile(metafile)
|
||||
if metadata ~= nil then
|
||||
local meta = jsonc.parse(metadata)
|
||||
if meta == nil then
|
||||
@ -291,15 +290,10 @@ local function get_installed_and_cache()
|
||||
}
|
||||
end
|
||||
local time = nil
|
||||
local metapkg = metapkgpre .. meta.name
|
||||
local status = ipkg.status(metapkg)
|
||||
if next(status) ~= nil then
|
||||
time = status[metapkg]["Installed-Time"]
|
||||
local istat = fs.stat(metafile)
|
||||
if istat ~= nil then
|
||||
time = istat["mtime"]
|
||||
else
|
||||
local istat = fs.stat("/usr/lib/opkg/info/" .. metapkg .. ".list")
|
||||
if istat ~= nil then
|
||||
time = istat["mtime"]
|
||||
end
|
||||
cacheable = false
|
||||
end
|
||||
if time ~= nil then
|
||||
@ -313,7 +307,7 @@ local function get_installed_and_cache()
|
||||
result = data
|
||||
if cacheable then
|
||||
fs.mkdirr(cachedir)
|
||||
local oflags = nixio.open_flags("rdwr", "creat")
|
||||
local oflags = nixio.open_flags("wronly", "creat", "trunc")
|
||||
local mfile, code, msg = nixio.open(cachefile, oflags)
|
||||
mfile:writeall(jsonc.stringify(result))
|
||||
mfile:close()
|
||||
@ -331,7 +325,6 @@ function store_action(param)
|
||||
local metapkgpre = "app-meta-"
|
||||
local code, out, err, ret
|
||||
local fs = require "nixio.fs"
|
||||
local ipkg = require "luci.model.ipkg"
|
||||
local jsonc = require "luci.jsonc"
|
||||
local json_parse = jsonc.parse
|
||||
local action = param.action or ""
|
||||
@ -342,18 +335,22 @@ function store_action(param)
|
||||
luci.http.status(400, "Bad Request")
|
||||
return
|
||||
end
|
||||
local metapkg = metapkgpre .. pkg
|
||||
local meta = {}
|
||||
local metadata = fs.readfile(metadir .. "/" .. pkg .. ".json")
|
||||
local metafile = metadir .. "/" .. pkg .. ".json"
|
||||
local metadata = fs.readfile(metafile)
|
||||
|
||||
if metadata ~= nil then
|
||||
meta = json_parse(metadata) or {}
|
||||
end
|
||||
meta.installed = false
|
||||
local status = ipkg.status(metapkg)
|
||||
if next(status) ~= nil then
|
||||
local time = nil
|
||||
local istat = fs.stat(metafile)
|
||||
if istat ~= nil then
|
||||
time = istat["mtime"]
|
||||
end
|
||||
if time ~= nil then
|
||||
meta.installed=true
|
||||
meta.time=tonumber(status[metapkg]["Installed-Time"])
|
||||
meta.time=tonumber(time)
|
||||
end
|
||||
|
||||
ret = meta
|
||||
@ -571,7 +568,7 @@ function entrysh()
|
||||
errors[#errors+1] = {app=meta.name, code=500, msg="json parse failed: " .. o}
|
||||
else
|
||||
results[#results+1] = status
|
||||
local oflags = nixio.open_flags("rdwr", "creat")
|
||||
local oflags = nixio.open_flags("wronly", "creat", "trunc")
|
||||
local mfile, code, msg = nixio.open(cachefile, oflags)
|
||||
mfile:writeall(jsonc.stringify(status))
|
||||
mfile:close()
|
||||
|
||||
@ -160,6 +160,16 @@ wrapped_in_update() {
|
||||
eval "$@"
|
||||
}
|
||||
|
||||
refresh_installed() {
|
||||
local pkg
|
||||
for pkg in $@; do
|
||||
[[ $pkg == app-meta-* ]] || continue
|
||||
pkg="/usr/lib/opkg/meta/${pkg#app-meta-}.json"
|
||||
[[ -f "$pkg" ]] && touch "$pkg"
|
||||
done
|
||||
return 0
|
||||
}
|
||||
|
||||
step_upgrade() {
|
||||
local pkg
|
||||
local pkgs=""
|
||||
@ -176,6 +186,7 @@ step_upgrade() {
|
||||
fi
|
||||
if [ -n "$metapkg" ]; then
|
||||
opkg_wrap_mirrors upgrade $metapkg || return 1
|
||||
refresh_installed $metapkg
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
@ -352,7 +363,7 @@ case $action in
|
||||
;;
|
||||
"install")
|
||||
check_space
|
||||
wrapped_in_update opkg_wrap_mirrors install "$@" && try_upgrade_depends "$1" && try_autoconf
|
||||
wrapped_in_update opkg_wrap_mirrors install "$@" && refresh_installed "$1" && try_upgrade_depends "$1" && try_autoconf
|
||||
;;
|
||||
"autoconf")
|
||||
try_autoconf
|
||||
|
||||
@ -26,9 +26,9 @@ FIREWALL_INCLUDE_SH="$SH_DIR/firewall_include.sh"
|
||||
DEBUG_SH="$SH_DIR/debug.sh"
|
||||
|
||||
## firewall
|
||||
NFT_DIR="$HOME_DIR/firewall"
|
||||
GEOIP_CN_NFT="$NFT_DIR/geoip_cn.nft"
|
||||
GEOIP6_CN_NFT="$NFT_DIR/geoip6_cn.nft"
|
||||
FIREWALL_DIR="$HOME_DIR/firewall"
|
||||
GEOIP_CN_NFT="$FIREWALL_DIR/geoip_cn.nft"
|
||||
GEOIP6_CN_NFT="$FIREWALL_DIR/geoip6_cn.nft"
|
||||
|
||||
## log
|
||||
LOG_DIR="/var/log/momo"
|
||||
@ -63,7 +63,7 @@ get_paths() {
|
||||
json_add_string firewall_include_sh "$FIREWALL_INCLUDE_SH"
|
||||
json_add_string debug_sh "$DEBUG_SH"
|
||||
|
||||
json_add_string nft_dir "$NFT_DIR"
|
||||
json_add_string firewall_dir "$FIREWALL_DIR"
|
||||
json_add_string geoip_cn_nft "$GEOIP_CN_NFT"
|
||||
json_add_string geoip6_cn_nft "$GEOIP6_CN_NFT"
|
||||
|
||||
|
||||
@ -6,12 +6,10 @@
|
||||
import { readfile } from 'fs';
|
||||
import { cursor } from 'uci';
|
||||
import { connect } from 'ubus';
|
||||
import { get_paths, uci_bool, uci_array, get_cgroups_version, get_users, get_groups, get_cgroups } from '/etc/momo/ucode/include.uc';
|
||||
import { uci_bool, uci_array, get_cgroups_version, get_users, get_groups, get_cgroups, load_profile } from '/etc/momo/ucode/include.uc';
|
||||
|
||||
const fw4 = require('fw4');
|
||||
|
||||
const paths = get_paths();
|
||||
|
||||
const cgroups_version = get_cgroups_version();
|
||||
|
||||
const users = get_users();
|
||||
@ -21,7 +19,7 @@
|
||||
const uci = cursor();
|
||||
const ubus = connect();
|
||||
|
||||
const profile = json(readfile(paths.run_profile_path));
|
||||
const profile = load_profile();
|
||||
|
||||
uci.load('momo');
|
||||
|
||||
|
||||
@ -7,12 +7,12 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=qbittorrent
|
||||
PKG_VERSION:=5.2.1
|
||||
PKG_VERSION:=5.2.2
|
||||
PKG_RELEASE=1
|
||||
|
||||
PKG_SOURCE:=qBittorrent-release-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=https://codeload.github.com/qbittorrent/qBittorrent/tar.gz/release-$(PKG_VERSION)?
|
||||
PKG_HASH:=6288bfeeca1931ff1e1ca04d0e5f872e0d0b9d5df583ed41289cb9275ccac208
|
||||
PKG_HASH:=177efdadcd66fa66c473e97ee8ed117ce33ccb9a0a25a0716b62245ce506d1d7
|
||||
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/qBittorrent-release-$(PKG_VERSION)
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user