From 7b5142bd021d4f78bb188b5d364182c0e61a81ce Mon Sep 17 00:00:00 2001 From: Adnan Hodzic Date: Tue, 31 Dec 2019 11:48:27 +0100 Subject: [PATCH] added daemon deploy script + its deployment mechanism --- auto-cpufreq.py | 18 ++++++++++++++++-- daemon-deploy.sh | 20 ++++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) create mode 100755 daemon-deploy.sh diff --git a/auto-cpufreq.py b/auto-cpufreq.py index 58886ef..037787d 100644 --- a/auto-cpufreq.py +++ b/auto-cpufreq.py @@ -27,6 +27,12 @@ p = psutil s = subprocess tool_run = "python3 auto-cpufreq.py" +# deploy auto-cpufreq daemon scrip +def daemon_deploy(): + + # ToDo: add check if file exists, skip + os.system('cp daemon-deploy.sh /usr/bin/auto-cpufreq') + def footer(l): print("\n" + "-" * l + "\n") @@ -66,7 +72,7 @@ def countdown(s): sys.stdout.flush() time.sleep(1) - sys.stdout.write("\rRefreshing ... \n") + #sys.stdout.write("\rRefreshing ... \n") # set powersave def set_powersave(): @@ -190,7 +196,15 @@ def cli(live, daemon): #time.sleep(1) subprocess.call("clear") elif daemon: - print("daemon ...") + while True: + print("daemon ...") + daemon_deploy() + root_check() + driver_check() + gov_check() + sysinfo() + autofreq() + countdown(15) else: print("remove ...") diff --git a/daemon-deploy.sh b/daemon-deploy.sh new file mode 100755 index 0000000..612be34 --- /dev/null +++ b/daemon-deploy.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +# +# auto-cpufreq daemon script +# reference: https://github.com/AdnanHodzic/auto-cpufreq + +if (( $EUID != 0 )); +then + echo -e "\nERROR\nMust be run as root (i.e: 'sudo $0')." + exit 1 +fi + +logs_file="/var/log/auto-cpufreq.log" + +python3 auto-cpufreq.py --live > $logs_file 2>&1 & + +echo -e "\n------------------------ auto-cpufreq -----------------------------\n" +echo -e "auto-cpufreq daemon started and running in background." +echo -e "\nLogs are available in:\n$logs_file" +echo -e "\nView live logs by running i.e: \ntail -n 50 -f $logs_file" +echo -e "\n-------------------------------------------------------------------\n"