daemon disabled on snap install, working install/remove
This commit is contained in:
parent
6b5fba3ac3
commit
71a8b92e04
|
@ -9,6 +9,8 @@ import sys
|
||||||
sys.path.append('../')
|
sys.path.append('../')
|
||||||
from source.core import *
|
from source.core import *
|
||||||
|
|
||||||
|
# ToD: replace every s.call with s.run
|
||||||
|
|
||||||
# cli
|
# cli
|
||||||
@click.command()
|
@click.command()
|
||||||
@click.option("--monitor", is_flag=True, help="Monitor and suggest CPU optimizations")
|
@click.option("--monitor", is_flag=True, help="Monitor and suggest CPU optimizations")
|
||||||
|
@ -29,8 +31,7 @@ def main(monitor, live, daemon, install, log):
|
||||||
footer(79)
|
footer(79)
|
||||||
else:
|
else:
|
||||||
if daemon:
|
if daemon:
|
||||||
#if os.getenv("PKG_MARKER") == "SNAP" and os.getenv("DAEMON") == "ENABLED":
|
if os.getenv("PKG_MARKER") == "SNAP" and dcheck == "enabled":
|
||||||
if os.getenv("PKG_MARKER") == "SNAP":
|
|
||||||
while True:
|
while True:
|
||||||
root_check()
|
root_check()
|
||||||
gov_check()
|
gov_check()
|
||||||
|
@ -40,6 +41,7 @@ def main(monitor, live, daemon, install, log):
|
||||||
countdown(5)
|
countdown(5)
|
||||||
subprocess.call("clear")
|
subprocess.call("clear")
|
||||||
elif os.getenv("PKG_MARKER") != "SNAP":
|
elif os.getenv("PKG_MARKER") != "SNAP":
|
||||||
|
# ToDo: disable running daemon without install (like on snap)
|
||||||
while True:
|
while True:
|
||||||
root_check()
|
root_check()
|
||||||
gov_check()
|
gov_check()
|
||||||
|
@ -49,10 +51,13 @@ def main(monitor, live, daemon, install, log):
|
||||||
countdown(5)
|
countdown(5)
|
||||||
subprocess.call("clear")
|
subprocess.call("clear")
|
||||||
else:
|
else:
|
||||||
sys.exit("Daemon non ENABLED")
|
print("\n" + "-" * 32 + " Daemon check " + "-" * 33 + "\n")
|
||||||
|
print("ERROR:\n\nDaemon not enabled, must run install first, i.e: \nsudo auto-cpufreq --install")
|
||||||
|
footer(79)
|
||||||
exit(1)
|
exit(1)
|
||||||
elif monitor:
|
elif monitor:
|
||||||
while True:
|
while True:
|
||||||
|
# ToDo: doesn't work on snap
|
||||||
running_check()
|
running_check()
|
||||||
root_check()
|
root_check()
|
||||||
gov_check()
|
gov_check()
|
||||||
|
@ -63,6 +68,7 @@ def main(monitor, live, daemon, install, log):
|
||||||
subprocess.call("clear")
|
subprocess.call("clear")
|
||||||
elif live:
|
elif live:
|
||||||
while True:
|
while True:
|
||||||
|
# ToDo: doesn't work on snap
|
||||||
running_check()
|
running_check()
|
||||||
root_check()
|
root_check()
|
||||||
gov_check()
|
gov_check()
|
||||||
|
@ -79,19 +85,20 @@ def main(monitor, live, daemon, install, log):
|
||||||
running_check()
|
running_check()
|
||||||
root_check()
|
root_check()
|
||||||
gov_check()
|
gov_check()
|
||||||
#os.environ["DAEMON"] = "ENABLED"
|
s.run("snapctl set daemon=enabled", shell=True)
|
||||||
s.run("snapctl start --enable auto-cpufreq", shell=True)
|
s.run("snapctl start --enable auto-cpufreq", shell=True)
|
||||||
|
deploy_complete_msg()
|
||||||
else:
|
else:
|
||||||
running_check()
|
running_check()
|
||||||
root_check()
|
root_check()
|
||||||
gov_check()
|
gov_check()
|
||||||
deploy()
|
deploy()
|
||||||
|
deploy_complete_msg()
|
||||||
elif remove:
|
elif remove:
|
||||||
if os.getenv('PKG_MARKER') == "SNAP":
|
if os.getenv('PKG_MARKER') == "SNAP":
|
||||||
root_check()
|
root_check()
|
||||||
#s.run("snapctl stop --disable auto-cpufreq", shell=True)
|
s.run("snapctl set daemon=disabled", shell=True)
|
||||||
s.run("snapctl stop --disable auto-cpufreq", shell=True)
|
s.run("snapctl stop --disable auto-cpufreq", shell=True)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
root_check()
|
root_check()
|
||||||
remove()
|
remove()
|
||||||
|
|
|
@ -24,11 +24,4 @@ echo -e "\n* Starting auto-cpufreq daemon (systemd) service"
|
||||||
systemctl start auto-cpufreq
|
systemctl start auto-cpufreq
|
||||||
|
|
||||||
echo -e "\n* Enabling auto-cpufreq daemon (systemd) service at boot"
|
echo -e "\n* Enabling auto-cpufreq daemon (systemd) service at boot"
|
||||||
systemctl enable auto-cpufreq
|
systemctl enable auto-cpufreq
|
||||||
|
|
||||||
echo -e "\n------------------ auto-cpufreq daemon installed and running -----------------\n"
|
|
||||||
|
|
||||||
echo -e "To view live log, run:\nauto-cpufreq --log"
|
|
||||||
echo -e "\nTo disable and remove auto-cpufreq daemon, run:\nsudo auto-cpufreq --remove"
|
|
||||||
|
|
||||||
echo -e "\n-------------------------------------------------------------------------------\n"
|
|
|
@ -37,6 +37,5 @@ 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
|
|
||||||
daemon: simple
|
daemon: simple
|
||||||
|
|
|
@ -36,6 +36,9 @@ bat_state = power.PowerManagement().get_providing_power_source_type()
|
||||||
# auto-cpufreq log file
|
# auto-cpufreq log file
|
||||||
auto_cpufreq_log_file = "/var/log/auto-cpufreq.log"
|
auto_cpufreq_log_file = "/var/log/auto-cpufreq.log"
|
||||||
|
|
||||||
|
# daemon check
|
||||||
|
dcheck = subprocess.getoutput("snapctl get daemon")
|
||||||
|
|
||||||
# deploy cpufreqctl script
|
# deploy cpufreqctl script
|
||||||
def cpufreqctl():
|
def cpufreqctl():
|
||||||
# detect if running on a SNAP
|
# detect if running on a SNAP
|
||||||
|
@ -48,9 +51,16 @@ def cpufreqctl():
|
||||||
else:
|
else:
|
||||||
os.system("cp /usr/local/share/auto-cpufreq/scripts/cpufreqctl.sh /usr/bin/cpufreqctl")
|
os.system("cp /usr/local/share/auto-cpufreq/scripts/cpufreqctl.sh /usr/bin/cpufreqctl")
|
||||||
|
|
||||||
|
# print footer func
|
||||||
def footer(l):
|
def footer(l):
|
||||||
print("\n" + "-" * l + "\n")
|
print("\n" + "-" * l + "\n")
|
||||||
|
|
||||||
|
def deploy_complete_msg():
|
||||||
|
print("\n" + "-" * 17 + " auto-cpufreq daemon installed and running " + "-" * 17 + "\n")
|
||||||
|
print("To view live log, run:\nauto-cpufreq --log")
|
||||||
|
print("\nTo disable and remove auto-cpufreq daemon, run:\nsudo auto-cpufreq --remove")
|
||||||
|
footer(79)
|
||||||
|
|
||||||
# deploy auto-cpufreq daemon
|
# deploy auto-cpufreq daemon
|
||||||
def deploy():
|
def deploy():
|
||||||
|
|
||||||
|
@ -165,12 +175,10 @@ def set_powersave():
|
||||||
elif cpuload > 50:
|
elif cpuload > 50:
|
||||||
print("High CPU load, setting turbo boost: on")
|
print("High CPU load, setting turbo boost: on")
|
||||||
s.run("echo 0 > /sys/devices/system/cpu/intel_pstate/no_turbo", shell=True)
|
s.run("echo 0 > /sys/devices/system/cpu/intel_pstate/no_turbo", shell=True)
|
||||||
#print("\n" + "-" * 60 + "\n")
|
|
||||||
footer(79)
|
footer(79)
|
||||||
else:
|
else:
|
||||||
print("Load optimal, setting turbo boost: off")
|
print("Load optimal, setting turbo boost: off")
|
||||||
s.run("echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo", shell=True)
|
s.run("echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo", shell=True)
|
||||||
#print("\n" + "-" * 60 + "\n")
|
|
||||||
footer(79)
|
footer(79)
|
||||||
|
|
||||||
# make turbo suggestions in powersave
|
# make turbo suggestions in powersave
|
||||||
|
@ -228,12 +236,10 @@ def set_performance():
|
||||||
elif cpuload > 20:
|
elif cpuload > 20:
|
||||||
print("High CPU load, setting turbo boost: on")
|
print("High CPU load, setting turbo boost: on")
|
||||||
s.run("echo 0 > /sys/devices/system/cpu/intel_pstate/no_turbo", shell=True)
|
s.run("echo 0 > /sys/devices/system/cpu/intel_pstate/no_turbo", shell=True)
|
||||||
#print("\n" + "-" * 60 + "\n")
|
|
||||||
footer(79)
|
footer(79)
|
||||||
else:
|
else:
|
||||||
print("Load optimal, setting turbo boost: off")
|
print("Load optimal, setting turbo boost: off")
|
||||||
s.run("echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo", shell=True)
|
s.run("echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo", shell=True)
|
||||||
#print("\n" + "-" * 60 + "\n")
|
|
||||||
footer(79)
|
footer(79)
|
||||||
|
|
||||||
# make turbo suggestions in performance
|
# make turbo suggestions in performance
|
||||||
|
|
Loading…
Reference in New Issue