start snap systemd service if DAEMON env var set to ENABLED

This commit is contained in:
Adnan Hodzic 2020-02-05 21:03:29 +01:00
parent 8a06de40cd
commit ea687deb20
3 changed files with 45 additions and 30 deletions

View File

@ -29,14 +29,27 @@ def main(monitor, live, daemon, install, log):
footer(79)
else:
if daemon:
while True:
root_check()
gov_check()
cpufreqctl()
sysinfo()
set_autofreq()
countdown(5)
subprocess.call("clear")
if os.getenv("PKG_MARKER") == "SNAP" and os.getenv("DAEMON") == "ENABLED":
while True:
root_check()
gov_check()
cpufreqctl()
sysinfo()
set_autofreq()
countdown(5)
subprocess.call("clear")
elif os.getenv("PKG_MARKER") != "SNAP":
while True:
root_check()
gov_check()
cpufreqctl()
sysinfo()
set_autofreq()
countdown(5)
subprocess.call("clear")
else:
sys.exit("Daemon non ENABLED")
exit(1)
elif monitor:
while True:
running_check()
@ -61,11 +74,29 @@ def main(monitor, live, daemon, install, log):
# ToDo: fail if log is missing or empty (on)
read_log()
elif install:
running_check()
root_check()
gov_check()
deploy()
if os.getenv('PKG_MARKER') == "SNAP":
os.environ["DAEMON"] = "ENABLED"
print(os.environ["DAEMON"])
running_check()
root_check()
gov_check()
# ToDo:
# implement option to restart snap service?
else:
running_check()
root_check()
gov_check()
deploy()
# ToDo: add remove for snap
elif remove:
if os.getenv('PKG_MARKER') == "SNAP":
root_check()
# ToDo: remove if not needed?
#kill_process("auto-cpufreq --daemon")
# ToDo:
# implement option to stop and restart snap service?
else:
root_check()
remove()

View File

@ -1,3 +0,0 @@
#!/bin/bash
auto-cpufreq --daemon 2>&1 | tee -a /var/log/auto-cpufreq.log

View File

@ -17,14 +17,6 @@ parts:
plugin: python
python-version: python3
source: .
#stage-packages:
# - python3-pip
# - python3-dev
#python-packages:
# - psutil
# - click
# - distro
# - power
deploy-cpufrectl:
plugin: dump
@ -32,13 +24,6 @@ parts:
organize:
cpufreqctl.sh: usr/bin/cpufreqctl
# ToDo: remove scripts/daemon
# deploy-demon:
# plugin: dump
# source: scripts
# organize:
# daemon.sh: usr/bin/daemon
apps:
auto-cpufreq:
command: bin/auto-cpufreq
@ -46,11 +31,13 @@ apps:
LC_ALL: C.UTF-8
LANG: C.UTF-8
PKG_MARKER: SNAP
DAEMON: DISABLED
auto-cpufreq-service:
command: bin/auto-cpufreq --daemon 2>&1 | tee -a /var/log/auto-cpufreq.log
environment:
LC_ALL: C.UTF-8
LANG: C.UTF-8
PKG_MARKER: SNAP
DAEMON: DISABLED
daemon: simple