Support for openrc (#314)

* Added support for openrc.

* Added main script from upstream.

* Added thankyou note.
This commit is contained in:
AdwaitAdk 2021-12-18 19:00:02 +00:00 committed by GitHub
parent aab79ca845
commit 00eca65c82
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 4 deletions

12
scripts/auto-cpufreq Normal file
View File

@ -0,0 +1,12 @@
#!/sbin/openrc-run
name=$RC_SVCNAME
description="auto-cpufreq - Automatic CPU speed & power optimizer for Linux"
supervisor="supervise-daemon"
command="/usr/bin/auto-cpufreq"
command_args="--daemon"
command_user="root"
depend() {
after net
}

View File

@ -2,7 +2,7 @@
#
# auto-cpufreq daemon install script
# reference: https://github.com/AdnanHodzic/auto-cpufreq
# Thanks to https://github.com/errornonamer for openrc fix
echo -e "\n------------------ Running auto-cpufreq daemon install script ------------------"
if [[ $EUID != 0 ]];
@ -50,8 +50,6 @@ if [ "$(ps h -o comm 1)" = "runit" ];then
*)
echo -e "\n* Runit init detected but your distro is not supported\n"
echo -e "\n* Please open an issue on https://github.com/AdnanHodzic/auto-cpufreq\n"
esac
fi
# Install script for systemd
@ -70,6 +68,17 @@ elif [ "$(ps h -o comm 1)" = "systemd" ];then
echo -e "\n* Enabling auto-cpufreq daemon (systemd) service at boot"
systemctl enable auto-cpufreq
# Install script for openrc
elif [ "$(ps h -o comm 1)" = "init" ];then
echo -e "\n* Deploying auto-cpufreq openrc unit file"
cp /usr/local/share/auto-cpufreq/scripts/auto-cpufreq /etc/init.d/auto-cpufreq
chmod +x /etc/init.d/auto-cpufreq
echo -e "Starting auto-cpufreq daemon (openrc) service"
rc-service auto-cpufreq start
echo -e "\n* Enabling auto-cpufreq daemon (openrc) service at boot"
rc-update add auto-cpufreq
else
echo -e "\n* Unsupported init system detected, could not install the daemon\n"
echo -e "\n* Please open an issue on https://github.com/AdnanHodzic/auto-cpufreq\n"

View File

@ -2,6 +2,7 @@
#
# auto-cpufreq daemon removal script
# reference: https://github.com/AdnanHodzic/auto-cpufreq
# Thanks to https://github.com/errornonamer for openrc fix
echo -e "\n------------------ Running auto-cpufreq daemon removal script ------------------"
@ -10,7 +11,6 @@ if [[ $EUID != 0 ]]; then
exit 1
fi
# First argument is the "sv" path, second argument is the "service" path
rm_sv() {
echo -e "\n* Stopping auto-cpufreq daemon (runit) service"
@ -52,6 +52,15 @@ elif [ "$(ps h -o comm 1)" = "systemd" ];then
echo -e "reset failed"
systemctl reset-failed
elif [ "$(ps h -o comm 1)" = "init" ];then
echo -e "\n* Stopping auto-cpufreq daemon (openrc) service"
rc-service auto-cpufreq stop
echo -e "\n* Disabling auto-cpufreq daemon (openrc) at boot"
rc-update del auto-cpufreq
echo -e "\n* Removing auto-cpufreq daemon (openrc) unit file"
rm /etc/init.d/auto-cpufreq
else
echo -e "\n* Unsupported init system detected, could not remove the daemon\n"
echo -e "\n* Please open an issue on https://github.com/AdnanHodzic/auto-cpufreq\n"