diff --git a/luci-app-zapret/Makefile b/luci-app-zapret/Makefile index a77ea26..1a3a073 100644 --- a/luci-app-zapret/Makefile +++ b/luci-app-zapret/Makefile @@ -5,8 +5,9 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-zapret -PKG_VERSION:=69-20241118 +PKG_VERSION:=69.20241118 PKG_LICENSE:=MIT +PKG_MAINTAINER:=remittor LUCI_TITLE:=LuCI support for zapret LUCI_DEPENDS:=+zapret @@ -19,8 +20,8 @@ if [ -z "$${IPKG_INSTROOT}" ]; then rm -rf /tmp/luci-modulecache/ #killall -HUP rpcd 2>/dev/null /etc/init.d/rpcd reload - /sbin/luci-reload - /etc/init.d/uhttpd reload + [ -f "/sbin/luci-reload" ] && /sbin/luci-reload + [ -f "/etc/init.d/uhttpd" ] && /etc/init.d/uhttpd reload fi exit 0 endef diff --git a/luci-app-zapret/htdocs/luci-static/resources/view/zapret/service.js b/luci-app-zapret/htdocs/luci-static/resources/view/zapret/service.js index 8bd552e..7b2161f 100644 --- a/luci-app-zapret/htdocs/luci-static/resources/view/zapret/service.js +++ b/luci-app-zapret/htdocs/luci-static/resources/view/zapret/service.js @@ -47,7 +47,7 @@ return view.extend({ fs.exec(tools.execPath, [ 'enabled' ]), // svc_en fs.exec(tools.execPath, [ 'info' ]), // svc_info 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 ]).catch(e => { 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 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; if (svc_info.code != 0) { diff --git a/luci-app-zapret/htdocs/luci-static/resources/view/zapret/tools.js b/luci-app-zapret/htdocs/luci-static/resources/view/zapret/tools.js index 2d03d7f..274baee 100644 --- a/luci-app-zapret/htdocs/luci-static/resources/view/zapret/tools.js +++ b/luci-app-zapret/htdocs/luci-static/resources/view/zapret/tools.js @@ -35,6 +35,7 @@ document.head.append(E('style', {'type': 'text/css'}, `)); return baseclass.extend({ + packager : null, appName : 'zapret', execPath : '/etc/init.d/zapret', syncCfgPath : '/opt/zapret/sync_config.sh', @@ -82,7 +83,24 @@ return baseclass.extend({ 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) { + this.init_consts(); return this.callInitState(name).then(res => { if (res) { return res[name].enabled ? true : false; @@ -114,12 +132,33 @@ return baseclass.extend({ let lines = pkg_list.trim().split('\n'); for (let i = 0; i < lines.length; i++) { let line = lines[i].trim(); - if (line.length >= 4) { - let word_list = line.split(' - '); - let name = word_list[0].trim(); - let ver = word_list[1].trim(); - pkg_dict[name] = ver; + let name; + let ver; + if (this.packager.name == 'apk') { + let fullname = line.split(' ')[0]; + 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; }, diff --git a/luci-app-zapret/root/usr/share/rpcd/acl.d/luci-app-zapret.json b/luci-app-zapret/root/usr/share/rpcd/acl.d/luci-app-zapret.json index b6caa7b..71091b2 100644 --- a/luci-app-zapret/root/usr/share/rpcd/acl.d/luci-app-zapret.json +++ b/luci-app-zapret/root/usr/share/rpcd/acl.d/luci-app-zapret.json @@ -10,6 +10,7 @@ "/etc/init.d/zapret*": [ "exec" ], "/bin/ps*": [ "exec" ], "/bin/opkg*": [ "exec" ], + "/usr/bin/apk*": [ "exec" ], "/opt/zapret/restore-def-cfg.sh*": [ "exec" ], "/opt/zapret/sync_config.sh*": [ "exec" ] }, diff --git a/zapret-ip2net/Makefile b/zapret-ip2net/Makefile index d3faba5..2eebd63 100644 --- a/zapret-ip2net/Makefile +++ b/zapret-ip2net/Makefile @@ -1,7 +1,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=zapret-ip2net -PKG_VERSION:=69-20241118 +PKG_VERSION:=69.20241118 PKG_MAINTAINER:=bol-van PKG_LICENSE:=MIT diff --git a/zapret-mdig/Makefile b/zapret-mdig/Makefile index 598e64c..7f34033 100644 --- a/zapret-mdig/Makefile +++ b/zapret-mdig/Makefile @@ -1,7 +1,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=zapret-mdig -PKG_VERSION:=69-20241118 +PKG_VERSION:=69.20241118 PKG_MAINTAINER:=bol-van PKG_LICENSE:=MIT diff --git a/zapret-tpws/Makefile b/zapret-tpws/Makefile index 062df89..dc755e2 100644 --- a/zapret-tpws/Makefile +++ b/zapret-tpws/Makefile @@ -1,7 +1,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=zapret-tpws -PKG_VERSION:=69-20241118 +PKG_VERSION:=69.20241118 PKG_MAINTAINER:=bol-van PKG_LICENSE:=MIT diff --git a/zapret/Makefile b/zapret/Makefile index d7256a0..9f20a2a 100644 --- a/zapret/Makefile +++ b/zapret/Makefile @@ -5,7 +5,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=zapret -PKG_VERSION:=69-20241118 +PKG_VERSION:=69.20241118 PKG_MAINTAINER:=bol-van PKG_LICENSE:=MIT