diff --git a/README.md b/README.md index 73e233b..89a4d2a 100644 --- a/README.md +++ b/README.md @@ -10,27 +10,29 @@ Internet-detector is an application for checking the availability of the Interne - Sending email notification when Internet access is restored (internet-detector-mod-email). - The daemon is written entirely in Lua using the luaposix library. +**OpenWrt >= 21.02.** + **Dependences:** lua, luaposix, libuci-lua. -## Installation notes (OpenWrt >= 21.02) +## Installation notes: opkg update - wget --no-check-certificate -O /tmp/internet-detector_1.4.4-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/internet-detector_1.4.4-r1_all.ipk - opkg install /tmp/internet-detector_1.4.4-r1_all.ipk - rm /tmp/internet-detector_1.4.4-r1_all.ipk + wget --no-check-certificate -O /tmp/internet-detector_1.4.5-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/internet-detector_1.4.5-r1_all.ipk + opkg install /tmp/internet-detector_1.4.5-r1_all.ipk + rm /tmp/internet-detector_1.4.5-r1_all.ipk service internet-detector start service internet-detector enable - wget --no-check-certificate -O /tmp/luci-app-internet-detector_1.4.4-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/luci-app-internet-detector_1.4.4-r1_all.ipk - opkg install /tmp/luci-app-internet-detector_1.4.4-r1_all.ipk - rm /tmp/luci-app-internet-detector_1.4.4-r1_all.ipk + wget --no-check-certificate -O /tmp/luci-app-internet-detector_1.4.5-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/luci-app-internet-detector_1.4.5-r1_all.ipk + opkg install /tmp/luci-app-internet-detector_1.4.5-r1_all.ipk + rm /tmp/luci-app-internet-detector_1.4.5-r1_all.ipk service rpcd restart i18n-ru: - wget --no-check-certificate -O /tmp/luci-i18n-internet-detector-ru_1.4.4-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/luci-i18n-internet-detector-ru_1.4.4-r1_all.ipk - opkg install /tmp/luci-i18n-internet-detector-ru_1.4.4-r1_all.ipk - rm /tmp/luci-i18n-internet-detector-ru_1.4.4-r1_all.ipk + wget --no-check-certificate -O /tmp/luci-i18n-internet-detector-ru_1.4.5-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/luci-i18n-internet-detector-ru_1.4.5-r1_all.ipk + opkg install /tmp/luci-i18n-internet-detector-ru_1.4.5-r1_all.ipk + rm /tmp/luci-i18n-internet-detector-ru_1.4.5-r1_all.ipk ## Screenshots: @@ -42,9 +44,9 @@ i18n-ru: **Dependences:** modemmanager. - wget --no-check-certificate -O /tmp/internet-detector-mod-modem-restart_1.4.4-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/internet-detector-mod-modem-restart_1.4.4-r1_all.ipk - opkg install /tmp/internet-detector-mod-modem-restart_1.4.4-r1_all.ipk - rm /tmp/internet-detector-mod-modem-restart_1.4.4-r1_all.ipk + wget --no-check-certificate -O /tmp/internet-detector-mod-modem-restart_1.4.5-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/internet-detector-mod-modem-restart_1.4.5-r1_all.ipk + opkg install /tmp/internet-detector-mod-modem-restart_1.4.5-r1_all.ipk + rm /tmp/internet-detector-mod-modem-restart_1.4.5-r1_all.ipk service internet-detector restart ![](https://github.com/gSpotx2f/luci-app-internet-detector/blob/master/screenshots/04.jpg) @@ -53,9 +55,9 @@ i18n-ru: **Dependences:** mailsend. - wget --no-check-certificate -O /tmp/internet-detector-mod-email_1.4.4-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/internet-detector-mod-email_1.4.4-r1_all.ipk - opkg install /tmp/internet-detector-mod-email_1.4.4-r1_all.ipk - rm /tmp/internet-detector-mod-email_1.4.4-r1_all.ipk + wget --no-check-certificate -O /tmp/internet-detector-mod-email_1.4.5-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/internet-detector-mod-email_1.4.5-r1_all.ipk + opkg install /tmp/internet-detector-mod-email_1.4.5-r1_all.ipk + rm /tmp/internet-detector-mod-email_1.4.5-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 5efd437..6b4a91a 100644 --- a/internet-detector-mod-email/Makefile +++ b/internet-detector-mod-email/Makefile @@ -5,7 +5,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=internet-detector-mod-email -PKG_VERSION:=1.4.4 +PKG_VERSION:=1.4.5 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 0a7336c..efa3e08 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 @@ -189,4 +189,8 @@ function Module:run(currentStatus, lastStatus, timeDiff, timeNow, inetChecked) end end +function Module:onExit() + return true +end + return Module diff --git a/internet-detector-mod-modem-restart/Makefile b/internet-detector-mod-modem-restart/Makefile index 27a2eda..ca401ec 100644 --- a/internet-detector-mod-modem-restart/Makefile +++ b/internet-detector-mod-modem-restart/Makefile @@ -5,7 +5,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=internet-detector-mod-modem-restart -PKG_VERSION:=1.4.4 +PKG_VERSION:=1.4.5 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 d264079..4f30e0c 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 @@ -99,4 +99,8 @@ function Module:run(currentStatus, lastStatus, timeDiff, timeNow, inetChecked) end end +function Module:onExit() + return true +end + return Module diff --git a/internet-detector/Makefile b/internet-detector/Makefile index 7d3d7e2..0d9d312 100644 --- a/internet-detector/Makefile +++ b/internet-detector/Makefile @@ -5,7 +5,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=internet-detector -PKG_VERSION:=1.4.4 +PKG_VERSION:=1.4.5 PKG_RELEASE:=1 PKG_MAINTAINER:=gSpot 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 2f0d93d..ecdf64e 100644 --- a/internet-detector/files/usr/lib/lua/internet-detector/main.lua +++ b/internet-detector/files/usr/lib/lua/internet-detector/main.lua @@ -593,6 +593,10 @@ function InternetDetector:run() self:mainLoop() + for _, e in ipairs(self.modules) do + e:onExit() + end + self:removeProcessFiles() if self.enableLogger then self:writeLogMessage("info", "stoped") 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 c9c8b89..b0f1698 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 @@ -39,6 +39,13 @@ function Module:setLedAttrs(t) t.ledBrightnessFile = string.format("%s/brightness", t.ledDir) t.ledMaxBrightness = self.readValue(t.ledMaxBrightnessFile) or 1 t.ledTriggerFile = string.format("%s/trigger", t.ledDir) + t.ledPrevState = { + brightness = self.readValue(t.ledBrightnessFile), + trigger = self.readValue(t.ledTriggerFile), + } + if t.ledPrevState.trigger then + t.ledPrevState.trigger = t.ledPrevState.trigger:match("%[%w+%]"):gsub("[%]%[]", "") + end end function Module:checkLed(t) @@ -53,8 +60,6 @@ function Module:init(t) end if t.led1_name then self._enabled = true - -- Reset all LEDs - --self:resetLeds() else return end @@ -155,4 +160,17 @@ function Module:run(currentStatus, lastStatus, timeDiff, timeNow, inetChecked) self._counter = self._counter + timeDiff end +function Module:onExit() + for _, l in ipairs(self._leds) do + if l.ledPrevState then + if l.ledPrevState.brightness then + self.writeValue(l.ledBrightnessFile, l.ledPrevState.brightness) + end + if l.ledPrevState.trigger then + self.writeValue(l.ledTriggerFile, l.ledPrevState.trigger) + end + end + end +end + return Module 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 4c1c332..354661a 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 @@ -141,4 +141,8 @@ function Module:run(currentStatus, lastStatus, timeDiff, timeNow, inetChecked) end end +function Module:onExit() + return true +end + return Module 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 be374b4..ac5110c 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 @@ -419,4 +419,8 @@ function Module:run(currentStatus, lastStatus, timeDiff, timeNow, inetChecked) self._counter = self._counter + timeDiff end +function Module:onExit() + return true +end + return Module 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 c282654..a403467 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 @@ -52,4 +52,8 @@ function Module:run(currentStatus, lastStatus, timeDiff, timeNow, inetChecked) end end +function Module:onExit() + return true +end + return Module 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 6610ada..339e1b7 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 @@ -59,4 +59,8 @@ function Module:run(currentStatus, lastStatus, timeDiff, timeNow, inetChecked) end end +function Module:onExit() + return true +end + return Module 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 47ec78d..8f8749e 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 @@ -66,4 +66,8 @@ function Module:run(currentStatus, lastStatus, timeDiff, timeNow, inetChecked) end end +function Module:onExit() + return true +end + return Module diff --git a/luci-app-internet-detector/Makefile b/luci-app-internet-detector/Makefile index 7053599..5a4b503 100644 --- a/luci-app-internet-detector/Makefile +++ b/luci-app-internet-detector/Makefile @@ -5,7 +5,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-internet-detector -PKG_VERSION:=1.4.4 +PKG_VERSION:=1.4.5 PKG_RELEASE:=1 LUCI_TITLE:=LuCI support for internet-detector LUCI_DEPENDS:=+internet-detector