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 <config_path>" will direct moonraker to use the supplied path for the config file. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
de34fee72a
commit
8b5ed3c9da
|
@ -3,6 +3,9 @@
|
||||||
# Raspbian/Raspberry Pi OS based distributions.
|
# Raspbian/Raspberry Pi OS based distributions.
|
||||||
|
|
||||||
PYTHONDIR="${HOME}/moonraker-env"
|
PYTHONDIR="${HOME}/moonraker-env"
|
||||||
|
REBUILD_ENV="n"
|
||||||
|
FORCE_DEFAULTS="n"
|
||||||
|
CONFIG_PATH="${HOME}/moonraker.conf"
|
||||||
|
|
||||||
# Step 1: Verify Klipper has been installed
|
# Step 1: Verify Klipper has been installed
|
||||||
check_klipper()
|
check_klipper()
|
||||||
|
@ -19,7 +22,7 @@ check_klipper()
|
||||||
# Step 2: Install packages
|
# Step 2: Install packages
|
||||||
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
|
# Update system package info
|
||||||
report_status "Running apt-get update..."
|
report_status "Running apt-get update..."
|
||||||
|
@ -33,10 +36,15 @@ install_packages()
|
||||||
# Step 3: Create python virtual environment
|
# Step 3: Create python virtual environment
|
||||||
create_virtualenv()
|
create_virtualenv()
|
||||||
{
|
{
|
||||||
report_status "Updating python virtual environment..."
|
report_status "Installing python virtual environment..."
|
||||||
|
|
||||||
# Create virtualenv if it doesn't already exist
|
# If venv exists and user prompts a rebuild, then do so
|
||||||
[ ! -d ${PYTHONDIR} ] && virtualenv -p /usr/bin/python3 ${PYTHONDIR}
|
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
|
# Install/update dependencies
|
||||||
${PYTHONDIR}/bin/pip install -r ${SRCDIR}/scripts/moonraker-requirements.txt
|
${PYTHONDIR}/bin/pip install -r ${SRCDIR}/scripts/moonraker-requirements.txt
|
||||||
|
@ -54,7 +62,7 @@ install_script()
|
||||||
install_config()
|
install_config()
|
||||||
{
|
{
|
||||||
DEFAULTS_FILE=/etc/default/moonraker
|
DEFAULTS_FILE=/etc/default/moonraker
|
||||||
[ -f $DEFAULTS_FILE ] && return
|
[ -f $DEFAULTS_FILE ] && [ $FORCE_DEFAULTS = "n" ] && return
|
||||||
|
|
||||||
report_status "Installing system start configuration..."
|
report_status "Installing system start configuration..."
|
||||||
sudo /bin/sh -c "cat > $DEFAULTS_FILE" <<EOF
|
sudo /bin/sh -c "cat > $DEFAULTS_FILE" <<EOF
|
||||||
|
@ -64,7 +72,7 @@ MOONRAKER_USER=$USER
|
||||||
|
|
||||||
MOONRAKER_EXEC=${PYTHONDIR}/bin/python
|
MOONRAKER_EXEC=${PYTHONDIR}/bin/python
|
||||||
|
|
||||||
MOONRAKER_ARGS="${SRCDIR}/moonraker/moonraker.py"
|
MOONRAKER_ARGS="${SRCDIR}/moonraker/moonraker.py -c ${CONFIG_PATH}"
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
@ -98,6 +106,15 @@ set -e
|
||||||
# Find SRCDIR from the pathname of this script
|
# Find SRCDIR from the pathname of this script
|
||||||
SRCDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/.. && pwd )"
|
SRCDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/.. && pwd )"
|
||||||
|
|
||||||
|
# Parse command line arguments
|
||||||
|
while getopts "rfc:" arg; do
|
||||||
|
case $arg in
|
||||||
|
r) REBUILD_ENV="y";;
|
||||||
|
f) FORCE_DEFAULTS="y";;
|
||||||
|
c) CONFIG_PATH=$OPTARG;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
# Run installation steps defined above
|
# Run installation steps defined above
|
||||||
verify_ready
|
verify_ready
|
||||||
check_klipper
|
check_klipper
|
||||||
|
|
Loading…
Reference in New Issue