Changed common dir.

This commit is contained in:
gSpot
2025-08-25 23:49:39 +03:00
parent 73e98a682d
commit e9814cf85b
7 changed files with 33 additions and 27 deletions

View File

@@ -16,7 +16,6 @@ local InternetDetector = {
loggingLevel = 6,
hostname = "OpenWrt",
appName = "internet-detector",
commonDir = "/tmp/run",
libDir = "/usr/lib/lua",
pingCmd = "/bin/ping",
pingParams = "-c 1",
@@ -56,6 +55,7 @@ local InternetDetector = {
InternetDetector.configDir = string.format("/etc/%s", InternetDetector.appName)
InternetDetector.modulesDir = string.format(
"%s/%s/modules", InternetDetector.libDir, InternetDetector.appName)
InternetDetector.commonDir = string.format("/tmp/run/%s", InternetDetector.appName)
-- Loading settings from UCI
@@ -386,7 +386,6 @@ function InternetDetector:mainLoop()
self:writeLogMessage("notice", "Disconnected")
end
end
counter = 0
end
@@ -400,7 +399,6 @@ function InternetDetector:mainLoop()
mTimeDiff = 1
end
mLastTime = mTimeNow
if self.debug then
e:run(currentStatus, lastStatus, mTimeDiff, mTimeNow, inetChecked)
else
@@ -553,6 +551,14 @@ function InternetDetector:preRun()
io.stderr:write(string.format('Start failed, mode != (1 or 2)\n', self.appName))
os.exit(0)
end
local s = stat.stat(self.commonDir)
if not s or not (stat.S_ISDIR(s.st_mode) ~= 0) then
if not stat.mkdir(self.commonDir) then
io.stderr:write(
string.format('Error occurred while creating %s. Exit.\n', self.commonDir))
os.exit(1)
end
end
if stat.stat(self.pidFile) then
io.stderr:write(
string.format('PID file "%s" exists. Is the %s already running?\n',