modules: Module.onExit().

This commit is contained in:
gSpot
2025-04-06 15:35:03 +03:00
parent 5b669fe718
commit 36a70fa706
14 changed files with 74 additions and 22 deletions

View File

@@ -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)

View File

@@ -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 <https://github.com/gSpotx2f/luci-app-internet-detector>

View File

@@ -189,4 +189,8 @@ function Module:run(currentStatus, lastStatus, timeDiff, timeNow, inetChecked)
end
end
function Module:onExit()
return true
end
return Module

View File

@@ -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 <https://github.com/gSpotx2f/luci-app-internet-detector>

View File

@@ -99,4 +99,8 @@ function Module:run(currentStatus, lastStatus, timeDiff, timeNow, inetChecked)
end
end
function Module:onExit()
return true
end
return Module

View File

@@ -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 <https://github.com/gSpotx2f/luci-app-internet-detector>

View File

@@ -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")

View File

@@ -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

View File

@@ -141,4 +141,8 @@ function Module:run(currentStatus, lastStatus, timeDiff, timeNow, inetChecked)
end
end
function Module:onExit()
return true
end
return Module

View File

@@ -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

View File

@@ -52,4 +52,8 @@ function Module:run(currentStatus, lastStatus, timeDiff, timeNow, inetChecked)
end
end
function Module:onExit()
return true
end
return Module

View File

@@ -59,4 +59,8 @@ function Module:run(currentStatus, lastStatus, timeDiff, timeNow, inetChecked)
end
end
function Module:onExit()
return true
end
return Module

View File

@@ -66,4 +66,8 @@ function Module:run(currentStatus, lastStatus, timeDiff, timeNow, inetChecked)
end
end
function Module:onExit()
return true
end
return Module

View File

@@ -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