From 232fcc38825b03debdb46f1abe7b0bf323516103 Mon Sep 17 00:00:00 2001 From: Hyper-KVM Date: Wed, 19 Feb 2020 15:57:14 -0500 Subject: [PATCH 1/8] Add OpenRC support testing --- openrc/lenovo_fix | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 openrc/lenovo_fix diff --git a/openrc/lenovo_fix b/openrc/lenovo_fix new file mode 100644 index 0000000..23b4467 --- /dev/null +++ b/openrc/lenovo_fix @@ -0,0 +1,18 @@ +#!/usr/bin/openrc-run + +command="PYTHONUNBUFFERED=1 /opt/lenovo_fix/venv/bin/python3 /opt/lenovo_fix/lenovo_fix.py" +pidfile=${pidfile-/var/run/lenovo_fix.pid} +description="Stop Intel throttling" + +start() { + ebegin "Starting Throttled daemon" + start-stop-daemon --quiet --background --start --exec $command \ + --make-pidfile --pidfile $pidfile -- "" + eend $? "Failed to start Throttled daemon" +} + +stop() { + ebegin "Stopping Throttled daemon" + start-stop-daemon --quiet --stop --pidfile $pidfile --signal QUIT + eend $? "Failed to stop Throttled daemon" +} From fbcbbb93c7de91e857d42a43bf52ccd8e701ff41 Mon Sep 17 00:00:00 2001 From: Hyper-KVM Date: Wed, 19 Feb 2020 16:15:56 -0500 Subject: [PATCH 2/8] add PKGBUILD --- package/PKGBUILD | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 package/PKGBUILD diff --git a/package/PKGBUILD b/package/PKGBUILD new file mode 100644 index 0000000..bfac13f --- /dev/null +++ b/package/PKGBUILD @@ -0,0 +1,34 @@ + +pkgname=throttled +pkgver=0.6 +pkgrel=4 +pkgdesc="Workaround for Intel throttling issues in Linux." +arch=('any') +url="https://github.com/erpalma/throttled" +license=('MIT') +depends=('python-dbus' 'python-psutil' 'python-gobject') +conflicts=('lenovo-throttling-fix-git' 'lenovo-throttling-fix') +replaces=('lenovo-throttling-fix') +backup=('etc/lenovo_fix.conf') +source=("git+https://github.com/Hyper-KVM/throttled.git#branch=openrc") +sha256sums=('SKIP') + +#prepare() { +# sed -i "s|ExecStart=.*|ExecStart=/usr/lib/$pkgname/lenovo_fix.py|" $pkgname-$pkgver/systemd/lenovo_fix.service +#} + +build() { + cd $pkgname-$pkgver + python -m compileall *.py +} + +package() { + cd throttled-$pkgver + install -Dm644 etc/lenovo_fix.conf "$pkgdir"/etc/lenovo_fix.conf + install -Dm644 systemd/lenovo_fix.service "$pkgdir"/usr/lib/systemd/system/lenovo_fix.service + install -Dm755 lenovo_fix.py "$pkgdir"/usr/lib/$pkgname/lenovo_fix.py + install -Dm755 openrc/lenovo_fix "$pkgdir/etc/init.d/lenovo_fix" + install -Dm755 mmio.py "$pkgdir"/usr/lib/$pkgname/mmio.py + cp -a __pycache__ "$pkgdir"/usr/lib/$pkgname/ + install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE +} From 9cb8537425a01e9b4a276db3508be22e84c4853f Mon Sep 17 00:00:00 2001 From: Hyper-KVM Date: Wed, 19 Feb 2020 16:21:24 -0500 Subject: [PATCH 3/8] fix PKGBUILD --- package/PKGBUILD | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package/PKGBUILD b/package/PKGBUILD index bfac13f..bf01df0 100644 --- a/package/PKGBUILD +++ b/package/PKGBUILD @@ -18,12 +18,12 @@ sha256sums=('SKIP') #} build() { - cd $pkgname-$pkgver + cd "${srcdir}/throttled/" python -m compileall *.py } package() { - cd throttled-$pkgver + cd "${srcdir}/throttled/" install -Dm644 etc/lenovo_fix.conf "$pkgdir"/etc/lenovo_fix.conf install -Dm644 systemd/lenovo_fix.service "$pkgdir"/usr/lib/systemd/system/lenovo_fix.service install -Dm755 lenovo_fix.py "$pkgdir"/usr/lib/$pkgname/lenovo_fix.py From 422769aafde952b924d06c07ffe4dfc7c4c76f4d Mon Sep 17 00:00:00 2001 From: Hyper-KVM Date: Wed, 19 Feb 2020 16:22:10 -0500 Subject: [PATCH 4/8] remove uneeded prepare function in PKGBUILD --- package/PKGBUILD | 3 --- 1 file changed, 3 deletions(-) diff --git a/package/PKGBUILD b/package/PKGBUILD index bf01df0..90f21f4 100644 --- a/package/PKGBUILD +++ b/package/PKGBUILD @@ -13,9 +13,6 @@ backup=('etc/lenovo_fix.conf') source=("git+https://github.com/Hyper-KVM/throttled.git#branch=openrc") sha256sums=('SKIP') -#prepare() { -# sed -i "s|ExecStart=.*|ExecStart=/usr/lib/$pkgname/lenovo_fix.py|" $pkgname-$pkgver/systemd/lenovo_fix.service -#} build() { cd "${srcdir}/throttled/" From c0b8c180bf83430729ffbc2ae3505d004ec388bb Mon Sep 17 00:00:00 2001 From: Hyper-KVM Date: Wed, 19 Feb 2020 16:40:52 -0500 Subject: [PATCH 5/8] fix init script --- openrc/lenovo_fix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openrc/lenovo_fix b/openrc/lenovo_fix index 23b4467..776c7c9 100644 --- a/openrc/lenovo_fix +++ b/openrc/lenovo_fix @@ -1,12 +1,12 @@ #!/usr/bin/openrc-run -command="PYTHONUNBUFFERED=1 /opt/lenovo_fix/venv/bin/python3 /opt/lenovo_fix/lenovo_fix.py" +command="env python3 /usr/lib/throttled/lenovo_fix.py" pidfile=${pidfile-/var/run/lenovo_fix.pid} description="Stop Intel throttling" start() { ebegin "Starting Throttled daemon" - start-stop-daemon --quiet --background --start --exec $command \ + start-stop-daemon --start --exec $command \ --make-pidfile --pidfile $pidfile -- "" eend $? "Failed to start Throttled daemon" } From a88689b8bb67396ee011071d1228e99a33396776 Mon Sep 17 00:00:00 2001 From: Hyper-KVM Date: Wed, 19 Feb 2020 18:48:54 -0500 Subject: [PATCH 6/8] really fix init script this time --- openrc/lenovo_fix | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/openrc/lenovo_fix b/openrc/lenovo_fix index 776c7c9..7bbbe2a 100644 --- a/openrc/lenovo_fix +++ b/openrc/lenovo_fix @@ -1,18 +1,5 @@ #!/usr/bin/openrc-run - command="env python3 /usr/lib/throttled/lenovo_fix.py" pidfile=${pidfile-/var/run/lenovo_fix.pid} description="Stop Intel throttling" - -start() { - ebegin "Starting Throttled daemon" - start-stop-daemon --start --exec $command \ - --make-pidfile --pidfile $pidfile -- "" - eend $? "Failed to start Throttled daemon" -} - -stop() { - ebegin "Stopping Throttled daemon" - start-stop-daemon --quiet --stop --pidfile $pidfile --signal QUIT - eend $? "Failed to stop Throttled daemon" -} +command_background="yes" From 5fc826aac0d59b9e90efb2807699dcd43ceba47c Mon Sep 17 00:00:00 2001 From: Hyper-KVM Date: Wed, 19 Feb 2020 20:03:44 -0500 Subject: [PATCH 7/8] Add OpenRC support in install.sh --- install.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/install.sh b/install.sh index 2ff623d..871d903 100755 --- a/install.sh +++ b/install.sh @@ -6,6 +6,8 @@ if pidof systemd 2>&1 1>/dev/null; then systemctl stop lenovo_fix.service >/dev/null 2>&1 elif pidof runit 2>&1 1>/dev/null; then sv down lenovo_fix >/dev/null 2>&1 +elif pidof openrc 2>&1 1>/dev/null; then + rc-service lenovo_fix stop >/dev/null 2>&1 fi mkdir -p "$INSTALL_DIR" >/dev/null 2>&1 @@ -26,6 +28,10 @@ if pidof systemd 2>&1 1>/dev/null; then elif pidof runit 2>&1 1>/dev/null; then echo "Copying runit service file" cp -R runit/lenovo_fix /etc/sv/ +elif pidof openrc-init 2>&1 1>/dev/null; then + echo "Copying OpenRC service file" + cp -R openrc/lenovo_fix /etc/init.d/lenovo_fix + chmod 755 /etc/init.d/lenovo_fix fi echo "Building virtualenv..." @@ -44,6 +50,10 @@ elif pidof runit 2>&1 1>/dev/null; then echo "Enabling and starting runit service..." ln -sv /etc/sv/lenovo_fix /var/service/ sv up lenovo_fix +elif pidof openrc-init 2>&1 1>/dev/null; then + echo "Enabling and starting OpenRC service..." + rc-update add lenovo_fix default + rc-service lenovo_fix start fi echo "All done." From 8300044558c5415b0591d102ea8d47bf6d4326ef Mon Sep 17 00:00:00 2001 From: Hyper-KVM Date: Thu, 20 Feb 2020 01:32:47 -0500 Subject: [PATCH 8/8] Add Artix and OpenRC entries --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index f5fc96c..4d5a718 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,13 @@ sudo systemctl enable --now lenovo_fix.service ``` Thanks to *felixonmars* for creating and maintaining this package. +### Artix Linux +``` +makepkg -si +sudo rc-update add lenovo_fix default +sudo rc-service lenovo_fix start +``` + ### Debian/Ubuntu ``` sudo apt install git build-essential python3-dev libdbus-glib-1-dev libgirepository1.0-dev libcairo2-dev python3-venv python3-wheel @@ -130,6 +137,12 @@ sv down lenovo_fix rm /var/service/lenovo_fix ``` +If you're using OpenRC instead of systemd: +``` +rc-service lenovo_fix stop +rc-update del lenovo_fix default +``` + If you also need to remove the tool from the system: ``` rm -rf /opt/lenovo_fix /etc/systemd/system/lenovo_fix.service @@ -145,6 +158,7 @@ cd lenovo-throttling-fix git pull sudo ./install.sh sudo systemctl restart lenovo_fix.service +OpenRC: sudo rc-service lenovo_fix restart ``` ## Configuration