Skip to content

Commit

Permalink
Fix for auto-cpufreq-installer regression in #460 (#462)
Browse files Browse the repository at this point in the history
* Added an error message when the file isn't found

* $srv_install and $srv_remove are now at new locations
Created _old variables to keep track of old locations

* Added exit statement and specified daemon not removed

* Fixed some errors
  • Loading branch information
abvee committed Nov 30, 2022
1 parent 70c58fb commit 13edca0
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions auto-cpufreq-installer
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,22 @@ fi
function tool_remove {
files="files.txt"
share_dir="/usr/local/share/auto-cpufreq/"
srv_install="/usr/bin/auto-cpufreq-install"
srv_remove="/usr/bin/auto-cpufreq-remove"

srv_install="/usr/local/bin/auto-cpufreq-install"
srv_install_old="/usr/bin/auto-cpufreq-install"

srv_remove="/usr/local/bin/auto-cpufreq-remove"
srv_remove_old="/usr/bin/auto-cpufreq-remove"

stats_file="/var/run/auto-cpufreq.stats"

tool_proc_rm="/usr/local/bin/auto-cpufreq --remove"
wrapper_script="/usr/local/bin/auto-cpufreq"
unit_file="/etc/systemd/system/auto-cpufreq.service"
venv_path="/opt/auto-cpufreq"
cpufreqctl="/usr/bin/cpufreqctl.auto-cpufreq"

cpufreqctl="/usr/local/bin/cpufreqctl.auto-cpufreq"
cpufreqctl_old="/usr/bin/cpufreqctl.auto-cpufreq"

# stop any running auto-cpufreq argument (daemon/live/monitor)
tool_arg_pids=($(pgrep -f "auto-cpufreq --"))
Expand All @@ -181,8 +189,13 @@ function tool_remove {
done

# run uninstall in case of installed daemon
if [ -f $srv_remove ]; then
if [ -f $srv_remove -o -f $srv_remove_old ]; then
eval $tool_proc_rm
else
separator
printf "Couldn't remove the auto-cpufreq daemon\n$srv_remove or $srv_remove_old do not exist.\n"
exit 1;
separator
fi

# remove auto-cpufreq and all its supporting files
Expand All @@ -191,11 +204,17 @@ function tool_remove {

# files cleanup
[ -f $srv_install ] && rm $srv_install
[ -f $srv_install_old ] && rm $srv_install_old

[ -f $srv_remove ] && rm $srv_remove
[ -f $srv_remove_old ] && rm $srv_remove_old

[ -f $stats_file ] && rm $stats_file
[ -f $unit_file ] && rm $unit_file
[ -f $wrapper_script ] && rm $wrapper_script

[ -f $cpufreqctl ] && rm $cpufreqctl
[ -f $cpufreqctl_old ] && rm $cpufreqctl_old

# remove python virtual environment
rm -rf "${venv_path}"
Expand Down

0 comments on commit 13edca0

Please sign in to comment.