mirror of
https://github.com/erpalma/throttled.git
synced 2025-12-06 07:01:59 +01:00
accurately identify systemd, runit, and openrc
This commit is contained in:
parent
c914897d3d
commit
883b20ec79
20
install.sh
20
install.sh
|
|
@ -3,13 +3,15 @@
|
||||||
LEGACY_INSTALL_DIR="/opt/lenovo_fix"
|
LEGACY_INSTALL_DIR="/opt/lenovo_fix"
|
||||||
INSTALL_DIR="/opt/throttled"
|
INSTALL_DIR="/opt/throttled"
|
||||||
|
|
||||||
if pidof systemd 2>&1 1>/dev/null; then
|
INIT="$(ps --no-headers -o comm 1)"
|
||||||
|
|
||||||
|
if [ "$INIT" == "systemd" ]; then
|
||||||
systemctl stop lenovo_fix.service >/dev/null 2>&1
|
systemctl stop lenovo_fix.service >/dev/null 2>&1
|
||||||
systemctl stop throttled.service >/dev/null 2>&1
|
systemctl stop throttled.service >/dev/null 2>&1
|
||||||
elif pidof runit 2>&1 1>/dev/null; then
|
elif [ "$INIT" == "runit" ]; then
|
||||||
sv down lenovo_fix >/dev/null 2>&1
|
sv down lenovo_fix >/dev/null 2>&1
|
||||||
sv down throttled >/dev/null 2>&1
|
sv down throttled >/dev/null 2>&1
|
||||||
elif pidof openrc 2>&1 1>/dev/null; then
|
elif [ "$INIT" == "init" ]; then
|
||||||
rc-service lenovo_fix stop >/dev/null 2>&1
|
rc-service lenovo_fix stop >/dev/null 2>&1
|
||||||
rc-service throttled stop >/dev/null 2>&1
|
rc-service throttled stop >/dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
|
|
@ -32,15 +34,15 @@ else
|
||||||
echo "Config file already exists, skipping"
|
echo "Config file already exists, skipping"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if pidof systemd 2>&1 1>/dev/null; then
|
if [ "$INIT" == "systemd" ]; then
|
||||||
echo "Copying systemd service file"
|
echo "Copying systemd service file"
|
||||||
cp systemd/throttled.service /etc/systemd/system
|
cp systemd/throttled.service /etc/systemd/system
|
||||||
rm -f /etc/systemd/system/lenovo_fix.service >/dev/null 2>&1
|
rm -f /etc/systemd/system/lenovo_fix.service >/dev/null 2>&1
|
||||||
elif pidof runit 2>&1 1>/dev/null; then
|
elif [ "$INIT" == "runit" ]; then
|
||||||
echo "Copying runit service file"
|
echo "Copying runit service file"
|
||||||
cp -R runit/throttled /etc/sv/
|
cp -R runit/throttled /etc/sv/
|
||||||
rm -r /etc/sv/lenovo_fix >/dev/null 2>&1
|
rm -r /etc/sv/lenovo_fix >/dev/null 2>&1
|
||||||
elif pidof openrc-init 2>&1 1>/dev/null; then
|
elif [ "$INIT" == "init" ]; then
|
||||||
echo "Copying OpenRC service file"
|
echo "Copying OpenRC service file"
|
||||||
cp -R openrc/throttled /etc/init.d/throttled
|
cp -R openrc/throttled /etc/init.d/throttled
|
||||||
rm -f /etc/init.d/lenovo_fix >/dev/null 2>&1
|
rm -f /etc/init.d/lenovo_fix >/dev/null 2>&1
|
||||||
|
|
@ -56,16 +58,16 @@ cd "$INSTALL_DIR"
|
||||||
pip install wheel
|
pip install wheel
|
||||||
pip install -r requirements.txt
|
pip install -r requirements.txt
|
||||||
|
|
||||||
if pidof systemd 2>&1 1>/dev/null; then
|
if [ "$INIT" == "systemd" ]; then
|
||||||
echo "Enabling and starting systemd service"
|
echo "Enabling and starting systemd service"
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
systemctl enable throttled.service
|
systemctl enable throttled.service
|
||||||
systemctl restart throttled.service
|
systemctl restart throttled.service
|
||||||
elif pidof runit 2>&1 1>/dev/null; then
|
elif [ "$INIT" == "runit" ]; then
|
||||||
echo "Enabling and starting runit service"
|
echo "Enabling and starting runit service"
|
||||||
ln -sv /etc/sv/throttled /var/service/
|
ln -sv /etc/sv/throttled /var/service/
|
||||||
sv up throttled
|
sv up throttled
|
||||||
elif pidof openrc-init 2>&1 1>/dev/null; then
|
elif [ "$INIT" == "init" ]; then
|
||||||
echo "Enabling and starting OpenRC service"
|
echo "Enabling and starting OpenRC service"
|
||||||
rc-update add throttled default
|
rc-update add throttled default
|
||||||
rc-service throttled start
|
rc-service throttled start
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue