From 4e4db603902a7e6ffe878645a3e162e8d6290bdc Mon Sep 17 00:00:00 2001 From: joluxer Date: Thu, 1 Aug 2024 16:20:15 +0200 Subject: [PATCH] Make installation work on Alpine Linux. Adds detection for the APK package installer and detects the OpenRC startup system. --- background_installer.sh | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/background_installer.sh b/background_installer.sh index 95df1c1..61586ae 100755 --- a/background_installer.sh +++ b/background_installer.sh @@ -54,8 +54,8 @@ function linux_install_deps { #Installing dependencies for Alpine Linux 3.20 and later elif command -v apk >/dev/null; then $1 apk update - $1 apk add build-base pkdconfig bison flex autoconf automake libtool make git sqlite cmake curl - $1 apk add python3 py3-libxml2 gcc g++ linux-headers openssl-dev + $1 apk add build-base pkgconfig bison flex autoconf automake libtool make git sqlite cmake curl + $1 apk add python3 py3-libxml2 py3-pip gcc g++ linux-headers openssl-dev util-linux-misc else fail "Unsupported linux distro." fi @@ -97,7 +97,8 @@ function install_pigpio { } function install_py_deps { - python3 -m venv "$VENV_DIR" + python3 -m venv "$VENV_DIR" --system-site-packages + source "$VENV_DIR/bin/activate" "$VENV_DIR/bin/python3" -m pip install --upgrade pip if [ "$1" == "neuron" ]; then "$VENV_DIR/bin/python3" -m pip install flask==2.2.5 werkzeug==2.2.2 flask-login==0.6.2 pyserial pymodbus==2.5.3 @@ -105,6 +106,7 @@ function install_py_deps { "$VENV_DIR/bin/python3" -m pip install flask==2.3.3 werkzeug==2.3.7 flask-login==0.6.2 pyserial pymodbus==2.5.3 fi python3 -m pip install pymodbus==2.5.3 + deactivate } function swap_on { @@ -229,9 +231,9 @@ EOF } function install_openrc_service() { - if [ "$1" == "sudo" ]; then + if [ "$(whoami)" == "root" ]; then echo "[OPENPLC SERVICE]" - $1 tee /etc/init.d/openplc > /dev/null < /dev/null <