diff --git a/README.md b/README.md index e56c3d9..b5c978e 100644 --- a/README.md +++ b/README.md @@ -15,22 +15,22 @@ Internet-detector is an application for checking the availability of the Interne ## Installation notes (OpenWrt >= 21.02) opkg update - wget --no-check-certificate -O /tmp/internet-detector_1.4.2-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/internet-detector_1.4.2-r1_all.ipk - opkg install /tmp/internet-detector_1.4.2-r1_all.ipk - rm /tmp/internet-detector_1.4.2-r1_all.ipk - /etc/init.d/internet-detector start - /etc/init.d/internet-detector enable + wget --no-check-certificate -O /tmp/internet-detector_1.4.3-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/internet-detector_1.4.3-r1_all.ipk + opkg install /tmp/internet-detector_1.4.3-r1_all.ipk + rm /tmp/internet-detector_1.4.3-r1_all.ipk + service internet-detector start + service internet-detector enable - wget --no-check-certificate -O /tmp/luci-app-internet-detector_1.4.2-r2_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/luci-app-internet-detector_1.4.2-r2_all.ipk - opkg install /tmp/luci-app-internet-detector_1.4.2-r2_all.ipk - rm /tmp/luci-app-internet-detector_1.4.2-r2_all.ipk - /etc/init.d/rpcd restart + wget --no-check-certificate -O /tmp/luci-app-internet-detector_1.4.3-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/luci-app-internet-detector_1.4.3-r1_all.ipk + opkg install /tmp/luci-app-internet-detector_1.4.3-r1_all.ipk + rm /tmp/luci-app-internet-detector_1.4.3-r1_all.ipk + service rpcd restart i18n-ru: - wget --no-check-certificate -O /tmp/luci-i18n-internet-detector-ru_1.4.2-r2_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/luci-i18n-internet-detector-ru_1.4.2-r2_all.ipk - opkg install /tmp/luci-i18n-internet-detector-ru_1.4.2-r2_all.ipk - rm /tmp/luci-i18n-internet-detector-ru_1.4.2-r2_all.ipk + wget --no-check-certificate -O /tmp/luci-i18n-internet-detector-ru_1.4.3-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/luci-i18n-internet-detector-ru_1.4.3-r1_all.ipk + opkg install /tmp/luci-i18n-internet-detector-ru_1.4.3-r1_all.ipk + rm /tmp/luci-i18n-internet-detector-ru_1.4.3-r1_all.ipk ## Screenshots: @@ -42,10 +42,10 @@ i18n-ru: **Dependences:** modemmanager. - wget --no-check-certificate -O /tmp/internet-detector-mod-modem-restart_1.4.2-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/internet-detector-mod-modem-restart_1.4.2-r1_all.ipk - opkg install /tmp/internet-detector-mod-modem-restart_1.4.2-r1_all.ipk - rm /tmp/internet-detector-mod-modem-restart_1.4.2-r1_all.ipk - /etc/init.d/internet-detector restart + wget --no-check-certificate -O /tmp/internet-detector-mod-modem-restart_1.4.3-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/internet-detector-mod-modem-restart_1.4.3-r1_all.ipk + opkg install /tmp/internet-detector-mod-modem-restart_1.4.3-r1_all.ipk + rm /tmp/internet-detector-mod-modem-restart_1.4.3-r1_all.ipk + service internet-detector restart ![](https://github.com/gSpotx2f/luci-app-internet-detector/blob/master/screenshots/04.jpg) @@ -53,9 +53,9 @@ i18n-ru: **Dependences:** mailsend. - wget --no-check-certificate -O /tmp/internet-detector-mod-email_1.4.2-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/internet-detector-mod-email_1.4.2-r1_all.ipk - opkg install /tmp/internet-detector-mod-email_1.4.2-r1_all.ipk - rm /tmp/internet-detector-mod-email_1.4.2-r1_all.ipk - /etc/init.d/internet-detector restart + wget --no-check-certificate -O /tmp/internet-detector-mod-email_1.4.3-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/internet-detector-mod-email_1.4.3-r1_all.ipk + opkg install /tmp/internet-detector-mod-email_1.4.3-r1_all.ipk + rm /tmp/internet-detector-mod-email_1.4.3-r1_all.ipk + service internet-detector restart ![](https://github.com/gSpotx2f/luci-app-internet-detector/blob/master/screenshots/05.jpg) diff --git a/internet-detector-mod-email/Makefile b/internet-detector-mod-email/Makefile index 7d045d0..af889ef 100644 --- a/internet-detector-mod-email/Makefile +++ b/internet-detector-mod-email/Makefile @@ -1,11 +1,11 @@ # -# (с) 2024 gSpot (https://github.com/gSpotx2f/luci-app-internet-detector) +# (с) 2025 gSpot (https://github.com/gSpotx2f/luci-app-internet-detector) # include $(TOPDIR)/rules.mk PKG_NAME:=internet-detector-mod-email -PKG_VERSION:=1.4.2 +PKG_VERSION:=1.4.3 PKG_RELEASE:=1 PKG_MAINTAINER:=gSpot diff --git a/internet-detector-mod-email/files/usr/lib/lua/internet-detector/mod_email.lua b/internet-detector-mod-email/files/usr/lib/lua/internet-detector/mod_email.lua index f924c55..0a7336c 100644 --- a/internet-detector-mod-email/files/usr/lib/lua/internet-detector/mod_email.lua +++ b/internet-detector-mod-email/files/usr/lib/lua/internet-detector/mod_email.lua @@ -142,7 +142,7 @@ function Module:sendMessage(msg, textPattern) end end -function Module:run(currentStatus, lastStatus, timeDiff, timeNow) +function Module:run(currentStatus, lastStatus, timeDiff, timeNow, inetChecked) if not self._enabled then return end diff --git a/internet-detector-mod-modem-restart/Makefile b/internet-detector-mod-modem-restart/Makefile index 9c52c1a..3facca5 100644 --- a/internet-detector-mod-modem-restart/Makefile +++ b/internet-detector-mod-modem-restart/Makefile @@ -1,11 +1,11 @@ # -# (с) 2024 gSpot (https://github.com/gSpotx2f/luci-app-internet-detector) +# (с) 2025 gSpot (https://github.com/gSpotx2f/luci-app-internet-detector) # include $(TOPDIR)/rules.mk PKG_NAME:=internet-detector-mod-modem-restart -PKG_VERSION:=1.4.2 +PKG_VERSION:=1.4.3 PKG_RELEASE:=1 PKG_MAINTAINER:=gSpot diff --git a/internet-detector-mod-modem-restart/files/usr/lib/lua/internet-detector/mod_modem_restart.lua b/internet-detector-mod-modem-restart/files/usr/lib/lua/internet-detector/mod_modem_restart.lua index 11e328d..d264079 100644 --- a/internet-detector-mod-modem-restart/files/usr/lib/lua/internet-detector/mod_modem_restart.lua +++ b/internet-detector-mod-modem-restart/files/usr/lib/lua/internet-detector/mod_modem_restart.lua @@ -80,7 +80,7 @@ function Module:init(t) end end -function Module:run(currentStatus, lastStatus, timeDiff, timeNow) +function Module:run(currentStatus, lastStatus, timeDiff, timeNow, inetChecked) if not self._enabled then return end diff --git a/internet-detector/Makefile b/internet-detector/Makefile index 287d29b..505a567 100644 --- a/internet-detector/Makefile +++ b/internet-detector/Makefile @@ -1,11 +1,11 @@ # -# (с) 2024 gSpot (https://github.com/gSpotx2f/luci-app-internet-detector) +# (с) 2025 gSpot (https://github.com/gSpotx2f/luci-app-internet-detector) # include $(TOPDIR)/rules.mk PKG_NAME:=internet-detector -PKG_VERSION:=1.4.2 +PKG_VERSION:=1.4.3 PKG_RELEASE:=1 PKG_MAINTAINER:=gSpot diff --git a/internet-detector/files/usr/bin/internet-detector b/internet-detector/files/usr/bin/internet-detector index c3ec1b9..15a4523 100755 --- a/internet-detector/files/usr/bin/internet-detector +++ b/internet-detector/files/usr/bin/internet-detector @@ -8,7 +8,7 @@ luaposix libuci-lua - (с) 2024 gSpot (https://github.com/gSpotx2f/luci-app-internet-detector) + (с) 2025 gSpot (https://github.com/gSpotx2f/luci-app-internet-detector) --]] local getopt = require("posix.unistd").getopt diff --git a/internet-detector/files/usr/lib/lua/internet-detector/main.lua b/internet-detector/files/usr/lib/lua/internet-detector/main.lua index fc0f33c..2f0d93d 100644 --- a/internet-detector/files/usr/lib/lua/internet-detector/main.lua +++ b/internet-detector/files/usr/lib/lua/internet-detector/main.lua @@ -268,7 +268,6 @@ function InternetDetector:TCPConnectionToHost(host, port) io.stdout:write(string.format( "SOCKET ERROR: %s, %s\n", errMsg, errNum)) end - unistd.close(sock) return retCode end @@ -349,10 +348,12 @@ function InternetDetector:mainLoop() signal.signal(signal.SIGUSR1, function(signo) self:resetUiCounter(signo) end) local lastStatus, currentStatus, mTimeNow, mTimeDiff, mLastTime, uiTimeNow, uiLastTime - local interval = self.serviceConfig.interval_up - local counter = 0 - local onStart = true - _RUNNING = true + local interval = self.serviceConfig.interval_up + local modulesStatus = {} + local counter = 0 + local onStart = true + local inetChecked = false + _RUNNING = true while _RUNNING do if counter == 0 or counter >= interval then currentStatus = self:checkHosts() @@ -377,11 +378,11 @@ function InternetDetector:mainLoop() self:writeLogMessage("notice", "Disconnected") end end - counter = 0 end - mTimeDiff = 0 + mTimeDiff = 0 + inetChecked = (counter == 0) for _, e in ipairs(self.modules) do mTimeNow = time.clock_gettime(time.CLOCK_MONOTONIC).tv_sec if mLastTime then @@ -390,16 +391,17 @@ function InternetDetector:mainLoop() mTimeDiff = 1 end mLastTime = mTimeNow - e:run(currentStatus, lastStatus, mTimeDiff, mTimeNow) + e:run(currentStatus, lastStatus, mTimeDiff, mTimeNow, inetChecked) end - local modulesStatus = {} + local modStatusChanged = false for k, v in ipairs(self.modules) do - if v.status ~= nil then + if modulesStatus[v.name] ~= v.status then modulesStatus[v.name] = v.status + modStatusChanged = true end end - if next(modulesStatus) then + if modStatusChanged and next(modulesStatus) then self:writeValueToFile(self.statusFile, self:statusJson( currentStatus, self.serviceConfig.instance, modulesStatus)) end diff --git a/internet-detector/files/usr/lib/lua/internet-detector/mod_led_control.lua b/internet-detector/files/usr/lib/lua/internet-detector/mod_led_control.lua index d4578c8..88454d8 100644 --- a/internet-detector/files/usr/lib/lua/internet-detector/mod_led_control.lua +++ b/internet-detector/files/usr/lib/lua/internet-detector/mod_led_control.lua @@ -140,7 +140,7 @@ function Module:ledRunFunc(t, currentStatus) end end -function Module:run(currentStatus, lastStatus, timeDiff, timeNow) +function Module:run(currentStatus, lastStatus, timeDiff, timeNow, inetChecked) if not self._enabled then return end diff --git a/internet-detector/files/usr/lib/lua/internet-detector/mod_network_restart.lua b/internet-detector/files/usr/lib/lua/internet-detector/mod_network_restart.lua index 1550709..4c1c332 100644 --- a/internet-detector/files/usr/lib/lua/internet-detector/mod_network_restart.lua +++ b/internet-detector/files/usr/lib/lua/internet-detector/mod_network_restart.lua @@ -10,63 +10,68 @@ local Module = { readValue = function(filePath) return nil end, deadPeriod = 900, attempts = 1, - iface = nil, restartTimeout = 0, status = nil, _attemptsCounter = 0, _deadCounter = 0, + _networkRestarted = false, _ifaceRestarting = false, _ifaceRestartCounter = 0, + _netIfaces = {}, + _netDevices = {}, + _netItemsNum = 0, } -function Module:toggleFunc(flag) - return -end - -function Module:toggleDevice(flag) - if not self.iface then +function Module:toggleDevices(flag) + if #self._netDevices == 0 then return end local ip = "/sbin/ip" if unistd.access(ip, "x") then - return os.execute(string.format( - "%s link set dev %s %s", ip, self.iface, (flag and "up" or "down")) - ) + for _, v in ipairs(self._netDevices) do + os.execute(string.format("%s link set dev %s %s", ip, v, (flag and "up" or "down"))) + end end end -function Module:toggleIface(flag) - if not self.iface then +function Module:toggleIfaces(flag) + if #self._netIfaces == 0 then return end - return os.execute( - string.format("%s %s", (flag and "/sbin/ifup" or "/sbin/ifdown"), self.iface) - ) + for _, v in ipairs(self._netIfaces) do + os.execute(string.format("%s %s", (flag and "/sbin/ifup" or "/sbin/ifdown"), v)) + end end -function Module:ifaceUp() - self:toggleFunc(true) +function Module:netItemsUp() + self:toggleDevices(true) + self:toggleIfaces(true) end -function Module:ifaceDown() - self:toggleFunc(false) +function Module:netItemsDown() + self:toggleIfaces(false) + self:toggleDevices(false) end -function Module:networkRestart() +function Module:restartNetworkService() return os.execute("/etc/init.d/network restart") end function Module:init(t) - local iface = t.iface - if iface then - self.iface = iface - if self.iface:match("^@") then - self.iface = self.iface:gsub("^@", "") - self.toggleFunc = self.toggleIface - else - self.toggleFunc = self.toggleDevice + if t.ifaces ~= nil and type(t.ifaces) == "table" then + self._netIfaces = {} + self._netDevices = {} + self._netItemsNum = 0 + for k, v in ipairs(t.ifaces) do + if v:match("^@") then + self._netIfaces[#self._netIfaces + 1] = v:gsub("^@", "") + else + self._netDevices[#self._netDevices + 1] = v + end + self._netItemsNum = self._netItemsNum + 1 end end + if t.attempts ~= nil then self.attempts = tonumber(t.attempts) end @@ -79,10 +84,34 @@ function Module:init(t) self._attemptsCounter = self.attempts end -function Module:run(currentStatus, lastStatus, timeDiff, timeNow) +function Module:networkRestartFunc() + if self._netItemsNum > 0 then + if #self._netIfaces > 0 then + self.syslog("info", string.format("%s: restarting interfaces: %s", + self.name, table.concat(self._netIfaces, ", "))) + end + if #self._netDevices > 0 then + self.syslog("info", string.format("%s: restarting devices: %s", + self.name, table.concat(self._netDevices, ", "))) + end + self:netItemsDown() + if self.restartTimeout < 1 then + self:netItemsUp() + else + self._ifaceRestarting = true + end + else + self.syslog("info", string.format( + "%s: restarting network", self.name)) + self:restartNetworkService() + end + self._attemptsCounter = self._attemptsCounter + 1 +end + +function Module:run(currentStatus, lastStatus, timeDiff, timeNow, inetChecked) if self._ifaceRestarting then if self._ifaceRestartCounter >= self.restartTimeout then - self:ifaceUp() + self:netItemsUp() self._ifaceRestarting = false self._ifaceRestartCounter = 0 else @@ -90,31 +119,23 @@ function Module:run(currentStatus, lastStatus, timeDiff, timeNow) end else if currentStatus == 1 then - if self._attemptsCounter < self.attempts then - if self._deadCounter >= self.deadPeriod then - if self.iface then - self.syslog("info", string.format( - "%s: restarting network interface '%s'", self.name, self.iface)) - self:ifaceDown() - if self.restartTimeout < 1 then - self:ifaceUp() - else - self._ifaceRestarting = true - end + if not self._networkRestarted then + if self._attemptsCounter < self.attempts then + if self._deadCounter >= self.deadPeriod then + self:networkRestartFunc() + self._networkRestarted = true + self._deadCounter = 0 else - self.syslog("info", string.format( - "%s: restarting network", self.name)) - self:networkRestart() + self._deadCounter = self._deadCounter + timeDiff end - self._deadCounter = 0 - self._attemptsCounter = self._attemptsCounter + 1 - else - self._deadCounter = self._deadCounter + timeDiff end + elseif inetChecked and self._attemptsCounter < self.attempts then + self:networkRestartFunc() end else - self._attemptsCounter = 0 - self._deadCounter = 0 + self._attemptsCounter = 0 + self._deadCounter = 0 + self._networkRestarted = false end self._ifaceRestartCounter = 0 end diff --git a/internet-detector/files/usr/lib/lua/internet-detector/mod_public_ip.lua b/internet-detector/files/usr/lib/lua/internet-detector/mod_public_ip.lua index 9d408bb..a62d0c0 100644 --- a/internet-detector/files/usr/lib/lua/internet-detector/mod_public_ip.lua +++ b/internet-detector/files/usr/lib/lua/internet-detector/mod_public_ip.lua @@ -256,7 +256,6 @@ function Module:decodeMessage(message) if numAnswers > 0 then for answerCount = 1, numAnswers do - if answerSectionStarts < #message then local ATYPE = tonumber( message:sub(answerSectionStarts + 5, answerSectionStarts + 8), 16) @@ -359,7 +358,7 @@ function Module:init(t) self._enabled = true end -function Module:run(currentStatus, lastStatus, timeDiff, timeNow) +function Module:run(currentStatus, lastStatus, timeDiff, timeNow, inetChecked) if not self._enabled then return end @@ -384,22 +383,16 @@ function Module:run(currentStatus, lastStatus, timeDiff, timeNow) if self._counter > 0 then self:runIpScript() end - else - self.status = nil end - self._currentIp = ip self._counter = 0 - else - self.status = nil end else - self.status = nil self._currentIp = nil + self.status = self._currentIp self._counter = 0 self._interval = self.runInterval end - self._counter = self._counter + timeDiff end diff --git a/internet-detector/files/usr/lib/lua/internet-detector/mod_reboot.lua b/internet-detector/files/usr/lib/lua/internet-detector/mod_reboot.lua index 969e1ca..c282654 100644 --- a/internet-detector/files/usr/lib/lua/internet-detector/mod_reboot.lua +++ b/internet-detector/files/usr/lib/lua/internet-detector/mod_reboot.lua @@ -36,7 +36,7 @@ function Module:init(t) end end -function Module:run(currentStatus, lastStatus, timeDiff, timeNow) +function Module:run(currentStatus, lastStatus, timeDiff, timeNow, inetChecked) if currentStatus == 1 then if not self._rebooted then if timeNow >= self.antiBootloopDelay and self._deadCounter >= self.deadPeriod then diff --git a/internet-detector/files/usr/lib/lua/internet-detector/mod_regular_script.lua b/internet-detector/files/usr/lib/lua/internet-detector/mod_regular_script.lua index f06d658..6610ada 100644 --- a/internet-detector/files/usr/lib/lua/internet-detector/mod_regular_script.lua +++ b/internet-detector/files/usr/lib/lua/internet-detector/mod_regular_script.lua @@ -1,6 +1,7 @@ local stdlib = require("posix.stdlib") local unistd = require("posix.unistd") +local time = require("posix.time") local Module = { name = "mod_regular_script", @@ -14,6 +15,7 @@ local Module = { script = "", status = nil, _nextTime = nil, + _firstRun = true, } function Module:runExternalScript(scriptPath, currentStatus) @@ -36,7 +38,7 @@ function Module:init(t) end end -function Module:run(currentStatus, lastStatus, timeDiff, timeNow) +function Module:run(currentStatus, lastStatus, timeDiff, timeNow, inetChecked) if not self._nextTime then if timeNow < self.runInterval then self._nextTime = self.runInterval @@ -44,11 +46,16 @@ function Module:run(currentStatus, lastStatus, timeDiff, timeNow) self._nextTime = timeNow - (timeNow % self.runInterval) + self.runInterval end end + if self._firstRun then + self.status = time.strftime ("%Y-%m-%d %H:%M:%S %z", time.localtime(time.time() + self._nextTime - timeNow)) + self._firstRun = false + end if timeNow >= self._nextTime then + self._nextTime = self._nextTime + self.runInterval if self.inetState == 2 or (self.inetState == 0 and currentStatus == 0) or (self.inetState == 1 and currentStatus == 1) then + self.status = time.strftime ("%Y-%m-%d %H:%M:%S %z", time.localtime(time.time() + self._nextTime - timeNow)) self:runExternalScript(self.script, currentStatus) end - self._nextTime = self._nextTime + self.runInterval end end diff --git a/internet-detector/files/usr/lib/lua/internet-detector/mod_user_scripts.lua b/internet-detector/files/usr/lib/lua/internet-detector/mod_user_scripts.lua index 3af696d..47ec78d 100644 --- a/internet-detector/files/usr/lib/lua/internet-detector/mod_user_scripts.lua +++ b/internet-detector/files/usr/lib/lua/internet-detector/mod_user_scripts.lua @@ -40,7 +40,7 @@ function Module:init(t) end end -function Module:run(currentStatus, lastStatus, timeDiff, timeNow) +function Module:run(currentStatus, lastStatus, timeDiff, timeNow, inetChecked) if currentStatus == 1 then self._aliveCounter = 0 self._upScriptExecuted = false diff --git a/luci-app-internet-detector/Makefile b/luci-app-internet-detector/Makefile index 2860103..b46eb3c 100644 --- a/luci-app-internet-detector/Makefile +++ b/luci-app-internet-detector/Makefile @@ -1,12 +1,12 @@ # -# (с) 2024 gSpot (https://github.com/gSpotx2f/luci-app-internet-detector) +# (с) 2025 gSpot (https://github.com/gSpotx2f/luci-app-internet-detector) # include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-internet-detector -PKG_VERSION:=1.4.2 -PKG_RELEASE:=2 +PKG_VERSION:=1.4.3 +PKG_RELEASE:=1 LUCI_TITLE:=LuCI support for internet-detector LUCI_DEPENDS:=+internet-detector LUCI_PKGARCH:=all diff --git a/luci-app-internet-detector/htdocs/luci-static/resources/view/internet-detector.js b/luci-app-internet-detector/htdocs/luci-static/resources/view/internet-detector.js index cbe3577..0bd4e6c 100644 --- a/luci-app-internet-detector/htdocs/luci-static/resources/view/internet-detector.js +++ b/luci-app-internet-detector/htdocs/luci-static/resources/view/internet-detector.js @@ -134,24 +134,25 @@ var Timefield = ui.Textfield.extend({ }); return view.extend({ - appName : 'internet-detector', - configDir : '/etc/internet-detector', - pollInterval : L.env.pollinterval, - appStatus : 'stoped', - initStatus : null, - inetStatus : null, - inetStatusArea : E('div', { 'class': 'cbi-value-field', 'id': 'inetStatusArea' }), - serviceStatusLabel : E('em', { 'id': 'serviceStatusLabel' }), - initButton : null, - currentAppMode : '0', - defaultHosts : [ '8.8.8.8', '1.1.1.1' ], - ledsPath : '/sys/class/leds', - ledsPerInstance : 3, - leds : [], - mm : false, - mmInit : false, - email : false, - emailExec : false, + appName : 'internet-detector', + configDir : '/etc/internet-detector', + pollInterval : L.env.pollinterval, + appStatus : 'stoped', + initStatus : null, + inetStatus : null, + inetStatusArea : E('div', { 'class': 'cbi-value-field', 'id': 'inetStatusArea' }), + serviceStatusLabel : E('em', { 'id': 'serviceStatusLabel' }), + initButton : null, + currentAppMode : '0', + defaultHosts : [ '8.8.8.8', '1.1.1.1' ], + ledsPath : '/sys/class/leds', + ledsPerInstance : 3, + leds : [], + mm : false, + mmInit : false, + email : false, + emailExec : false, + modRegularScriptNextRun: {}, callInitStatus: rpc.declare({ object: 'luci', @@ -273,6 +274,18 @@ return view.extend({ i.instance + ': ', status, publicIp) ) ); + + if(i.mod_regular_script) { + this.modRegularScriptNextRun[i.instance] = i.mod_regular_script; + let nextRunLabel = document.getElementById('id_next_run_' + i.instance); + if(nextRunLabel) { + if(this.appStatus === 'running') { + nextRunLabel.innerHTML = this.modRegularScriptNextRun[i.instance]; + } else { + nextRunLabel.innerHTML = _('Not scheduled'); + }; + }; + }; }; }; @@ -670,8 +683,8 @@ return view.extend({ // iface o = s.taboption('main', widgets.DeviceSelect, - 'iface', _('Interface'), - _('Network interface for Internet access. If not specified, the default interface is used.') + 'iface', _('Device'), + _('Network device for Internet access. If not specified, the default device is used.') ); o.noaliases = true; @@ -765,7 +778,7 @@ return view.extend({ // enabled o = s.taboption('led_control', form.Flag, 'mod_led_control_enabled', _('Enabled')); - o.rmempty = false; + o.rmempty = false; o.modalonly = true; o = s.taboption('led_control', form.SectionValue, s.section, form.NamedSection, @@ -827,7 +840,7 @@ return view.extend({ // enabled o = s.taboption('reboot_device', form.Flag, 'mod_reboot_enabled', _('Enabled')); - o.rmempty = false; + o.rmempty = false; o.modalonly = true; // dead_period @@ -866,13 +879,13 @@ return view.extend({ // enabled o = s.taboption('restart_network', form.Flag, 'mod_network_restart_enabled', _('Enabled')); - o.rmempty = false; + o.rmempty = false; o.modalonly = true; // dead_period o = s.taboption('restart_network', this.CBITimeInput, 'mod_network_restart_dead_period', _('Dead period'), - _('Period of time without Internet access before network restart or between restart attempts.') + _('Period of time without Internet access before network restart.') ); o.default = '900'; o.rmempty = false; @@ -891,17 +904,18 @@ return view.extend({ o.value(5); o.default = '1'; - // iface - o = s.taboption('restart_network', widgets.DeviceSelect, 'mod_network_restart_iface', - _('Interface'), - _('Network interface to restart. If not specified, then the network service is restarted.') + // ifaces + o = s.taboption('restart_network', widgets.DeviceSelect, 'mod_network_restart_ifaces', + _('Device'), + _('Network device or interface to restart. If not specified, then the network service is restarted.') ); o.modalonly = true; + o.multiple = true; // restart_timeout o = s.taboption('restart_network', form.ListValue, 'mod_network_restart_restart_timeout', _('Restart timeout'), - _('Timeout between stopping and starting the interface.') + _('Timeout between stopping and starting a network device.') ); o.modalonly = true; o.value(0, '0 ' + _('sec')); @@ -1065,7 +1079,7 @@ return view.extend({ // enabled o = s.taboption('email', form.Flag, 'mod_email_enabled', _('Enabled')); - o.rmempty = false; + o.rmempty = false; o.modalonly = true; // mode @@ -1083,7 +1097,7 @@ return view.extend({ 'mod_email_alive_period', _('Alive period'), _('Period of time after connecting to the Internet before sending a message.') ); - o.rmempty = false; + o.rmempty = false; o.modalonly = true; o.depends({ 'mod_email_mode': '0' }); o.depends({ 'mod_email_mode': '2' }); @@ -1094,7 +1108,7 @@ return view.extend({ 'mod_email_dead_period', _('Dead period'), _('Period of time after disconnecting from Internet before sending a message.') ); - o.rmempty = false; + o.rmempty = false; o.modalonly = true; o.depends({ 'mod_email_mode': '1' }); o.depends({ 'mod_email_mode': '2' }); @@ -1231,6 +1245,20 @@ return view.extend({ o.rmempty = false; o.modalonly = true; + // next run + o = s.taboption('regular_script', form.DummyValue, '_dummy', _('Next run')); + o.rawhtml = true; + o.default = '' + (this.modRegularScriptNextRun[s.section] || _('Not scheduled')) + ''; + o.modalonly = true; + + // interval + o = s.taboption('regular_script', this.CBITimeInput, + 'mod_regular_script_interval', _('Run interval') + ); + o.default = '3600'; + o.rmempty = false; + o.modalonly = true; + // inet_state o = s.taboption('regular_script', form.ListValue, 'mod_regular_script_inet_state', _('Run if Internet state is') @@ -1249,14 +1277,6 @@ return view.extend({ _('Shell commands that run regularly at a specified interval. Current state of the Internet is available as value of the $INET_STATE variable (0 - connected, 1 - disconnected).') ); o.modalonly = true; - - // interval - o = s.taboption('regular_script', this.CBITimeInput, - 'mod_regular_script_interval', _('Run interval') - ); - o.default = '3600'; - o.rmempty = false; - o.modalonly = true; }; }; diff --git a/luci-app-internet-detector/po/ru/internet-detector.po b/luci-app-internet-detector/po/ru/internet-detector.po index 4e1a85c..62e0759 100644 --- a/luci-app-internet-detector/po/ru/internet-detector.po +++ b/luci-app-internet-detector/po/ru/internet-detector.po @@ -83,6 +83,9 @@ msgstr "Период после отключения" msgid "Default port value for TCP connections." msgstr "Стандартное значение порта для TCP-подключений." +msgid "Device" +msgstr "Устройство" + msgid "Device will be rebooted when the Internet is disconnected." msgstr "Устройство будет перезагружено при отключении Интернет." @@ -255,24 +258,30 @@ msgstr "" "ModemManger." msgid "" -"Network interface for Internet access. If not specified, the default " -"interface is used." +"Network device for Internet access. If not specified, the default " +"device is used." msgstr "" -"Сетевой интерфейс для доступа в Интернет. Если не указан, используется " -"интерфейс по умолчанию." +"Сетевое устройство для доступа в Интернет. Если не указано, используется " +"устройство по умолчанию." msgid "" -"Network interface to restart. If not specified, then the network service is restarted." +"Network device or interface to restart. If not specified, then the network service is restarted." msgstr "" -"Сетевой интерфейс для перезапуска. Если не задан, то будет перезапущена сетевая " +"Сетевое устройство или интерфейс для перезапуска. Если не задано, то будет перезапущена сетевая " "служба." msgid "Network will be restarted when the Internet is disconnected." msgstr "Сеть будет перезапущена при отключении Интернет." +msgid "Next run" +msgstr "Следующий запуск" + msgid "No LEDs available..." msgstr "Нет доступных LED..." +msgid "Not scheduled" +msgstr "Не запланирован" + msgid "Off" msgstr "Выключить" @@ -309,8 +318,8 @@ msgstr "Период времени отсутствия доступа в Ин msgid "Period of time without Internet access before modem restart." msgstr "Период времени отсутствия доступа в Интренет перед перезапуском модема." -msgid "Period of time without Internet access before network restart or between restart attempts." -msgstr "Период времени отсутствия доступа в Интренет перед перезапуском сети или между попытками перезапуска." +msgid "Period of time without Internet access before network restart." +msgstr "Период времени отсутствия доступа в Интренет перед перезапуском сети." msgid "" "Period of time without Internet access until the device is rebooted." @@ -440,8 +449,8 @@ msgstr "Тип записи запрашиваемой в DNS-запросе (е msgid "TLS: use STARTTLS if the server supports it." msgstr "TLS: использовать STARTTLS если сервер поддерживает." -msgid "Timeout between stopping and starting the interface." -msgstr "Таймаут между остановкой и запуском интерфейса." +msgid "Timeout between stopping and starting a network device." +msgstr "Таймаут между остановкой и запуском сетевого устройства." msgid "Type a time string" msgstr "Введите строку времени" diff --git a/luci-app-internet-detector/po/templates/internet-detector.pot b/luci-app-internet-detector/po/templates/internet-detector.pot index 2ccf138..5572b88 100644 --- a/luci-app-internet-detector/po/templates/internet-detector.pot +++ b/luci-app-internet-detector/po/templates/internet-detector.pot @@ -71,6 +71,9 @@ msgstr "" msgid "Default port value for TCP connections." msgstr "" +msgid "Device" +msgstr "" + msgid "Device will be rebooted when the Internet is disconnected." msgstr "" @@ -237,20 +240,26 @@ msgid "" msgstr "" msgid "" -"Network interface for Internet access. If not specified, the default " +"Network device for Internet access. If not specified, the default " "interface is used." msgstr "" msgid "" -"Network interface to restart. If not specified, then the network service is restarted." +"Network device or interface to restart. If not specified, then the network service is restarted." msgstr "" msgid "Network will be restarted when the Internet is disconnected." msgstr "" +msgid "Next run" +msgstr "" + msgid "No LEDs available..." msgstr "" +msgid "Not scheduled" +msgstr "" + msgid "Off" msgstr "" @@ -285,7 +294,7 @@ msgstr "" msgid "Period of time without Internet access before modem restart." msgstr "" -msgid "Period of time without Internet access before network restart or between restart attempts." +msgid "Period of time without Internet access before network restart." msgstr "" msgid "" @@ -415,7 +424,7 @@ msgstr "" msgid "TLS: use STARTTLS if the server supports it." msgstr "" -msgid "Timeout between stopping and starting the interface." +msgid "Timeout between stopping and starting a network device." msgstr "" msgid "Type a time string"