working daemon as part of snap (dirty)

This commit is contained in:
Adnan Hodzic 2020-01-24 15:53:25 +01:00
parent 9f1bbc1778
commit efabcab056
4 changed files with 27 additions and 1 deletions

View File

@ -36,6 +36,9 @@ def main(monitor, live, daemon, install, log):
if daemon:
while True:
root_check()
# this is needed on SELinux enabled systems (see also ConditionPathExists in .service)
#create_log()
# ToDo: unless daemon invoked from snap fail
gov_check()
cpufreqctl()
sysinfo()
@ -63,6 +66,7 @@ def main(monitor, live, daemon, install, log):
countdown(5)
subprocess.call("clear")
elif log:
# ToDo: fail if log is missing or empty (on)
read_log()
elif install:
running_check()

3
scripts/daemon.sh Executable file
View File

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

View File

@ -32,10 +32,25 @@ 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
environment:
LC_ALL: C.UTF-8
LANG: C.UTF-8
PKG_MARKER: SNAP
PKG_MARKER: SNAP
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: simple

View File

@ -365,6 +365,10 @@ def read_log():
print("ERROR: auto-cpufreq log is missing.\n\nMake sure to run: \"python3 auto-cpufreq.py --install\" first")
footer(79)
# create log func
def creat_log():
open("/var/log/auto-cpufreq.log", "a").close()
def running_check():
daemon_marker = False
for proc in p.process_iter():