From 8b5ed3c9daa084b19f4ffd07513b4aa231370996 Mon Sep 17 00:00:00 2001 From: Arksine Date: Mon, 2 Nov 2020 07:35:07 -0500 Subject: [PATCH] scripts: update install script Add python3-libgpiod dependency. As this dependency requiress a rebuild of the python3 environment, add some command line options to the install script: - "-r" will rebuild the virtualenv - "-f" will force overwite the defaults file. By default an existing defaults file will not be modified. - "-c " will direct moonraker to use the supplied path for the config file. Signed-off-by: Eric Callahan --- scripts/install-moonraker.sh | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/scripts/install-moonraker.sh b/scripts/install-moonraker.sh index 9b9c182..ef5c11a 100755 --- a/scripts/install-moonraker.sh +++ b/scripts/install-moonraker.sh @@ -3,6 +3,9 @@ # Raspbian/Raspberry Pi OS based distributions. PYTHONDIR="${HOME}/moonraker-env" +REBUILD_ENV="n" +FORCE_DEFAULTS="n" +CONFIG_PATH="${HOME}/moonraker.conf" # Step 1: Verify Klipper has been installed check_klipper() @@ -19,7 +22,7 @@ check_klipper() # Step 2: Install packages install_packages() { - PKGLIST="python3-virtualenv python3-dev nginx libopenjp2-7" + PKGLIST="python3-virtualenv python3-dev nginx libopenjp2-7 python3-libgpiod" # Update system package info report_status "Running apt-get update..." @@ -33,10 +36,15 @@ install_packages() # Step 3: Create python virtual environment create_virtualenv() { - report_status "Updating python virtual environment..." + report_status "Installing python virtual environment..." - # Create virtualenv if it doesn't already exist - [ ! -d ${PYTHONDIR} ] && virtualenv -p /usr/bin/python3 ${PYTHONDIR} + # If venv exists and user prompts a rebuild, then do so + if [ -d ${PYTHONDIR} ] && [ $REBUILD_ENV = "y" ]; then + report_status "Removing old virtualenv" + rm -rf ${PYTHONDIR} + fi + + [ ! -d ${PYTHONDIR} ] && virtualenv -p /usr/bin/python3 --system-site-packages ${PYTHONDIR} # Install/update dependencies ${PYTHONDIR}/bin/pip install -r ${SRCDIR}/scripts/moonraker-requirements.txt @@ -54,7 +62,7 @@ install_script() install_config() { DEFAULTS_FILE=/etc/default/moonraker - [ -f $DEFAULTS_FILE ] && return + [ -f $DEFAULTS_FILE ] && [ $FORCE_DEFAULTS = "n" ] && return report_status "Installing system start configuration..." sudo /bin/sh -c "cat > $DEFAULTS_FILE" <