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) footer(79)
else: else:
if daemon: if daemon:
while True: if os.getenv("PKG_MARKER") == "SNAP" and os.getenv("DAEMON") == "ENABLED":
root_check() while True:
gov_check() root_check()
cpufreqctl() gov_check()
sysinfo() cpufreqctl()
set_autofreq() sysinfo()
countdown(5) set_autofreq()
subprocess.call("clear") 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: elif monitor:
while True: while True:
running_check() running_check()
@ -61,11 +74,29 @@ def main(monitor, live, daemon, install, log):
# ToDo: fail if log is missing or empty (on) # ToDo: fail if log is missing or empty (on)
read_log() read_log()
elif install: elif install:
running_check() if os.getenv('PKG_MARKER') == "SNAP":
root_check() os.environ["DAEMON"] = "ENABLED"
gov_check() print(os.environ["DAEMON"])
deploy() 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: 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() root_check()
remove() 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 plugin: python
python-version: python3 python-version: python3
source: . source: .
#stage-packages:
# - python3-pip
# - python3-dev
#python-packages:
# - psutil
# - click
# - distro
# - power
deploy-cpufrectl: deploy-cpufrectl:
plugin: dump plugin: dump
@ -32,13 +24,6 @@ parts:
organize: organize:
cpufreqctl.sh: usr/bin/cpufreqctl cpufreqctl.sh: usr/bin/cpufreqctl
# ToDo: remove scripts/daemon
# deploy-demon:
# plugin: dump
# source: scripts
# organize:
# daemon.sh: usr/bin/daemon
apps: apps:
auto-cpufreq: auto-cpufreq:
command: bin/auto-cpufreq command: bin/auto-cpufreq
@ -46,11 +31,13 @@ apps:
LC_ALL: C.UTF-8 LC_ALL: C.UTF-8
LANG: C.UTF-8 LANG: C.UTF-8
PKG_MARKER: SNAP PKG_MARKER: SNAP
DAEMON: DISABLED
auto-cpufreq-service: auto-cpufreq-service:
command: bin/auto-cpufreq --daemon 2>&1 | tee -a /var/log/auto-cpufreq.log command: bin/auto-cpufreq --daemon 2>&1 | tee -a /var/log/auto-cpufreq.log
environment: environment:
LC_ALL: C.UTF-8 LC_ALL: C.UTF-8
LANG: C.UTF-8 LANG: C.UTF-8
PKG_MARKER: SNAP PKG_MARKER: SNAP
DAEMON: DISABLED
daemon: simple daemon: simple