From ec805aee2e1d1376f3f015116575369f44e5ad90 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Thu, 20 Apr 2017 12:30:15 -0400 Subject: scripts: Add octopi installation scripts Add a system startup script so that Klipper can automatically start at boot time. Create an installation script that will install the system dependencies and the startup script. Signed-off-by: Kevin O'Connor --- scripts/install-octopi.sh | 102 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100755 scripts/install-octopi.sh (limited to 'scripts/install-octopi.sh') diff --git a/scripts/install-octopi.sh b/scripts/install-octopi.sh new file mode 100755 index 00000000..024e83aa --- /dev/null +++ b/scripts/install-octopi.sh @@ -0,0 +1,102 @@ +#!/bin/bash +# This script installs Klipper on a Raspberry Pi machine running the +# OctoPi distribution. + +PYTHONDIR="${HOME}/klippy-env" + +# Step 1: Install system packages +install_packages() +{ + # Packages for python cffi + PKGLIST="libffi-dev" + # kconfig requirements + PKGLIST="${PKGLIST} libncurses-dev" + # hub-ctrl + PKGLIST="${PKGLIST} libusb-dev" + # AVR chip installation and building + PKGLIST="${PKGLIST} avrdude gcc-avr binutils-avr avr-libc" + # ARM chip installation and building + PKGLIST="${PKGLIST} bossa-cli libnewlib-arm-none-eabi" + + # Update system package info + report_status "Running apt-get update..." + sudo apt-get update + + # Install desired packages + report_status "Installing packages..." + sudo apt-get install --yes ${PKGLIST} +} + +# Step 2: Create python virtual environment +create_virtualenv() +{ + report_status "Updating python virtual environment..." + + # Create virtualenv if it doesn't already exist + [ ! -d ${PYTHONDIR} ] && virtualenv ${PYTHONDIR} + + # Install/update dependencies + ${PYTHONDIR}/bin/pip install cffi==1.6.0 pyserial==3.2.1 greenlet==0.4.10 +} + +# Step 3: Install startup script +install_script() +{ + report_status "Installing system start script..." + sudo cp "${SRCDIR}/scripts/klipper-start.sh" /etc/init.d/klipper + sudo update-rc.d klipper defaults +} + +# Step 4: Install startup script config +install_config() +{ + DEFAULTS_FILE=/etc/default/klipper + [ -f $DEFAULTS_FILE ] && return + + report_status "Installing system start configuration..." + sudo /bin/sh -c "cat > $DEFAULTS_FILE" <