From b0706c58f0c8e25026c459223548b8d3ced1afdd Mon Sep 17 00:00:00 2001 From: Connor Frank Date: Sat, 11 Dec 2021 23:52:08 -0500 Subject: [PATCH 1/2] openrc fix This maintains consistency with the install.sh script by using the virtualenv that the script sets up. The original version was using a different interpreter and complained about missing imports. Additionally, the new shebang now points to the correct openrc-run executable. These were the only changes needed for this script to work on Gentoo. --- openrc/throttled | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openrc/throttled b/openrc/throttled index 5551d36..d440151 100644 --- a/openrc/throttled +++ b/openrc/throttled @@ -1,5 +1,5 @@ -#!/usr/bin/openrc-run -command="env python3 /usr/lib/throttled/throttled.py" +#!/sbin/openrc-run +command="/opt/throttled/venv/bin/python3 /opt/throttled/throttled.py" pidfile=${pidfile-/var/run/throttled.pid} description="Stop Intel throttling" command_background="yes" From 883b20ec79a9908662a5b6c1eeceb4929ef5f9a8 Mon Sep 17 00:00:00 2001 From: Connor Frank Date: Sun, 30 Jan 2022 22:11:09 -0500 Subject: [PATCH 2/2] accurately identify systemd, runit, and openrc --- install.sh | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/install.sh b/install.sh index 042d5f0..d5f8c6a 100755 --- a/install.sh +++ b/install.sh @@ -3,13 +3,15 @@ LEGACY_INSTALL_DIR="/opt/lenovo_fix" 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 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 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 throttled stop >/dev/null 2>&1 fi @@ -32,15 +34,15 @@ else echo "Config file already exists, skipping" fi -if pidof systemd 2>&1 1>/dev/null; then +if [ "$INIT" == "systemd" ]; then echo "Copying systemd service file" cp systemd/throttled.service /etc/systemd/system 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" cp -R runit/throttled /etc/sv/ 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" cp -R openrc/throttled /etc/init.d/throttled rm -f /etc/init.d/lenovo_fix >/dev/null 2>&1 @@ -56,16 +58,16 @@ cd "$INSTALL_DIR" pip install wheel pip install -r requirements.txt -if pidof systemd 2>&1 1>/dev/null; then +if [ "$INIT" == "systemd" ]; then echo "Enabling and starting systemd service" systemctl daemon-reload systemctl enable 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" ln -sv /etc/sv/throttled /var/service/ sv up throttled -elif pidof openrc-init 2>&1 1>/dev/null; then +elif [ "$INIT" == "init" ]; then echo "Enabling and starting OpenRC service" rc-update add throttled default rc-service throttled start