Skip to content

Commit

Permalink
Develop (#80)
Browse files Browse the repository at this point in the history
* Fix/postinstall (#74)

* Develop (#70)

* Feature/rpm repo (#67)

* feat: rpm package repo

* feat: rpm package repo

* release: develop

* Fix/readme rpm (#69)

* feat: rpm package repo

* feat: rpm package repo

* Develop (#68)

* Feature/rpm repo (#67)

* feat: rpm package repo

* feat: rpm package repo

* release: develop

Co-authored-by: skynet-core <[email protected]>

* fix: added rpm install info

* feat: detect config by smbios info

* fix: sqlite static linking

* fix: config name to match device model

* log levels

* fix: service log level

* fix: service files

Co-authored-by: skynet-core <[email protected]>

* release: develop

Co-authored-by: skynet-core <[email protected]>

* fix: installation scripts, sqlite3 dependency

Co-authored-by: skynet-core <[email protected]>

* release: develop

* Fix/postinstall (#76)

* Develop (#70)

* Feature/rpm repo (#67)

* feat: rpm package repo

* feat: rpm package repo

* release: develop

* Fix/readme rpm (#69)

* feat: rpm package repo

* feat: rpm package repo

* Develop (#68)

* Feature/rpm repo (#67)

* feat: rpm package repo

* feat: rpm package repo

* release: develop

Co-authored-by: skynet-core <[email protected]>

* fix: added rpm install info

* feat: detect config by smbios info

* fix: sqlite static linking

* fix: config name to match device model

* log levels

* fix: service log level

* fix: service files

Co-authored-by: skynet-core <[email protected]>

* release: develop

Co-authored-by: skynet-core <[email protected]>

* fix: installation scripts, sqlite3 dependency

* chore: trigger release

* Develop (#75)

* Fix/postinstall (#74)

* Develop (#70)

* Feature/rpm repo (#67)

* feat: rpm package repo

* feat: rpm package repo

* release: develop

* Fix/readme rpm (#69)

* feat: rpm package repo

* feat: rpm package repo

* Develop (#68)

* Feature/rpm repo (#67)

* feat: rpm package repo

* feat: rpm package repo

* release: develop

Co-authored-by: skynet-core <[email protected]>

* fix: added rpm install info

* feat: detect config by smbios info

* fix: sqlite static linking

* fix: config name to match device model

* log levels

* fix: service log level

* fix: service files

Co-authored-by: skynet-core <[email protected]>

* release: develop

Co-authored-by: skynet-core <[email protected]>

* fix: installation scripts, sqlite3 dependency

Co-authored-by: skynet-core <[email protected]>

* release: develop

Co-authored-by: skynet-core <[email protected]>

* fix: postinstall script

Co-authored-by: skynet-core <[email protected]>

* release: develop

* Fix/setup (#79)

* Develop (#78)

* Fix/postinstall (#74)

* Develop (#70)

* Feature/rpm repo (#67)

* feat: rpm package repo

* feat: rpm package repo

* release: develop

* Fix/readme rpm (#69)

* feat: rpm package repo

* feat: rpm package repo

* Develop (#68)

* Feature/rpm repo (#67)

* feat: rpm package repo

* feat: rpm package repo

* release: develop

Co-authored-by: skynet-core <[email protected]>

* fix: added rpm install info

* feat: detect config by smbios info

* fix: sqlite static linking

* fix: config name to match device model

* log levels

* fix: service log level

* fix: service files

Co-authored-by: skynet-core <[email protected]>

* release: develop

Co-authored-by: skynet-core <[email protected]>

* fix: installation scripts, sqlite3 dependency

Co-authored-by: skynet-core <[email protected]>

* release: develop

* Fix/postinstall (#76)

* Develop (#70)

* Feature/rpm repo (#67)

* feat: rpm package repo

* feat: rpm package repo

* release: develop

* Fix/readme rpm (#69)

* feat: rpm package repo

* feat: rpm package repo

* Develop (#68)

* Feature/rpm repo (#67)

* feat: rpm package repo

* feat: rpm package repo

* release: develop

Co-authored-by: skynet-core <[email protected]>

* fix: added rpm install info

* feat: detect config by smbios info

* fix: sqlite static linking

* fix: config name to match device model

* log levels

* fix: service log level

* fix: service files

Co-authored-by: skynet-core <[email protected]>

* release: develop

Co-authored-by: skynet-core <[email protected]>

* fix: installation scripts, sqlite3 dependency

* chore: trigger release

* Develop (#75)

* Fix/postinstall (#74)

* Develop (#70)

* Feature/rpm repo (#67)

* feat: rpm package repo

* feat: rpm package repo

* release: develop

* Fix/readme rpm (#69)

* feat: rpm package repo

* feat: rpm package repo

* Develop (#68)

* Feature/rpm repo (#67)

* feat: rpm package repo

* feat: rpm package repo

* release: develop

Co-authored-by: skynet-core <[email protected]>

* fix: added rpm install info

* feat: detect config by smbios info

* fix: sqlite static linking

* fix: config name to match device model

* log levels

* fix: service log level

* fix: service files

Co-authored-by: skynet-core <[email protected]>

* release: develop

Co-authored-by: skynet-core <[email protected]>

* fix: installation scripts, sqlite3 dependency

Co-authored-by: skynet-core <[email protected]>

* release: develop

Co-authored-by: skynet-core <[email protected]>

* fix: postinstall script

Co-authored-by: skynet-core <[email protected]>

* release: develop

Co-authored-by: skynet-core <[email protected]>

* fix: setup scripts

Co-authored-by: skynet-core <[email protected]>
Co-authored-by: Skynet Core <[email protected]>

* release: develop

Co-authored-by: skynet-core <[email protected]>
Co-authored-by: Skynet Core <[email protected]>
  • Loading branch information
3 people authored Jan 10, 2021
1 parent eeb3c7c commit 20497db
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 25 deletions.
6 changes: 3 additions & 3 deletions nsense.nimble
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import tables
import strutils
# Package

version = "0.6.5"
version = "0.6.6"
author = "Skynet Core"
description = "A new awesome nimble package"
license = "MIT"
Expand All @@ -25,7 +25,7 @@ task nsense, "Run nsense service":
task static, "Build static musl binaries":
let dir = getCurrentDir()
exec "docker run --rm -v " & dir &
":/home/nim/nord-sense smartcoder/nim:v1.4 bash -c '" &
":/home/nim/nord-sense smartcoder/nim:v1.2 bash -c '" &
"sudo apk update && sudo apk upgrade && sudo apk add sqlite-static &&" &
" cd /home/nim/nord-sense && nimble build --gcc.exe:gcc --gcc.linkerexe:gcc" &
" --passL:-static --dynlibOverride:libsqlite3.so --passL:/usr/lib/libsqlite3.a -d:release --opt:size -y'"
Expand Down Expand Up @@ -54,5 +54,5 @@ task purge, "Removing service from system":
exec selfExe() & " " & dir & "/res/uninstall/" & hostOS & ".nims"

task clean, "clean artifacts":
exec "rm -rf nsensepkg nsense tests/test1 here.pid"
exec "sudo rm -rf settings.db run etc nsensepkg nsense usr tests/test1 here.pid"
echo "Done"
2 changes: 1 addition & 1 deletion res/install/linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ bin=${executable##*/}

if [ "$bin" = "systemd" ]; then

if systemctl status nsense 2>&1 1>/dev/null; then
if systemctl is-active nsense 2>&1 1>/dev/null; then
systemctl stop nsense
fi

Expand Down
2 changes: 1 addition & 1 deletion res/service/systemd/nsense.service
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Description=Acer nsense service
[Service]
Type=simple
WorkingDirectory=/opt/nsense
ExecStart=/opt/nsense/bin/nsense -p /run/nsense.pid -l error -f
ExecStart=/opt/nsense/bin/nsense -p /run/nsense.pid -l debug -f
ExecStop=sh -c 'kill -s TERM `cat /opt/nsense/run/nsense.pid`'
ExecReload=sh -c 'kill -s HUP `cat /opt/nsense/run/nsense.pid`'
PIDFile=/run/nsense.pid
Expand Down
10 changes: 5 additions & 5 deletions res/uninstall/linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,11 @@ set -x

echo "nsense Linux uninstaller script"

if [ -d /opt/nsense ]; then
rm -rf /opt/nsense
fi

executable=$(readlink /proc/1/exe)
bin=${executable##*/}

if [ "$bin" = "systemd" ]; then
if systemctl status nsense 2>&1 1>/dev/null; then
if systemctl is-active nsense 2>&1 1>/dev/null; then
systemctl stop nsense
fi
systemctl disable nsense
Expand All @@ -26,4 +22,8 @@ else
exit 1
fi

if [ -d /opt/nsense ]; then
rm -rf /opt/nsense
fi

systemctl daemon-reload
18 changes: 15 additions & 3 deletions src/nsense.nim
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ when isMainModule:

if not config.ready():
# check if config for current model exists or /etc/config(.yml*) exists
log.info(&"resolving config {configFile} for {model}...")
configFile = resolveConfig(wd, model, configFile)
config = if configFile.len > 0:
loadConfig(configFile)
Expand All @@ -69,7 +70,13 @@ when isMainModule:
timerFd = sel.registerTimer(int(config.pollTickMs), oneshot = false,0) # once per second
zones = initZones(config.zones)

let
let
switchToAuto = proc(): void =
if config.ready():
log.info("reset to auto mode...")
for (i, zone) in config.zones.pairs:
for (j, fan) in zone.fans.pairs:
ctrl.send(fan.address, fan.auto)
loadAndReset = proc(): void =
if configFile.len > 0:
config = loadConfig(configFile)
Expand All @@ -86,6 +93,7 @@ when isMainModule:

let handlerSwitch = {
hupFd: proc(timeStr: string): void =
switchToAuto()
log.info(&"{timeStr}: SIGHUP received. Updating configuration ...")
loadAndReset()
,
Expand All @@ -94,11 +102,13 @@ when isMainModule:
loadAndReset()
,
pauseFd: proc(timeStr: string): void =
switchToAuto()
unregisterTimerAndReset()
log.info(&"{timeStr}: SIGSTOP received. Going idle ...")
,
timerFd: proc(timeStr: string): void =
if not config.ready():
log.info(&"{timeStr}: config wasn't loaded correctly...")
unregisterTimerAndReset()
return
## iterate through zones and compare temp with level bounds
Expand Down Expand Up @@ -126,13 +136,15 @@ when isMainModule:
state.reset()
,
termFd: proc(timeStr: string): void =
switchToAuto()
unregisterTimerAndReset()
log.info("{timeStr}: SIGTERM received. Quiting ... ")
log.info(&"{timeStr}: SIGTERM received. Quiting ... ")
quit(0)
,
killFd: proc(timeStr: string): void =
switchToAuto()
unregisterTimerAndReset()
log.info("{timeStr}: SIGKILL received. Quiting ... ")
log.info(&"{timeStr}: SIGKILL received. Quiting ... ")
quit(1)
,
}.toTable
Expand Down
24 changes: 12 additions & 12 deletions src/nsensepkg/misc.nim
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,18 @@ proc resolveConfig*(wd: string, model: string, configFile: string): string =
except OSError:
quit("failed to create '" & configDir & "' :" & getCurrentExceptionMsg(),-1)
# try to find something from ready to use shared configs
let
match = model.multiReplace(replacements).toUpper()
for file in walkDir(joinPath(wd, shareConfigsDir)):
let configFile = file.path.splitFile.name.
split('.')[0].multiReplace(replacements).toUpper()
if configFile == match:
let dest = joinPath(configDir, configFileName)
try:
copyFile(file.path, dest)
return dest
except OSError:
quit("failed to copy '" & configFile & "' into '" & dest & "': " & getCurrentExceptionMsg(),-1)
let
match = model.multiReplace(replacements).toUpper()
for file in walkDir(joinPath(wd, shareConfigsDir)):
let configFile = file.path.splitFile.name.
split('.')[0].multiReplace(replacements).toUpper()
if configFile == match:
let dest = joinPath(configDir, configFileName)
try:
copyFile(file.path, dest)
return dest
except OSError:
quit("failed to copy '" & configFile & "' into '" & dest & "': " & getCurrentExceptionMsg(),-1)
return ""

proc configFilePath*(wd: string): string =
Expand Down

0 comments on commit 20497db

Please sign in to comment.