-
-
Notifications
You must be signed in to change notification settings - Fork 332
improve installer script #889
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
auto-cpufreq-installer
Outdated
| if [ -f $srv_remove -o -f $AUTO_CPUFREQ_FILE ]; then | ||
| eval "$AUTO_CPUFREQ_FILE --remove" | ||
| if [[ -f "$srv_remove" || -f "$AUTO_CPUFREQ_FILE" ]]; then | ||
| "$AUTO_CPUFREQ_FILE" --remove || exit 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this ok? Unsure if $AUTO_CPUFREQ_FILE" --remove is allowed to exit non-zero in normal operation or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing eval makes sense in this case. But potential problem is that if $AUTO_CPUFREQ_FILE --remove returns a non-zero exit code when the daemon isn't installed, script will prematurely exit with an error, even though the desired final state (daemon removed) has been achieved.
Maybe it would make sense to log it while allowing the removal command to fail silently (which is often acceptable for removal steps), with something like:
if [[ -f "$srv_remove" || -f "$AUTO_CPUFREQ_FILE" ]]; then
"$AUTO_CPUFREQ_FILE" --remove || echo "\nWARNING: Removal of auto-cpufreq binary failed (exit status $?).\n Continuing ..." >&2
fi
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry to nitpick, but I think this might confuse some users now, as in case auto-cpufreq daemon is installed and you simply run sudo ./auto-cpufreq-installer --remove it's all clear when it comes to messaging.
But if daemon is not installed and you run sudo ./auto-cpufreq-installer --remove, output can be bit confusing:
auto-cpufreq daemon is not installed.
WARNING: Removal of auto-cpufreq binary failed (exit status 1).
Continuing...
auto-cpufreq tool and all its supporting files successfully removed
As Removal of auto-cpufreq binary failed ... it didn't fail, it just wasn't there at this point ... and this is indicated as part of previous message, so maybe good to remove:
Continuing...
after all.
Regarding whole block:
# run uninstall in case of installed daemon
if [[ -f "$srv_remove" || -f "$AUTO_CPUFREQ_FILE" ]]; then
"$AUTO_CPUFREQ_FILE" --remove || echo -e "\nWARNING: Removal of auto-cpufreq binary failed (exit status $?).\n Continuing..." >&2
else
echo; echo "Couldn't remove the auto-cpufreq daemon, [$srv_remove] does not exist."
fi
Basically else echo; echo "Couldn't remove the auto-cpufreq daemon, [$srv_remove] does not exist." is confusing and potentially misleading. The if check uses two files ($srv_remove or $AUTO_CPUFREQ_FILE), but the else message only mentions $srv_remove not existing. This message is only accurate if the if statement failed because $srv_remove didn't exist AND $AUTO_CPUFREQ_FILE also didn't exist. The message should ideally reflect the combined condition failure or be more generic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess copilot was kind of referring to same thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well that was the very reason that place got flagged -- I'm not familiar with the intricacies of $AUTO_CPUFREQ_FILE itself and would like some guidance/help there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AUTO_CPUFREQ_FILE is simply a auto-cpufreq binary, placed on that location after ./auto-cpufreq-installer --install. After which you can run install or live, etc ...
When it comes to srv_remove and what I see on master branch, this change was introduced with with #695, a refactor attempt I should've payed more attention during review and probably shouldn't have merged.
But before this change, srv_remove pointed to srv_remove="/usr/local/bin/auto-cpufreq-remove"..
I can't remember what was the case here, but I think this was because these were 2 different scripts (before they were merged into single install script with parameters), one for removal and other for install:
So I think this variable can even be removed now, as it doesn't point to anything. After auto-cpufreq is installed with auto-cpufreq-installer it'll only have 2 binaries in /usr/local/bin/
- auto-cpufreq
- auto-cpufreq-gtk
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR modernizes the auto-cpufreq-installer bash script by improving code quality, consistency, and error handling. The changes focus on adopting bash best practices, improving script robustness, and ensuring proper error propagation throughout the installation and removal processes.
Key changes:
- Standardized quoting of variables and updated syntax to modern bash conventions (e.g.,
[[over[) - Added
set -o pipefailand|| exit 1error handling to fail fast on command failures - Replaced tabs with spaces and corrected variable names (COLOUMNS → COLUMNS)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "$AUTO_CPUFREQ_FILE" --remove || exit 1 | ||
| else | ||
| echo; echo "Couldn't remove the auto-cpufreq daemon, $srv_remove do not exist." | ||
| echo; echo "Couldn't remove the auto-cpufreq daemon, [$srv_remove] does not exist." |
Copilot
AI
Oct 25, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message is misleading. It suggests that $srv_remove doesn't exist, but the condition on line 223 checks for the existence of either $srv_remove OR $AUTO_CPUFREQ_FILE. Consider clarifying: "Couldn't remove the auto-cpufreq daemon, required files do not exist."
| echo; echo "Couldn't remove the auto-cpufreq daemon, [$srv_remove] does not exist." | |
| echo; echo "Couldn't remove the auto-cpufreq daemon, required files do not exist." |
|
@laur89 also please check the Copilot suggestions. |
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Uh oh!
There was an error while loading. Please reload this page.