added daemon deploy script + its deployment mechanism

This commit is contained in:
Adnan Hodzic 2019-12-31 11:48:27 +01:00
parent 2a9ecdc2d2
commit 7b5142bd02
2 changed files with 36 additions and 2 deletions

View File

@ -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 ...")

20
daemon-deploy.sh Executable file
View File

@ -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"