From 683141616fa2fcbec09a4287a65484796891da8f Mon Sep 17 00:00:00 2001 From: Adnan Hodzic Date: Sat, 25 Jan 2020 17:39:17 +0100 Subject: [PATCH] fixed daemon install/removal with setup.py --- bin/auto-cpufreq | 3 --- scripts/auto-cpufreq-install.sh | 2 +- source/__init__.py | 0 source/core.py | 13 ++++++------- 4 files changed, 7 insertions(+), 11 deletions(-) create mode 100644 source/__init__.py diff --git a/bin/auto-cpufreq b/bin/auto-cpufreq index aaba36d..1a0f12a 100755 --- a/bin/auto-cpufreq +++ b/bin/auto-cpufreq @@ -36,9 +36,6 @@ 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() diff --git a/scripts/auto-cpufreq-install.sh b/scripts/auto-cpufreq-install.sh index bb586fa..5ec93b0 100755 --- a/scripts/auto-cpufreq-install.sh +++ b/scripts/auto-cpufreq-install.sh @@ -15,7 +15,7 @@ fi touch /var/log/auto-cpufreq.log echo -e "\n* Deploy auto-cpufreq systemd unit file" -cp scripts/auto-cpufreq.service /etc/systemd/system/auto-cpufreq.service +cp ../scripts/auto-cpufreq.service /etc/systemd/system/auto-cpufreq.service echo -e "\n* Reloading systemd manager configuration" systemctl daemon-reload diff --git a/source/__init__.py b/source/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/source/core.py b/source/core.py index 8d3101c..cc6261a 100644 --- a/source/core.py +++ b/source/core.py @@ -72,13 +72,13 @@ def deploy(): print("\nERROR:\nWas unable to turn off bluetooth on boot") print("\n* Deploy auto-cpufreq as system wide accessible binary") - os.system("cp auto-cpufreq.py /usr/bin/auto-cpufreq") + os.system("cp auto-cpufreq /usr/bin/auto-cpufreq") print("\n* Deploy auto-cpufreq install script") - os.system("cp scripts/auto-cpufreq-install.sh /usr/bin/auto-cpufreq-install") + os.system("cp ../scripts/auto-cpufreq-install.sh /usr/bin/auto-cpufreq-install") print("\n* Deploy auto-cpufreq remove script") - os.system("cp scripts/auto-cpufreq-remove.sh /usr/bin/auto-cpufreq-remove") + os.system("cp ../scripts/auto-cpufreq-remove.sh /usr/bin/auto-cpufreq-remove") # run auto-cpufreq daemon deploy script s.call("/usr/bin/auto-cpufreq-install", shell=True) @@ -104,6 +104,9 @@ def remove(): # run auto-cpufreq daemon install script s.call("/usr/bin/auto-cpufreq-remove", shell=True) + # remove auto-cpufreq-remove + os.remove("/usr/bin/auto-cpufreq-remove") + # check for necessary scaling governors def gov_check(): avail_gov = "/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors" @@ -365,10 +368,6 @@ 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():