2018-04-20 10:46:00 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
|
|
INSTALL_DIR="/opt/lenovo_fix"
|
|
|
|
|
|
2019-03-05 22:50:43 +01:00
|
|
|
if pidof systemd 2>&1 1>/dev/null; then
|
2019-07-12 09:54:06 +02:00
|
|
|
systemctl stop lenovo_fix.service >/dev/null 2>&1
|
2019-03-05 22:50:43 +01:00
|
|
|
elif pidof runit 2>&1 1>/dev/null; then
|
2019-07-12 09:54:06 +02:00
|
|
|
sv down lenovo_fix >/dev/null 2>&1
|
2020-02-20 02:03:44 +01:00
|
|
|
elif pidof openrc 2>&1 1>/dev/null; then
|
|
|
|
|
rc-service lenovo_fix stop >/dev/null 2>&1
|
2019-03-05 22:50:43 +01:00
|
|
|
fi
|
2018-04-20 10:46:00 +02:00
|
|
|
|
2019-07-12 09:54:06 +02:00
|
|
|
mkdir -p "$INSTALL_DIR" >/dev/null 2>&1
|
2018-04-20 10:46:00 +02:00
|
|
|
set -e
|
|
|
|
|
|
|
|
|
|
cd "$(dirname "$0")"
|
|
|
|
|
|
|
|
|
|
echo "Copying config file..."
|
|
|
|
|
if [ ! -f /etc/lenovo_fix.conf ]; then
|
|
|
|
|
cp etc/lenovo_fix.conf /etc
|
|
|
|
|
else
|
|
|
|
|
echo "Config file already exists, skipping."
|
|
|
|
|
fi
|
|
|
|
|
|
2019-03-05 22:50:43 +01:00
|
|
|
if pidof systemd 2>&1 1>/dev/null; then
|
|
|
|
|
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/
|
2020-02-20 02:03:44 +01:00
|
|
|
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
|
2019-03-05 22:50:43 +01:00
|
|
|
fi
|
2018-04-20 10:46:00 +02:00
|
|
|
|
|
|
|
|
echo "Building virtualenv..."
|
2018-10-31 13:57:45 +01:00
|
|
|
cp -n requirements.txt lenovo_fix.py mmio.py "$INSTALL_DIR"
|
2018-04-20 10:46:00 +02:00
|
|
|
cd "$INSTALL_DIR"
|
2018-10-19 19:48:11 +02:00
|
|
|
/usr/bin/python3 -m venv venv
|
2018-04-23 14:22:19 +02:00
|
|
|
. venv/bin/activate
|
2020-07-10 07:58:26 +02:00
|
|
|
pip install wheel
|
2018-04-20 10:46:00 +02:00
|
|
|
pip install -r requirements.txt
|
|
|
|
|
|
2019-03-05 22:50:43 +01:00
|
|
|
if pidof systemd 2>&1 1>/dev/null; then
|
|
|
|
|
echo "Enabling and starting systemd service..."
|
|
|
|
|
systemctl daemon-reload
|
|
|
|
|
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
|
2020-02-20 02:03:44 +01:00
|
|
|
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
|
2019-03-05 22:50:43 +01:00
|
|
|
fi
|
2018-04-20 10:46:00 +02:00
|
|
|
|
|
|
|
|
echo "All done."
|