mirror of
https://github.com/remittor/zapret-openwrt.git
synced 2025-12-15 16:06:50 +03:00
luci: Adapt code for APK support
This commit is contained in:
@@ -5,8 +5,9 @@
|
|||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=luci-app-zapret
|
PKG_NAME:=luci-app-zapret
|
||||||
PKG_VERSION:=69-20241118
|
PKG_VERSION:=69.20241118
|
||||||
PKG_LICENSE:=MIT
|
PKG_LICENSE:=MIT
|
||||||
|
PKG_MAINTAINER:=remittor <https://github.com/remittor>
|
||||||
|
|
||||||
LUCI_TITLE:=LuCI support for zapret
|
LUCI_TITLE:=LuCI support for zapret
|
||||||
LUCI_DEPENDS:=+zapret
|
LUCI_DEPENDS:=+zapret
|
||||||
@@ -19,8 +20,8 @@ if [ -z "$${IPKG_INSTROOT}" ]; then
|
|||||||
rm -rf /tmp/luci-modulecache/
|
rm -rf /tmp/luci-modulecache/
|
||||||
#killall -HUP rpcd 2>/dev/null
|
#killall -HUP rpcd 2>/dev/null
|
||||||
/etc/init.d/rpcd reload
|
/etc/init.d/rpcd reload
|
||||||
/sbin/luci-reload
|
[ -f "/sbin/luci-reload" ] && /sbin/luci-reload
|
||||||
/etc/init.d/uhttpd reload
|
[ -f "/etc/init.d/uhttpd" ] && /etc/init.d/uhttpd reload
|
||||||
fi
|
fi
|
||||||
exit 0
|
exit 0
|
||||||
endef
|
endef
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ return view.extend({
|
|||||||
fs.exec(tools.execPath, [ 'enabled' ]), // svc_en
|
fs.exec(tools.execPath, [ 'enabled' ]), // svc_en
|
||||||
fs.exec(tools.execPath, [ 'info' ]), // svc_info
|
fs.exec(tools.execPath, [ 'info' ]), // svc_info
|
||||||
fs.exec('/bin/ps'), // process list
|
fs.exec('/bin/ps'), // process list
|
||||||
fs.exec('/bin/opkg', [ 'list-installed', '*zapret*' ]), // installed packages
|
fs.exec(tools.packager.path, tools.packager.args), // installed packages
|
||||||
uci.load(tools.appName), // config
|
uci.load(tools.appName), // config
|
||||||
]).catch(e => {
|
]).catch(e => {
|
||||||
ui.addNotification(null, E('p', _('Unable to execute or read contents')
|
ui.addNotification(null, E('p', _('Unable to execute or read contents')
|
||||||
@@ -72,7 +72,7 @@ return view.extend({
|
|||||||
let proc_list = status_array[3]; // stdout: multiline text
|
let proc_list = status_array[3]; // stdout: multiline text
|
||||||
let pkg_list = status_array[4]; // stdout: installed packages
|
let pkg_list = status_array[4]; // stdout: installed packages
|
||||||
|
|
||||||
console.log('svc_en: ' + svc_en.code);
|
//console.log('svc_en: ' + svc_en.code);
|
||||||
svc_en = (svc_en.code == 0) ? true : false;
|
svc_en = (svc_en.code == 0) ? true : false;
|
||||||
|
|
||||||
if (svc_info.code != 0) {
|
if (svc_info.code != 0) {
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ document.head.append(E('style', {'type': 'text/css'},
|
|||||||
`));
|
`));
|
||||||
|
|
||||||
return baseclass.extend({
|
return baseclass.extend({
|
||||||
|
packager : null,
|
||||||
appName : 'zapret',
|
appName : 'zapret',
|
||||||
execPath : '/etc/init.d/zapret',
|
execPath : '/etc/init.d/zapret',
|
||||||
syncCfgPath : '/opt/zapret/sync_config.sh',
|
syncCfgPath : '/opt/zapret/sync_config.sh',
|
||||||
@@ -82,7 +83,24 @@ return baseclass.extend({
|
|||||||
expect: { result: false }
|
expect: { result: false }
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
init_consts: function() {
|
||||||
|
if (!this.packager) {
|
||||||
|
this.packager = { };
|
||||||
|
if (L.hasSystemFeature('apk')) {
|
||||||
|
this.packager.name = 'apk';
|
||||||
|
this.packager.path = '/usr/bin/apk';
|
||||||
|
this.packager.args = [ 'list', '-I', '*zapret*' ];
|
||||||
|
} else {
|
||||||
|
this.packager.name = 'opkg';
|
||||||
|
this.packager.path = '/bin/opkg';
|
||||||
|
this.packager.args = [ 'list-installed', '*zapret*' ];
|
||||||
|
}
|
||||||
|
//console.log('PACKAGER: ' + this.packager.name);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
getInitState: function(name) {
|
getInitState: function(name) {
|
||||||
|
this.init_consts();
|
||||||
return this.callInitState(name).then(res => {
|
return this.callInitState(name).then(res => {
|
||||||
if (res) {
|
if (res) {
|
||||||
return res[name].enabled ? true : false;
|
return res[name].enabled ? true : false;
|
||||||
@@ -114,12 +132,33 @@ return baseclass.extend({
|
|||||||
let lines = pkg_list.trim().split('\n');
|
let lines = pkg_list.trim().split('\n');
|
||||||
for (let i = 0; i < lines.length; i++) {
|
for (let i = 0; i < lines.length; i++) {
|
||||||
let line = lines[i].trim();
|
let line = lines[i].trim();
|
||||||
if (line.length >= 4) {
|
let name;
|
||||||
let word_list = line.split(' - ');
|
let ver;
|
||||||
let name = word_list[0].trim();
|
if (this.packager.name == 'apk') {
|
||||||
let ver = word_list[1].trim();
|
let fullname = line.split(' ')[0];
|
||||||
pkg_dict[name] = ver;
|
let mpos = fullname.lastIndexOf("-");
|
||||||
|
if (mpos <= 0)
|
||||||
|
continue;
|
||||||
|
if (fullname.substring(mpos+1, mpos+2) == 'r') {
|
||||||
|
// release number
|
||||||
|
fullname = fullname.substring(0, mpos);
|
||||||
|
}
|
||||||
|
mpos = fullname.lastIndexOf("-");
|
||||||
|
if (mpos <= 0)
|
||||||
|
continue;
|
||||||
|
name = fullname.substring(0, mpos).trim();
|
||||||
|
ver = fullname.substring(mpos+1).trim();
|
||||||
|
} else {
|
||||||
|
if (!line.includes(' - '))
|
||||||
|
continue;
|
||||||
|
name = line.split(' - ')[0].trim();
|
||||||
|
ver = line.split(' - ')[1].trim();
|
||||||
|
let spos = ver.indexOf(" ");
|
||||||
|
if (spos > 0) {
|
||||||
|
ver = ver.substring(0, spos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
pkg_dict[name] = ver;
|
||||||
}
|
}
|
||||||
return pkg_dict;
|
return pkg_dict;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
"/etc/init.d/zapret*": [ "exec" ],
|
"/etc/init.d/zapret*": [ "exec" ],
|
||||||
"/bin/ps*": [ "exec" ],
|
"/bin/ps*": [ "exec" ],
|
||||||
"/bin/opkg*": [ "exec" ],
|
"/bin/opkg*": [ "exec" ],
|
||||||
|
"/usr/bin/apk*": [ "exec" ],
|
||||||
"/opt/zapret/restore-def-cfg.sh*": [ "exec" ],
|
"/opt/zapret/restore-def-cfg.sh*": [ "exec" ],
|
||||||
"/opt/zapret/sync_config.sh*": [ "exec" ]
|
"/opt/zapret/sync_config.sh*": [ "exec" ]
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=zapret-ip2net
|
PKG_NAME:=zapret-ip2net
|
||||||
PKG_VERSION:=69-20241118
|
PKG_VERSION:=69.20241118
|
||||||
|
|
||||||
PKG_MAINTAINER:=bol-van
|
PKG_MAINTAINER:=bol-van
|
||||||
PKG_LICENSE:=MIT
|
PKG_LICENSE:=MIT
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=zapret-mdig
|
PKG_NAME:=zapret-mdig
|
||||||
PKG_VERSION:=69-20241118
|
PKG_VERSION:=69.20241118
|
||||||
|
|
||||||
PKG_MAINTAINER:=bol-van
|
PKG_MAINTAINER:=bol-van
|
||||||
PKG_LICENSE:=MIT
|
PKG_LICENSE:=MIT
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=zapret-tpws
|
PKG_NAME:=zapret-tpws
|
||||||
PKG_VERSION:=69-20241118
|
PKG_VERSION:=69.20241118
|
||||||
|
|
||||||
PKG_MAINTAINER:=bol-van
|
PKG_MAINTAINER:=bol-van
|
||||||
PKG_LICENSE:=MIT
|
PKG_LICENSE:=MIT
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=zapret
|
PKG_NAME:=zapret
|
||||||
PKG_VERSION:=69-20241118
|
PKG_VERSION:=69.20241118
|
||||||
|
|
||||||
PKG_MAINTAINER:=bol-van
|
PKG_MAINTAINER:=bol-van
|
||||||
PKG_LICENSE:=MIT
|
PKG_LICENSE:=MIT
|
||||||
|
|||||||
Reference in New Issue
Block a user