code refinement (working systemd) without logs

This commit is contained in:
Adnan Hodzic 2020-01-02 23:30:29 +01:00
parent 324b59a8da
commit 45071a1493
4 changed files with 14 additions and 11 deletions

View File

@ -88,7 +88,7 @@ def deploy():
s.call("/usr/bin/auto-cpufreq-daemon", shell=True) s.call("/usr/bin/auto-cpufreq-daemon", shell=True)
print("auto-cpufreq daemon started and will automatically start at boot time.") print("auto-cpufreq daemon started and will automatically start at boot time.")
print("\nTo disable and remove auto-cpufreq daemon, run:\nauto-cpufreq --remove") print("\nTo disable and remove auto-cpufreq daemon, run:\nsudo auto-cpufreq --remove")
print("\nTo view live auto-cpufreq daemon logs, run:\nauto-cpufreq --log") print("\nTo view live auto-cpufreq daemon logs, run:\nauto-cpufreq --log")
footer(79) footer(79)
@ -99,6 +99,9 @@ def remove():
print("\n" + "-" * 21 + " Removing auto-cpufreq daemon " + "-" * 22 + "\n") print("\n" + "-" * 21 + " Removing auto-cpufreq daemon " + "-" * 22 + "\n")
# delete /var/log/auto-cpufreq.log if it exists # delete /var/log/auto-cpufreq.log if it exists
#if os.path.exists(auto_cpufreq_log_file):
# os.remove(auto_cpufreq_log_file)
# delete /var/log/auto-cpufreq.log file
os.remove(auto_cpufreq_log_file) os.remove(auto_cpufreq_log_file)
print("* Turn on bluetooth on boot") print("* Turn on bluetooth on boot")
@ -120,7 +123,7 @@ def remove():
# run auto-cpufreq daemon deploy script # run auto-cpufreq daemon deploy script
s.call("/usr/bin/auto-cpufreq-remove", shell=True) s.call("/usr/bin/auto-cpufreq-remove", shell=True)
if os.path.isfile("/usr/bin/cpufreqctl"): if os.path.isfile("/lib/systemd/system/auto-cpufreq.service"):
print("\n* Remove auto-cpufreq systemd unit file") print("\n* Remove auto-cpufreq systemd unit file")
os.remove("/lib/systemd/system/auto-cpufreq.service") os.remove("/lib/systemd/system/auto-cpufreq.service")
@ -237,7 +240,7 @@ def set_performance():
print("Total system load:", load1m, "\n") print("Total system load:", load1m, "\n")
print("Setting turbo boost: on") print("Setting turbo boost: on")
s.run("echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo", shell=True) s.run("echo 0 > /sys/devices/system/cpu/intel_pstate/no_turbo", shell=True)
footer(79) footer(79)
# make turbo suggestions in performance # make turbo suggestions in performance
@ -379,7 +382,7 @@ def log_check():
print("\n" + "-" * 30 + " auto-cpufreq log " + "-" * 31 + "\n") print("\n" + "-" * 30 + " auto-cpufreq log " + "-" * 31 + "\n")
print("ERROR: prevention from running multiple instances.") print("ERROR: prevention from running multiple instances.")
print("\nIt seems like auto-cpufreq daemon is already running in background.\n\nTo view live log run:\nauto-cpufreq --log") print("\nIt seems like auto-cpufreq daemon is already running in background.\n\nTo view live log run:\nauto-cpufreq --log")
print("\nTo disable and remove auto-cpufreq daemon, run:\nauto-cpufreq --remove") print("\nTo disable and remove auto-cpufreq daemon, run:\nsudo auto-cpufreq --remove")
footer(79) footer(79)
sys.exit() sys.exit()

View File

@ -25,7 +25,7 @@ systemctl start auto-cpufreq
echo -e "\n* Enabling auto-cpufreq systemd service at boot" echo -e "\n* Enabling auto-cpufreq systemd service at boot"
systemctl enable auto-cpufreq systemctl enable auto-cpufreq
echo -e "\n* Starting auto-cpufreq systemd service" echo -e "\n* Running auto-cpufreq binary"
/usr/bin/python3 /usr/bin/auto-cpufreq --live > $logs_file 2>&1 & #/usr/bin/python3 /usr/bin/auto-cpufreq --live > $logs_file 2>&1 &
echo -e "\n------\n" echo -e "\n------\n"

View File

@ -11,8 +11,6 @@ then
exit 1 exit 1
fi fi
logs_file="/var/log/auto-cpufreq.log"
echo -e "\n* Disabling auto-cpufreq systemd service at boot" echo -e "\n* Disabling auto-cpufreq systemd service at boot"
systemctl disable auto-cpufreq systemctl disable auto-cpufreq

View File

@ -1,11 +1,13 @@
[Unit] [Unit]
Description=auto-cpufreq - TBU description Description=auto-cpufreq - Automatic CPU speed & power optimizer for Linux
After=network.target network-online.target After=network.target network-online.target
[Service] [Service]
Type=simple Type=simple
User=root User=root
ExecStart=/bin/bash /usr/bin/auto-cpufreq-daemon #ExecStart=/bin/bash /usr/bin/auto-cpufreq-daemon
# ToDo: new script which just starts auto-cpufreq (no systemd)
ExecStart=/usr/bin/python3 /usr/bin/auto-cpufreq --live
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target