Merge pull request #105 from moinmoi/master

added void/runit support
This commit is contained in:
Francesco Palmarini
2019-03-06 09:18:31 +01:00
committed by GitHub
3 changed files with 43 additions and 7 deletions

View File

@@ -91,12 +91,31 @@ systemctl enable throttled.service
systemctl start throttled.service systemctl start throttled.service
``` ```
### Void
The installation itself will create a runit service as lenovo_fix, enable it and start it. Before installation, make sure dbus is running `sv up dbus`.
```
sudo xbps-install -Sy gcc git python3-devel dbus-glib-devel libgirepository-devel cairo-devel python3-wheel pkg-config make
git clone https://github.com/erpalma/lenovo-throttling-fix.git
sudo ./lenovo-throttling-fix/install.sh
```
### Uninstall ### Uninstall
To permanently stop and disable the execution just issue: To permanently stop and disable the execution just issue:
``` ```
systemctl stop lenovo_fix.service systemctl stop lenovo_fix.service
systemctl disable lenovo_fix.service systemctl disable lenovo_fix.service
``` ```
If you're running runit instead of systemd:
```
sv down lenovo_fix
rm /var/service/lenovo_fix
```
If you also need to remove the tool from the system: If you also need to remove the tool from the system:
``` ```
rm -rf /opt/lenovo_fix /etc/systemd/system/lenovo_fix.service rm -rf /opt/lenovo_fix /etc/systemd/system/lenovo_fix.service

View File

@@ -2,7 +2,11 @@
INSTALL_DIR="/opt/lenovo_fix" INSTALL_DIR="/opt/lenovo_fix"
systemctl stop lenovo_fix.service &>/dev/null if pidof systemd 2>&1 1>/dev/null; then
systemctl stop lenovo_fix.service &>/dev/null
elif pidof runit 2>&1 1>/dev/null; then
sv down lenovo_fix &>/dev/null
fi
mkdir -p "$INSTALL_DIR" &>/dev/null mkdir -p "$INSTALL_DIR" &>/dev/null
set -e set -e
@@ -16,8 +20,13 @@ else
echo "Config file already exists, skipping." echo "Config file already exists, skipping."
fi fi
echo "Copying systemd service file..." if pidof systemd 2>&1 1>/dev/null; then
cp systemd/lenovo_fix.service /etc/systemd/system echo "Copying systemd service file..."
cp systemd/lenovo_fix.service /etc/systemd/system
elif pidof runit 2>&1 1>/dev/null; then
echo "Copying runit service file"
cp -R runit/lenovo_fix /etc/sv/
fi
echo "Building virtualenv..." echo "Building virtualenv..."
cp -n requirements.txt lenovo_fix.py mmio.py "$INSTALL_DIR" cp -n requirements.txt lenovo_fix.py mmio.py "$INSTALL_DIR"
@@ -26,9 +35,15 @@ cd "$INSTALL_DIR"
. venv/bin/activate . venv/bin/activate
pip install -r requirements.txt pip install -r requirements.txt
echo "Enabling and starting systemd service..." if pidof systemd 2>&1 1>/dev/null; then
systemctl daemon-reload echo "Enabling and starting systemd service..."
systemctl enable lenovo_fix.service systemctl daemon-reload
systemctl restart lenovo_fix.service systemctl enable lenovo_fix.service
systemctl restart lenovo_fix.service
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
fi
echo "All done." echo "All done."

2
runit/lenovo_fix/run Executable file
View File

@@ -0,0 +1,2 @@
#!/bin/sh
PYTHONUNBUFFERED=1 exec /opt/lenovo_fix/venv/bin/python3 /opt/lenovo_fix/lenovo_fix.py