From 6e9132c8f7b0a94d8ea3627271f553fd09c09320 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Sun, 15 Feb 2015 23:14:04 +0200 Subject: [PATCH 001/352] Remove out of date torrent --- README.rst | 3 --- 1 file changed, 3 deletions(-) diff --git a/README.rst b/README.rst index f30d8dc8..dbc32042 100644 --- a/README.rst +++ b/README.rst @@ -15,9 +15,6 @@ Official mirror is `here `_ Alternative mirror is `here `_ - -There is also a torrent for 0.10.0 `here `_ . - Nightly builds are avilable `here `_ How to use it? From 528777bf01772f057450acc0569fc159e5e2f971 Mon Sep 17 00:00:00 2001 From: Philipp Engel Date: Fri, 20 Feb 2015 18:19:00 +0100 Subject: [PATCH 002/352] changed code to support variants and flavors. Flavors are supposed to be slightly different configurations of the same variant, where as variants can be very different from the default OctoPi release: * added a variants directory with an example * moved common functions to util.sh --- src/build | 28 +++++++++++ src/chroot_script | 47 ++++--------------- src/octopi | 38 ++++++++++----- src/util.sh | 45 ++++++++++++++++++ src/variants/example/chroot_script | 16 +++++++ src/variants/example/config | 3 ++ src/variants/example/config.nightly | 3 ++ .../example/filesystem/root/etc/dhclient.conf | 0 8 files changed, 131 insertions(+), 49 deletions(-) create mode 100755 src/util.sh create mode 100755 src/variants/example/chroot_script create mode 100755 src/variants/example/config create mode 100755 src/variants/example/config.nightly create mode 100644 src/variants/example/filesystem/root/etc/dhclient.conf diff --git a/src/build b/src/build index 05880ff2..c3141fb6 100755 --- a/src/build +++ b/src/build @@ -1,4 +1,32 @@ #!/usr/bin/env bash + +source ./util.sh + OCTOPI_PATH=$(dirname $(realpath -s $0)) + +BUILD_VARIANT=default +BUILD_FLAVOR=default + +if [ "$#" -eq 1 ]; then + BUILD_VARIANT=$1 +elif [ "$#" -eq 2 ]; then + BUILD_VARIANT=$1 + BUILD_FLAVOR=$2 +fi + +if [ $BUILD_VARIANT != 'default' ]; then + export VARIANT_BASE="$OCTOPI_PATH/variants/$BUILD_VARIANT" + [ -d $VARIANT_BASE ] || die "Could not find Variant $BUILD_VARIANT" + if [ $BUILD_FLAVOR == '' ] || [ $BUILD_FLAVOR == 'default' ]; then + FLAVOR_CONFIG=$VARIANT_BASE/config + else + FLAVOR_CONFIG=$VARIANT_BASE/config.$BUILD_FLAVOR + fi + source $FLAVOR_CONFIG || die "Could not find config file $FLAVOR_CONFIG" + + echo "Building VARIANT $BUILD_VARIANT, FLAVOR $BUILD_FLAVOR" +fi + + source $OCTOPI_PATH/config source $OCTOPI_PATH/octopi diff --git a/src/chroot_script b/src/chroot_script index 1d779e26..330768d7 100755 --- a/src/chroot_script +++ b/src/chroot_script @@ -4,38 +4,8 @@ set -x # Helper script that runs in a Raspbian chroot to create the OctoPI distro # Written by Guy Sheffer # GPL V3 -fixLd(){ - sed -i 's@/usr/lib/arm-linux-gnueabihf/libcofi_rpi.so@\#/usr/lib/arm-linux-gnueabihf/libcofi_rpi.so@' /etc/ld.so.preload -} - -gitclone(){ -if [ $GIT_REPO_OVERRIDE != "" ] ; then - REPO=$GIT_REPO_OVERRIDE`echo $1 | awk -F '/' '{print $(NF)}'` - sudo -u pi git clone $REPO - sudo -u pi git remote set-url $1 -else - sudo -u pi git clone $1 -fi -} - -unpackHome(){ - shopt -s dotglob - cp -av /filesystem/home/* /home/pi - shopt -u dotglob - chown -hR pi:pi /home/pi -} - -unpackRoot(){ - shopt -s dotglob - cp -av /filesystem/root/* / - shopt -u dotglob -} - -unpackBoot(){ - shopt -s dotglob - cp -av /filesystem/boot/* /boot - shopt -u dotglob -} + +source /util.sh fixLd unpackHome @@ -52,11 +22,14 @@ pushd /home/pi #build virtualenv sudo -u pi virtualenv --system-site-packages oprint - #OctoPrint - gitclone https://github.com/foosel/OctoPrint.git - pushd OctoPrint - sudo -u pi /home/pi/oprint/bin/python setup.py install - popd + if [ -n $OVERRIDE_OCTOPRINT ] + then + #OctoPrint + gitclone https://github.com/foosel/OctoPrint.git + pushd OctoPrint + sudo -u pi /home/pi/oprint/bin/python setup.py install + popd + fi #OctoPiPanel gitclone https://github.com/jonaslorander/OctoPiPanel.git diff --git a/src/octopi b/src/octopi index 4bf3f41f..9a1f716d 100755 --- a/src/octopi +++ b/src/octopi @@ -3,6 +3,26 @@ # This script takes a Raspbian image and adds to it octoprint and verions addons # Written by Guy Sheffer # GPL V3 + +function execute_chroot_script() { + #move OctoPi filesystem files + cp -av $1/filesystem . + + #black magic of qemu-arm-static + cp `which qemu-arm-static` usr/bin + + cp $2 chroot_script + chmod 755 chroot_script + cp $SCRIPT_PATH/util.sh util.sh + chmod 755 util.sh + + chroot . usr/bin/qemu-arm-static /bin/bash /chroot_script + + #cleanup + rm chroot_script + rm -rfv filesystem +} + mkdir -p $OCTOPI_WORKSPACE mkdir -p $MOUNT_PATH @@ -21,19 +41,13 @@ pushd $OCTOPI_WORKSPACE #make QEMU boot (remember to return) #sed -i 's@include /etc/ld.so.conf.d/\*.conf@\#include /etc/ld.so.conf.d/\*.conf@' etc/ld.so.conf - #move OctoPi filesystem files - cp -av $SCRIPT_PATH/filesystem . - - #black magic of qemu-arm-static - cp `which qemu-arm-static` usr/bin - cp $CHROOT_SCRIPT_PATH chroot_script - chmod 755 chroot_script - - chroot . usr/bin/qemu-arm-static /bin/bash /chroot_script + # execute the base chroot script + #execute_chroot_script $SCRIPT_PATH $CHROOT_SCRIPT_PATH - #cleanup - rm chroot_script - rm -rfv filesystem + # if building a variant, execute its chroot script + if [ -n $VARIANT_BASE ]; then + execute_chroot_script $VARIANT_BASE $VARIANT_BASE/chroot_script + fi popd # unmount first boot, then root partition diff --git a/src/util.sh b/src/util.sh new file mode 100755 index 00000000..9eb5bb7f --- /dev/null +++ b/src/util.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash + +function die () { + echo >&2 "$@" + exit 1 +} + +function fixLd(){ + sed -i 's@/usr/lib/arm-linux-gnueabihf/libcofi_rpi.so@\#/usr/lib/arm-linux-gnueabihf/libcofi_rpi.so@' /etc/ld.so.preload +} + +function gitclone(){ +if [ $GIT_REPO_OVERRIDE != "" ] ; then + REPO=$GIT_REPO_OVERRIDE`echo $1 | awk -F '/' '{print $(NF)}'` + sudo -u pi git clone $REPO + sudo -u pi git remote set-url $1 +else + sudo -u pi git clone $1 +fi +} + +function unpackHome(){ + shopt -s dotglob + cp -av /filesystem/home/* /home/pi + shopt -u dotglob + chown -hR pi:pi /home/pi +} + +function unpackRoot(){ + shopt -s dotglob + cp -av /filesystem/root/* / + shopt -u dotglob +} + +function unpackBoot(){ + shopt -s dotglob + cp -av /filesystem/boot/* /boot + shopt -u dotglob +} + +function install_fail_on_error_trap() { + set -e + trap 'previous_command=$this_command; this_command=$BASH_COMMAND' DEBUG + trap 'echo -e "\nexit $? due to $previous_command \nBUILD FAILED!"' EXIT +} diff --git a/src/variants/example/chroot_script b/src/variants/example/chroot_script new file mode 100755 index 00000000..1b2f5c47 --- /dev/null +++ b/src/variants/example/chroot_script @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +source /util.sh + +# exit script on any error +install_fail_on_error_trap + +#change the hostname +sudo sed -i 's@octopi@example@' /etc/hosts + +# install dhclient.conf and possibly other files +unpackRoot + +#cleanup +fixLd +sudo apt-get clean diff --git a/src/variants/example/config b/src/variants/example/config new file mode 100755 index 00000000..f62134c1 --- /dev/null +++ b/src/variants/example/config @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +export OVERRIDE_OCTOPRINT=yes diff --git a/src/variants/example/config.nightly b/src/variants/example/config.nightly new file mode 100755 index 00000000..9110dff5 --- /dev/null +++ b/src/variants/example/config.nightly @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +export OVERRIDE_OCTOPRINT=no \ No newline at end of file diff --git a/src/variants/example/filesystem/root/etc/dhclient.conf b/src/variants/example/filesystem/root/etc/dhclient.conf new file mode 100644 index 00000000..e69de29b From 6f5965874dce3a3ed43f53a4d1fe3f44a30f9558 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Sat, 21 Feb 2015 01:46:07 +0200 Subject: [PATCH 003/352] Fix ld.so.preload mess so we don't get uncaught target signal 4 (Illegal instruction) - core dumped --- src/chroot_script | 4 ---- src/octopi | 4 ++++ src/util.sh | 6 +++++- src/variants/example/chroot_script | 1 - 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/chroot_script b/src/chroot_script index 330768d7..163a568a 100755 --- a/src/chroot_script +++ b/src/chroot_script @@ -7,7 +7,6 @@ set -x source /util.sh -fixLd unpackHome unpackBoot apt-get update @@ -122,7 +121,4 @@ unpackRoot sudo update-rc.d octoprint defaults 99 #cleanup -fixLd sudo apt-get clean - -sed -i 's@\#/usr/lib/arm-linux-gnueabihf/libcofi_rpi.so@/usr/lib/arm-linux-gnueabihf/libcofi_rpi.so@' /etc/ld.so.preload diff --git a/src/octopi b/src/octopi index 9a1f716d..cd131da7 100755 --- a/src/octopi +++ b/src/octopi @@ -39,6 +39,8 @@ pushd $OCTOPI_WORKSPACE pushd $MOUNT_PATH #make QEMU boot (remember to return) + source util.sh + fixLd #sed -i 's@include /etc/ld.so.conf.d/\*.conf@\#include /etc/ld.so.conf.d/\*.conf@' etc/ld.so.conf # execute the base chroot script @@ -48,6 +50,8 @@ pushd $OCTOPI_WORKSPACE if [ -n $VARIANT_BASE ]; then execute_chroot_script $VARIANT_BASE $VARIANT_BASE/chroot_script fi + + restoreLd popd # unmount first boot, then root partition diff --git a/src/util.sh b/src/util.sh index 9eb5bb7f..a0374b53 100755 --- a/src/util.sh +++ b/src/util.sh @@ -6,7 +6,11 @@ function die () { } function fixLd(){ - sed -i 's@/usr/lib/arm-linux-gnueabihf/libcofi_rpi.so@\#/usr/lib/arm-linux-gnueabihf/libcofi_rpi.so@' /etc/ld.so.preload + sed -i 's@/usr/lib/arm-linux-gnueabihf/libcofi_rpi.so@\#/usr/lib/arm-linux-gnueabihf/libcofi_rpi.so@' etc/ld.so.preload +} + +function restoreLd(){ + sed -i 's@\#/usr/lib/arm-linux-gnueabihf/libcofi_rpi.so@/usr/lib/arm-linux-gnueabihf/libcofi_rpi.so@' etc/ld.so.preload } function gitclone(){ diff --git a/src/variants/example/chroot_script b/src/variants/example/chroot_script index 1b2f5c47..08c1ba1f 100755 --- a/src/variants/example/chroot_script +++ b/src/variants/example/chroot_script @@ -12,5 +12,4 @@ sudo sed -i 's@octopi@example@' /etc/hosts unpackRoot #cleanup -fixLd sudo apt-get clean From 0416efd2702e857edf84753a30a3a435d5435f2b Mon Sep 17 00:00:00 2001 From: root Date: Sat, 21 Feb 2015 15:38:09 +0200 Subject: [PATCH 004/352] Build from devel both OctoPrint and OctoPiPanel --- src/chroot_script | 2 ++ src/config | 2 ++ 2 files changed, 4 insertions(+) mode change 100644 => 100755 src/config diff --git a/src/chroot_script b/src/chroot_script index 1d779e26..ad807d6f 100755 --- a/src/chroot_script +++ b/src/chroot_script @@ -55,12 +55,14 @@ pushd /home/pi #OctoPrint gitclone https://github.com/foosel/OctoPrint.git pushd OctoPrint + git checkout $OCTOPRINT_BRANCH sudo -u pi /home/pi/oprint/bin/python setup.py install popd #OctoPiPanel gitclone https://github.com/jonaslorander/OctoPiPanel.git pushd OctoPiPanel + git checkout $OCTOPIPANEL_BRANCH sudo -u pi /home/pi/oprint/bin/pip install -r requirements.txt popd diff --git a/src/config b/src/config old mode 100644 new mode 100755 index 9d20d99e..57ddb979 --- a/src/config +++ b/src/config @@ -1,4 +1,6 @@ CONFIG_DIR=$(dirname $(realpath -s $BASH_SOURCE)) +export OCTOPRINT_BRANCH=devel +export OCTOPIPANEL_BRANCH=devel if [ -f $CONFIG_DIR/config.local ]; then source $CONFIG_DIR/config.local From c9bc2ebdd3eba589d9203eb3729272c4235efac7 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Sat, 21 Feb 2015 15:38:47 +0200 Subject: [PATCH 005/352] Increment version to 0.12.0 --- src/filesystem/root/etc/octopi_version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/filesystem/root/etc/octopi_version b/src/filesystem/root/etc/octopi_version index d9df1bbc..ac454c6a 100644 --- a/src/filesystem/root/etc/octopi_version +++ b/src/filesystem/root/etc/octopi_version @@ -1 +1 @@ -0.11.0 +0.12.0 From 93ce291270d121b0d3cfae05441af67a38796c0e Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Sat, 21 Feb 2015 19:03:29 +0200 Subject: [PATCH 006/352] Nighlty builds scripts. Still not usable, gnet.homelinux.com needs to be removed, needs docs etc --- src/nightly_build_scripts/build_local_mirrors | 6 +++++ .../octopi_nightly_build | 23 +++++++++++++++++++ src/nightly_build_scripts/update_git_mirrors | 12 ++++++++++ 3 files changed, 41 insertions(+) create mode 100644 src/nightly_build_scripts/build_local_mirrors create mode 100755 src/nightly_build_scripts/octopi_nightly_build create mode 100755 src/nightly_build_scripts/update_git_mirrors diff --git a/src/nightly_build_scripts/build_local_mirrors b/src/nightly_build_scripts/build_local_mirrors new file mode 100644 index 00000000..684f4b0f --- /dev/null +++ b/src/nightly_build_scripts/build_local_mirrors @@ -0,0 +1,6 @@ +pushd /var/www/git +git clone --mirror https://github.com/foosel/OctoPrint +git clone --mirror https://github.com/jonaslorander/OctoPiPanel.git +git clone --mirror https://github.com/jacksonliam/mjpg-streamer.git +git clone --mirror https://github.com/tasanakorn/rpi-fbcp +popd diff --git a/src/nightly_build_scripts/octopi_nightly_build b/src/nightly_build_scripts/octopi_nightly_build new file mode 100755 index 00000000..d044c099 --- /dev/null +++ b/src/nightly_build_scripts/octopi_nightly_build @@ -0,0 +1,23 @@ +#!/bin/bash -x +whoami +OCTOPIPATH=/home/guy/tmp/OctoPi + +#Update repos used +sudo -u guy /home/guy/stuff/scripts/gitmirror/update_git_mirrors + +for i in `lsof ${OCTOPIPATH}/src/workspace/mount | awk '{print $2}'`; do kill -9 $i; done + +rm ${OCTOPIPATH}/src/workspace/*.img +rm ${OCTOPIPATH}/src/workspace/*.zip + +pushd ${OCTOPIPATH} + umount ${OCTOPIPATH}/src/workspace/mount/boot + umount ${OCTOPIPATH}/src/workspace/mount + git pull origin devel + export GIT_REPO_OVERRIDE='http://gnet.homelinux.com/git/' + ${OCTOPIPATH}/src/build + pushd src + ${OCTOPIPATH}/src/release + popd + chmod 777 ${OCTOPIPATH}/src/* +popd diff --git a/src/nightly_build_scripts/update_git_mirrors b/src/nightly_build_scripts/update_git_mirrors new file mode 100755 index 00000000..03346a08 --- /dev/null +++ b/src/nightly_build_scripts/update_git_mirrors @@ -0,0 +1,12 @@ +#!/bin/bash +MIRROR_LOCATION=/var/www/git +mkdir $MIRROR_LOCATION +pushd MIRROR_LOCATION + for repo in `ls` + do + pushd $repo + git fetch --prune + git update-server-info + popd + done +popd From a31fcc2a5e549976dbb58f4693761ae0d12d55e9 Mon Sep 17 00:00:00 2001 From: Philipp Engel Date: Tue, 24 Feb 2015 16:44:08 +0100 Subject: [PATCH 007/352] various tweaks and fixes to the variants implementation: * let build fail only when a command actually fails. added a check for command return values OTHER than 0 * installing error trap for octopi script * removed unnecessary sudos * fixed bug: rm *.img fails first build (when set -e is applied) * always displaying the variant and flavor * renamed util.sh to common.sh --- src/build | 11 +++++------ src/chroot_script | 2 +- src/{util.sh => common.sh} | 2 +- src/octopi | 14 +++++++++----- src/variants/example/chroot_script | 6 +++--- 5 files changed, 19 insertions(+), 16 deletions(-) rename src/{util.sh => common.sh} (91%) diff --git a/src/build b/src/build index c3141fb6..eaf24f29 100755 --- a/src/build +++ b/src/build @@ -1,16 +1,16 @@ #!/usr/bin/env bash -source ./util.sh +source ./common.sh OCTOPI_PATH=$(dirname $(realpath -s $0)) BUILD_VARIANT=default BUILD_FLAVOR=default -if [ "$#" -eq 1 ]; then - BUILD_VARIANT=$1 -elif [ "$#" -eq 2 ]; then +if [ "$#" -gt 0 ]; then BUILD_VARIANT=$1 +fi +if [ "$#" -gt 1 ]; then BUILD_FLAVOR=$2 fi @@ -23,10 +23,9 @@ if [ $BUILD_VARIANT != 'default' ]; then FLAVOR_CONFIG=$VARIANT_BASE/config.$BUILD_FLAVOR fi source $FLAVOR_CONFIG || die "Could not find config file $FLAVOR_CONFIG" - - echo "Building VARIANT $BUILD_VARIANT, FLAVOR $BUILD_FLAVOR" fi +echo -e "--> Building VARIANT $BUILD_VARIANT, FLAVOR $BUILD_FLAVOR" source $OCTOPI_PATH/config source $OCTOPI_PATH/octopi diff --git a/src/chroot_script b/src/chroot_script index 163a568a..9e99a5bd 100755 --- a/src/chroot_script +++ b/src/chroot_script @@ -5,7 +5,7 @@ set -x # Written by Guy Sheffer # GPL V3 -source /util.sh +source /common.sh unpackHome unpackBoot diff --git a/src/util.sh b/src/common.sh similarity index 91% rename from src/util.sh rename to src/common.sh index a0374b53..9ddbb67b 100755 --- a/src/util.sh +++ b/src/common.sh @@ -45,5 +45,5 @@ function unpackBoot(){ function install_fail_on_error_trap() { set -e trap 'previous_command=$this_command; this_command=$BASH_COMMAND' DEBUG - trap 'echo -e "\nexit $? due to $previous_command \nBUILD FAILED!"' EXIT + trap 'if [ $? -ne 0 ]; then echo -e "\nexit $? due to $previous_command \nBUILD FAILED!"; fi' EXIT } diff --git a/src/octopi b/src/octopi index cd131da7..35c62cf8 100755 --- a/src/octopi +++ b/src/octopi @@ -4,6 +4,9 @@ # Written by Guy Sheffer # GPL V3 +source $SCRIPT_PATH/common.sh +install_fail_on_error_trap + function execute_chroot_script() { #move OctoPi filesystem files cp -av $1/filesystem . @@ -13,8 +16,8 @@ function execute_chroot_script() { cp $2 chroot_script chmod 755 chroot_script - cp $SCRIPT_PATH/util.sh util.sh - chmod 755 util.sh + cp $SCRIPT_PATH/common.sh common.sh + chmod 755 common.sh chroot . usr/bin/qemu-arm-static /bin/bash /chroot_script @@ -27,7 +30,9 @@ mkdir -p $OCTOPI_WORKSPACE mkdir -p $MOUNT_PATH pushd $OCTOPI_WORKSPACE - rm *.img + if [ -e *.img ]; then + rm *.img + fi unzip $ZIP_IMG IMG_PATH=`ls | grep .img` @@ -39,12 +44,11 @@ pushd $OCTOPI_WORKSPACE pushd $MOUNT_PATH #make QEMU boot (remember to return) - source util.sh fixLd #sed -i 's@include /etc/ld.so.conf.d/\*.conf@\#include /etc/ld.so.conf.d/\*.conf@' etc/ld.so.conf # execute the base chroot script - #execute_chroot_script $SCRIPT_PATH $CHROOT_SCRIPT_PATH + execute_chroot_script $SCRIPT_PATH $CHROOT_SCRIPT_PATH # if building a variant, execute its chroot script if [ -n $VARIANT_BASE ]; then diff --git a/src/variants/example/chroot_script b/src/variants/example/chroot_script index 08c1ba1f..b05e4e88 100755 --- a/src/variants/example/chroot_script +++ b/src/variants/example/chroot_script @@ -1,15 +1,15 @@ #!/usr/bin/env bash -source /util.sh +source /common.sh # exit script on any error install_fail_on_error_trap #change the hostname -sudo sed -i 's@octopi@example@' /etc/hosts +sed -i 's@octopi@example@' /etc/hosts # install dhclient.conf and possibly other files unpackRoot #cleanup -sudo apt-get clean +apt-get clean From 68e87a89f06a5d3d1c0ed60241368c3aa924bd28 Mon Sep 17 00:00:00 2001 From: Philipp Engel Date: Wed, 25 Feb 2015 23:49:04 +0100 Subject: [PATCH 008/352] cp -a messed up the owners system folders (e.g. /etc), using -r --preserve=mode,timestamps instead --- src/common.sh | 6 +++--- src/octopi | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/common.sh b/src/common.sh index 9ddbb67b..b388d765 100755 --- a/src/common.sh +++ b/src/common.sh @@ -25,20 +25,20 @@ fi function unpackHome(){ shopt -s dotglob - cp -av /filesystem/home/* /home/pi + cp -v -r --preserve=mode,timestamps /filesystem/home/* /home/pi shopt -u dotglob chown -hR pi:pi /home/pi } function unpackRoot(){ shopt -s dotglob - cp -av /filesystem/root/* / + cp -v -r --preserve=mode,timestamps /filesystem/root/* / shopt -u dotglob } function unpackBoot(){ shopt -s dotglob - cp -av /filesystem/boot/* /boot + cp -v -r --preserve=mode,timestamps /filesystem/boot/* /boot shopt -u dotglob } diff --git a/src/octopi b/src/octopi index 35c62cf8..2427f53c 100755 --- a/src/octopi +++ b/src/octopi @@ -9,7 +9,7 @@ install_fail_on_error_trap function execute_chroot_script() { #move OctoPi filesystem files - cp -av $1/filesystem . + cp -vr --preserve=mode,timestamps $1/filesystem . #black magic of qemu-arm-static cp `which qemu-arm-static` usr/bin From 7797955900eed9f99bacb298f726e7f32686bf0d Mon Sep 17 00:00:00 2001 From: Philipp Engel Date: Wed, 25 Feb 2015 23:50:43 +0100 Subject: [PATCH 009/352] implemented hostname override using variable OVERRIDE_HOSTNAME which can be defined by variants --- src/chroot_script | 4 ++-- src/config | 2 ++ src/variants/example/config | 6 ++++++ src/variants/example/config.nightly | 3 ++- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/chroot_script b/src/chroot_script index 9e99a5bd..7a5cc129 100755 --- a/src/chroot_script +++ b/src/chroot_script @@ -106,8 +106,8 @@ echo "pi ALL=NOPASSWD: /sbin/service" > /etc/sudoers.d/octoprint-service #reach printer by name sudo apt-get -y --force-yes install avahi-daemon -echo octopi > /etc/hostname -sed -i 's@raspberrypi@octopi@' /etc/hosts +echo "$OVERRIDE_HOSTNAME" > /etc/hostname +sed -i -e "s@raspberrypi@$OVERRIDE_HOSTNAME@g" /etc/hosts # enable raspicam echo "# enable raspicam" >> /boot/config.txt diff --git a/src/config b/src/config index 9d20d99e..3d5a8df7 100644 --- a/src/config +++ b/src/config @@ -12,6 +12,7 @@ fi [ -n "$OCTOPI_WORKSPACE" ] || OCTOPI_WORKSPACE=$SCRIPT_PATH/workspace [ -n "$CHROOT_SCRIPT_PATH" ] || CHROOT_SCRIPT_PATH=$SCRIPT_PATH/chroot_script [ -n "$MOUNT_PATH" ] || MOUNT_PATH=$OCTOPI_WORKSPACE/mount +[ -n "$OVERRIDE_HOSTNAME" ] || OVERRIDE_HOSTNAME=octopi echo "================================================================" echo "Using the following config:" @@ -21,4 +22,5 @@ echo "ZIP_IMG = $ZIP_IMG" echo "OCTOPI_WORKSPACE = $OCTOPI_WORKSPACE" echo "CHROOT_SCRIPT_PATH = $CHROOT_SCRIPT_PATH" echo "MOUNT_PATH = $MOUNT_PATH" +echo "OVERRIDE_HOSTNAME = $OVERRIDE_HOSTNAME" echo "================================================================" diff --git a/src/variants/example/config b/src/variants/example/config index f62134c1..3ce7b42b 100755 --- a/src/variants/example/config +++ b/src/variants/example/config @@ -1,3 +1,9 @@ #!/usr/bin/env bash +# make sure to export all the variables to make them available to the chroot scripts as well + +# customize the hostname +export OVERRIDE_HOSTNAME=blueberrypi + +# skip octoprint installation in main build script export OVERRIDE_OCTOPRINT=yes diff --git a/src/variants/example/config.nightly b/src/variants/example/config.nightly index 9110dff5..679aae89 100755 --- a/src/variants/example/config.nightly +++ b/src/variants/example/config.nightly @@ -1,3 +1,4 @@ #!/usr/bin/env bash -export OVERRIDE_OCTOPRINT=no \ No newline at end of file +export OVERRIDE_HOSTNAME=blueberrypi +export OVERRIDE_OCTOPRINT=no From ee86c1fb2ccdf910b50f0f4ff1f6c4da15f455d4 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Mon, 2 Mar 2015 15:47:32 +0200 Subject: [PATCH 010/352] Handle raspbian changing their image name the last two releases --- src/config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config b/src/config index 6daf980c..14235199 100755 --- a/src/config +++ b/src/config @@ -9,7 +9,7 @@ fi [ -n "$SCRIPT_PATH" ] || SCRIPT_PATH=$CONFIG_DIR [ -n "$IMAGE_PATH" ] || IMAGE_PATH=$SCRIPT_PATH/image -[ -n "$ZIP_IMG" ] || ZIP_IMG=`ls -t $IMAGE_PATH/*-raspbian.zip | head -n 1` +[ -n "$ZIP_IMG" ] || ZIP_IMG=`ls -t $IMAGE_PATH/*-raspbian-*.zip | head -n 1` [ -n "$OCTOPI_WORKSPACE" ] || OCTOPI_WORKSPACE=$SCRIPT_PATH/workspace [ -n "$CHROOT_SCRIPT_PATH" ] || CHROOT_SCRIPT_PATH=$SCRIPT_PATH/chroot_script From b636a6be08d74adedf2dc14a23ab35bed885cdda Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Wed, 4 Mar 2015 02:30:48 +0200 Subject: [PATCH 011/352] Make globing more general --- src/config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config b/src/config index 14235199..df893791 100755 --- a/src/config +++ b/src/config @@ -9,7 +9,7 @@ fi [ -n "$SCRIPT_PATH" ] || SCRIPT_PATH=$CONFIG_DIR [ -n "$IMAGE_PATH" ] || IMAGE_PATH=$SCRIPT_PATH/image -[ -n "$ZIP_IMG" ] || ZIP_IMG=`ls -t $IMAGE_PATH/*-raspbian-*.zip | head -n 1` +[ -n "$ZIP_IMG" ] || ZIP_IMG=`ls -t $IMAGE_PATH/*-raspbian*.zip | head -n 1` [ -n "$OCTOPI_WORKSPACE" ] || OCTOPI_WORKSPACE=$SCRIPT_PATH/workspace [ -n "$CHROOT_SCRIPT_PATH" ] || CHROOT_SCRIPT_PATH=$SCRIPT_PATH/chroot_script From 864d06f527058c0b3d0f5e4f2dda0bf794e00829 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Wed, 4 Mar 2015 02:34:53 +0200 Subject: [PATCH 012/352] Make config export variables, regression caused by #73 --- src/config | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/config b/src/config index df893791..ce8f88ab 100755 --- a/src/config +++ b/src/config @@ -6,15 +6,15 @@ if [ -f $CONFIG_DIR/config.local ]; then source $CONFIG_DIR/config.local fi -[ -n "$SCRIPT_PATH" ] || SCRIPT_PATH=$CONFIG_DIR -[ -n "$IMAGE_PATH" ] || IMAGE_PATH=$SCRIPT_PATH/image +[ -n "$SCRIPT_PATH" ] || export SCRIPT_PATH=$CONFIG_DIR +[ -n "$IMAGE_PATH" ] || export IMAGE_PATH=$SCRIPT_PATH/image -[ -n "$ZIP_IMG" ] || ZIP_IMG=`ls -t $IMAGE_PATH/*-raspbian*.zip | head -n 1` +[ -n "$ZIP_IMG" ] || export ZIP_IMG=`ls -t $IMAGE_PATH/*-raspbian*.zip | head -n 1` -[ -n "$OCTOPI_WORKSPACE" ] || OCTOPI_WORKSPACE=$SCRIPT_PATH/workspace -[ -n "$CHROOT_SCRIPT_PATH" ] || CHROOT_SCRIPT_PATH=$SCRIPT_PATH/chroot_script -[ -n "$MOUNT_PATH" ] || MOUNT_PATH=$OCTOPI_WORKSPACE/mount -[ -n "$OVERRIDE_HOSTNAME" ] || OVERRIDE_HOSTNAME=octopi +[ -n "$OCTOPI_WORKSPACE" ] || export OCTOPI_WORKSPACE=$SCRIPT_PATH/workspace +[ -n "$CHROOT_SCRIPT_PATH" ] || export CHROOT_SCRIPT_PATH=$SCRIPT_PATH/chroot_script +[ -n "$MOUNT_PATH" ] || export MOUNT_PATH=$OCTOPI_WORKSPACE/mount +[ -n "$OVERRIDE_HOSTNAME" ] || export OVERRIDE_HOSTNAME=octopi echo "================================================================" echo "Using the following config:" From 06d449e0e69cb402f16ef25e2fe638985b2d764a Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Thu, 5 Mar 2015 01:34:57 +0200 Subject: [PATCH 013/352] Fix common.sh source and make it absolute --- src/build | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/build b/src/build index eaf24f29..9dd99f17 100755 --- a/src/build +++ b/src/build @@ -1,6 +1,7 @@ #!/usr/bin/env bash -source ./common.sh +BUILD_SCRIPT__PATH=$(dirname $(realpath -s $BASH_SOURCE)) +source ${BUILD_SCRIPT__PATH}/common.sh OCTOPI_PATH=$(dirname $(realpath -s $0)) From 71f8734ae4e0efb6e5b075b591c9aa171683bcb3 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Sun, 8 Mar 2015 01:56:06 +0200 Subject: [PATCH 014/352] Spliting variant chroot_script to pre_chroot_script and post_chroot_script, adjust your variants! #73 --- src/octopi | 10 +++++++--- .../example/{chroot_script => post_chroot_script} | 0 2 files changed, 7 insertions(+), 3 deletions(-) rename src/variants/example/{chroot_script => post_chroot_script} (100%) diff --git a/src/octopi b/src/octopi index 2427f53c..d5c2dcd6 100755 --- a/src/octopi +++ b/src/octopi @@ -46,13 +46,17 @@ pushd $OCTOPI_WORKSPACE #make QEMU boot (remember to return) fixLd #sed -i 's@include /etc/ld.so.conf.d/\*.conf@\#include /etc/ld.so.conf.d/\*.conf@' etc/ld.so.conf - + # if building a variant, execute its pre-chroot script + if [ -n $VARIANT_BASE ]; then + execute_chroot_script $VARIANT_BASE $VARIANT_BASE/pre_chroot_script + fi + # execute the base chroot script execute_chroot_script $SCRIPT_PATH $CHROOT_SCRIPT_PATH - # if building a variant, execute its chroot script + # if building a variant, execute its post-chroot script if [ -n $VARIANT_BASE ]; then - execute_chroot_script $VARIANT_BASE $VARIANT_BASE/chroot_script + execute_chroot_script $VARIANT_BASE $VARIANT_BASE/post_chroot_script fi restoreLd diff --git a/src/variants/example/chroot_script b/src/variants/example/post_chroot_script similarity index 100% rename from src/variants/example/chroot_script rename to src/variants/example/post_chroot_script From b9f290ab206563d42484f5283c18c5047fb28374 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Sun, 8 Mar 2015 01:57:32 +0200 Subject: [PATCH 015/352] Add bananapi-m1 variant, works with rapbian images, no bananapi camera support yet #63 --- src/variants/bananapi-m1/config | 38 +++++++++++++++++++ .../filesystem/root/etc/resolv.conf | 1 + src/variants/bananapi-m1/post_chroot_script | 1 + src/variants/bananapi-m1/pre_chroot_script | 12 ++++++ 4 files changed, 52 insertions(+) create mode 100755 src/variants/bananapi-m1/config create mode 100644 src/variants/bananapi-m1/filesystem/root/etc/resolv.conf create mode 100644 src/variants/bananapi-m1/post_chroot_script create mode 100755 src/variants/bananapi-m1/pre_chroot_script diff --git a/src/variants/bananapi-m1/config b/src/variants/bananapi-m1/config new file mode 100755 index 00000000..0fd0f51f --- /dev/null +++ b/src/variants/bananapi-m1/config @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +# make sure to export all the variables to make them available to the chroot scripts as well + +# customize the hostname +#export OVERRIDE_HOSTNAME=blueberrypi + +# skip octoprint installation in main build script +#export OVERRIDE_OCTOPRINT=yes + +CONFIG_DIR=$(realpath -s $(dirname $(realpath -s $BASH_SOURCE))/../../) +VARIANT=$(basename $(dirname $(realpath -s $BASH_SOURCE))) +export OCTOPRINT_BRANCH=devel +export OCTOPIPANEL_BRANCH=devel + +if [ -f $CONFIG_DIR/config.local ]; then + source $CONFIG_DIR/config.local +fi + +[ -n "$SCRIPT_PATH" ] || export SCRIPT_PATH=$CONFIG_DIR +[ -n "$IMAGE_PATH" ] || export IMAGE_PATH=$SCRIPT_PATH/image-varients +[ -n "$ZIP_IMG" ] || export ZIP_IMG=`ls -t $IMAGE_PATH/*-raspbian-bpi-R1-M1*.zip | head -n 1` +[ -n "$OCTOPI_WORKSPACE" ] || export OCTOPI_WORKSPACE=$SCRIPT_PATH/workspace-${VARIANT} +[ -n "$CHROOT_SCRIPT_PATH" ] || export CHROOT_SCRIPT_PATH=$SCRIPT_PATH/chroot_script +[ -n "$MOUNT_PATH" ] || export MOUNT_PATH=$OCTOPI_WORKSPACE/mount +[ -n "$OVERRIDE_HOSTNAME" ] || export OVERRIDE_HOSTNAME=octopi + +echo "================================================================" +echo "Using the following config:" +echo "SCRIPT_PATH = $SCRIPT_PATH" +echo "IMAGE_PATH = $IMAGE_PATH" +echo "ZIP_IMG = $ZIP_IMG" +echo "OCTOPI_WORKSPACE = $OCTOPI_WORKSPACE" +echo "CHROOT_SCRIPT_PATH = $CHROOT_SCRIPT_PATH" +echo "MOUNT_PATH = $MOUNT_PATH" +echo "OVERRIDE_HOSTNAME = $OVERRIDE_HOSTNAME" +echo "================================================================" + diff --git a/src/variants/bananapi-m1/filesystem/root/etc/resolv.conf b/src/variants/bananapi-m1/filesystem/root/etc/resolv.conf new file mode 100644 index 00000000..ec8c9291 --- /dev/null +++ b/src/variants/bananapi-m1/filesystem/root/etc/resolv.conf @@ -0,0 +1 @@ +nameserver localhost diff --git a/src/variants/bananapi-m1/post_chroot_script b/src/variants/bananapi-m1/post_chroot_script new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/src/variants/bananapi-m1/post_chroot_script @@ -0,0 +1 @@ + diff --git a/src/variants/bananapi-m1/pre_chroot_script b/src/variants/bananapi-m1/pre_chroot_script new file mode 100755 index 00000000..d8c00877 --- /dev/null +++ b/src/variants/bananapi-m1/pre_chroot_script @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +source /common.sh + +# exit script on any error +install_fail_on_error_trap + +# install dhclient.conf and possibly other files +unpackRoot + +#cleanup +apt-get clean From 32b57f4e00410550eadddf0cf5d91dcd356acb06 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Fri, 13 Mar 2015 20:11:47 +0200 Subject: [PATCH 016/352] Fix OctoPi builds #77 --- src/octopi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/octopi b/src/octopi index d5c2dcd6..cc435b74 100755 --- a/src/octopi +++ b/src/octopi @@ -47,7 +47,7 @@ pushd $OCTOPI_WORKSPACE fixLd #sed -i 's@include /etc/ld.so.conf.d/\*.conf@\#include /etc/ld.so.conf.d/\*.conf@' etc/ld.so.conf # if building a variant, execute its pre-chroot script - if [ -n $VARIANT_BASE ]; then + if [ -n $VARIANT_BASE ] && [ -f $VARIANT_BASE $VARIANT_BASE/pre_chroot_script ]; then execute_chroot_script $VARIANT_BASE $VARIANT_BASE/pre_chroot_script fi @@ -55,7 +55,7 @@ pushd $OCTOPI_WORKSPACE execute_chroot_script $SCRIPT_PATH $CHROOT_SCRIPT_PATH # if building a variant, execute its post-chroot script - if [ -n $VARIANT_BASE ]; then + if [ -n $VARIANT_BASE ] && [ -f $VARIANT_BASE $VARIANT_BASE/post_chroot_script ]; then execute_chroot_script $VARIANT_BASE $VARIANT_BASE/post_chroot_script fi From 8e1e3a4acc15bf8fa1bdf439467b5f2da9f03a96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 24 Mar 2015 10:23:38 +0100 Subject: [PATCH 017/352] Fix for guysofl/OctoPi#84: Uninstall python-serial Due to the site-package being active in the OctoPrint virtualenv, sometimes the site wide installed version of pyserial got used, leading to errors when trying to connect to 250k baud firmwares. Just removing the preinstalled variant (which contrary to some reports seems to NOT include the patch for 250k support) solves that. --- src/chroot_script | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/chroot_script b/src/chroot_script index 06097645..74de73cc 100755 --- a/src/chroot_script +++ b/src/chroot_script @@ -11,7 +11,7 @@ unpackHome unpackBoot apt-get update -apt-get remove -y --purge scratch squeak-plugins-scratch squeak-vm wolfram-engine python-minecraftpi minecraft-pi sonic-pi oracle-java8-jdk +apt-get remove -y --purge scratch squeak-plugins-scratch squeak-vm wolfram-engine python-minecraftpi minecraft-pi sonic-pi oracle-java8-jdk python-serial #apt-get octoprint virtualenv apt-get -y --force-yes install python-virtualenv python-dev git python-numpy screen libts-bin From 950332962b5e65492452ff099c447cad8d803d77 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Sun, 29 Mar 2015 22:43:43 +0300 Subject: [PATCH 018/352] Add variant support in nightly build --- src/nightly_build_scripts/octopi_nightly_build | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/nightly_build_scripts/octopi_nightly_build b/src/nightly_build_scripts/octopi_nightly_build index d044c099..6e108496 100755 --- a/src/nightly_build_scripts/octopi_nightly_build +++ b/src/nightly_build_scripts/octopi_nightly_build @@ -15,9 +15,9 @@ pushd ${OCTOPIPATH} umount ${OCTOPIPATH}/src/workspace/mount git pull origin devel export GIT_REPO_OVERRIDE='http://gnet.homelinux.com/git/' - ${OCTOPIPATH}/src/build + ${OCTOPIPATH}/src/build $1 pushd src - ${OCTOPIPATH}/src/release + ${OCTOPIPATH}/src/release $1 popd chmod 777 ${OCTOPIPATH}/src/* popd From b8de49466c5bfd105832114bc52683980e4d3c5b Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Sun, 29 Mar 2015 22:45:15 +0300 Subject: [PATCH 019/352] Add jenkins console parsing configuration so it can be included in the job --- src/jenkins-ci/console_parsing | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 src/jenkins-ci/console_parsing diff --git a/src/jenkins-ci/console_parsing b/src/jenkins-ci/console_parsing new file mode 100644 index 00000000..0f88926a --- /dev/null +++ b/src/jenkins-ci/console_parsing @@ -0,0 +1,3 @@ +error /BUILD FAILED/ +error /mv: cannot stat/ +error /md5sum: * No such file or directory/ From 433ad9227b2fb3b37e2c7a854a16625799952853 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Sun, 29 Mar 2015 22:46:27 +0300 Subject: [PATCH 020/352] Add variant support in release --- src/release | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/release b/src/release index 611e0794..672dd58e 100755 --- a/src/release +++ b/src/release @@ -1,6 +1,10 @@ #!/usr/bin/env bash -pushd workspace - +if [ -z "$1" ];then + pushd workspace +else + pushd workspace-$1 +fi + FILENAME=$(basename `ls . | grep .img | tail -n 1` .img) OCTOPI_FILENAME=$(echo $FILENAME-`cat ../filesystem/root/etc/octopi_version` | sed 's/raspbian/octopi/') mv ${FILENAME}.img $OCTOPI_FILENAME.img From 2bc3729780e54a1aa2df4878aaa398b06374584e Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Mon, 30 Mar 2015 03:29:05 +0300 Subject: [PATCH 021/352] Fix typo --- src/octopi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/octopi b/src/octopi index cc435b74..cdd70629 100755 --- a/src/octopi +++ b/src/octopi @@ -47,7 +47,7 @@ pushd $OCTOPI_WORKSPACE fixLd #sed -i 's@include /etc/ld.so.conf.d/\*.conf@\#include /etc/ld.so.conf.d/\*.conf@' etc/ld.so.conf # if building a variant, execute its pre-chroot script - if [ -n $VARIANT_BASE ] && [ -f $VARIANT_BASE $VARIANT_BASE/pre_chroot_script ]; then + if [ -n "$VARIANT_BASE" ] && [ -f $VARIANT_BASE/pre_chroot_script ]; then execute_chroot_script $VARIANT_BASE $VARIANT_BASE/pre_chroot_script fi @@ -55,7 +55,7 @@ pushd $OCTOPI_WORKSPACE execute_chroot_script $SCRIPT_PATH $CHROOT_SCRIPT_PATH # if building a variant, execute its post-chroot script - if [ -n $VARIANT_BASE ] && [ -f $VARIANT_BASE $VARIANT_BASE/post_chroot_script ]; then + if [ -n "$VARIANT_BASE" ] && [ -f $VARIANT_BASE/post_chroot_script ]; then execute_chroot_script $VARIANT_BASE $VARIANT_BASE/post_chroot_script fi From 8c8e4fe649c9733e08a24c26a35c4963781f0034 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Sat, 4 Apr 2015 13:12:30 +0300 Subject: [PATCH 022/352] Fix if condition and also #74 --- src/common.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/common.sh b/src/common.sh index b388d765..03ba9e18 100755 --- a/src/common.sh +++ b/src/common.sh @@ -14,10 +14,13 @@ function restoreLd(){ } function gitclone(){ -if [ $GIT_REPO_OVERRIDE != "" ] ; then +if [ "$GIT_REPO_OVERRIDE" != "" ] ; then REPO=$GIT_REPO_OVERRIDE`echo $1 | awk -F '/' '{print $(NF)}'` sudo -u pi git clone $REPO - sudo -u pi git remote set-url $1 + REPO_DIR_NAME=$(echo ${REPO} | 's%^.*/\([^/]*\)\.git$%\1%g') + pushd ${REPO_DIR_NAME} + sudo -u pi git remote set-url $1 + popd else sudo -u pi git clone $1 fi From eeac80f93915efa7a225c64ff5e758d6a228d8db Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Sun, 5 Apr 2015 14:00:41 +0300 Subject: [PATCH 023/352] Forgot 'sed' command in line --- src/common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common.sh b/src/common.sh index 03ba9e18..ff0b05d1 100755 --- a/src/common.sh +++ b/src/common.sh @@ -17,7 +17,7 @@ function gitclone(){ if [ "$GIT_REPO_OVERRIDE" != "" ] ; then REPO=$GIT_REPO_OVERRIDE`echo $1 | awk -F '/' '{print $(NF)}'` sudo -u pi git clone $REPO - REPO_DIR_NAME=$(echo ${REPO} | 's%^.*/\([^/]*\)\.git$%\1%g') + REPO_DIR_NAME=$(echo ${REPO} | sed 's%^.*/\([^/]*\)\.git$%\1%g') pushd ${REPO_DIR_NAME} sudo -u pi git remote set-url $1 popd From 244cdc933ae6069cd2f5c2b8dc61e43e18b1fe33 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Thu, 9 Apr 2015 13:38:51 +0300 Subject: [PATCH 024/352] Add origin to line #74 --- src/common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common.sh b/src/common.sh index ff0b05d1..97d634a3 100755 --- a/src/common.sh +++ b/src/common.sh @@ -19,7 +19,7 @@ if [ "$GIT_REPO_OVERRIDE" != "" ] ; then sudo -u pi git clone $REPO REPO_DIR_NAME=$(echo ${REPO} | sed 's%^.*/\([^/]*\)\.git$%\1%g') pushd ${REPO_DIR_NAME} - sudo -u pi git remote set-url $1 + sudo -u pi git remote set-url origin $1 popd else sudo -u pi git clone $1 From 74d2ee174f3b7aef681d7bcc8b98304b87f7a321 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arkadiusz=20Mi=C5=9Bkiewicz?= Date: Thu, 14 May 2015 22:17:46 +0200 Subject: [PATCH 025/352] Store log for webcam daemon. --- src/chroot_script | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/chroot_script b/src/chroot_script index 74de73cc..6d361410 100755 --- a/src/chroot_script +++ b/src/chroot_script @@ -98,7 +98,7 @@ popd sed -i 's@exit 0@@' /etc/rc.local echo "/home/pi/scripts/genCert" >> /etc/rc.local -echo "sudo -u pi /home/pi/scripts/webcamDaemon &" >> /etc/rc.local +echo "sudo -u pi -s /bin/bash -c \"exec /home/pi/scripts/webcamDaemon > /home/pi/.octoprint/logs/webcam.log 2>&1\" &" >> /etc/rc.local echo "/usr/local/sbin/haproxy -f /etc/haproxy/haproxy.cfg" >> /etc/rc.local echo "exit 0" >> /etc/rc.local From 5803ee5d5f6451bc76f821411099064a938d3054 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 2 Jun 2015 16:15:01 +0200 Subject: [PATCH 026/352] Fix for #95: Check for zero sized ssl files While this doesn't solve the problem of these files being generated at 0 bytes size in the first place, it at least should make OctoPi reattempt to generate the certificate and thus fix the issue described in #95 (possibly after a couple of reboots). --- src/filesystem/home/scripts/genCert | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/filesystem/home/scripts/genCert b/src/filesystem/home/scripts/genCert index 8204637b..662b05d4 100755 --- a/src/filesystem/home/scripts/genCert +++ b/src/filesystem/home/scripts/genCert @@ -1,6 +1,10 @@ #!/bin/bash -if [ ! -f /etc/ssl/private/ssl-cert-snakeoil.key ]; then +keyfile=/etc/ssl/private/ssl-cert-snakeoil.key +pemfile=/etc/ssl/certs/ssl-cert-snakeoil.pem +certfile=/etc/ssl/snakeoil.pem + +if [ ! -f $keyfile ] || [ ! -s $keyfile ] || [ ! -f $pemfile ] || [ ! -s $pemfile ] || [ ! -f $certfile ] || [ ! -s $certfile ]; then echo "Generating SSL certificate" sudo make-ssl-cert generate-default-snakeoil --force-overwrite - sudo cat /etc/ssl/private/ssl-cert-snakeoil.key /etc/ssl/certs/ssl-cert-snakeoil.pem > /etc/ssl/snakeoil.pem + sudo cat $keyfile $pemfile > $certfile fi From 2291c00bbb97869160ef0bc6a489ba62c1f606d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 2 Jun 2015 18:25:04 +0200 Subject: [PATCH 027/352] Bind OctoPrint only to 127.0.0.1 This will prevent connections to http://:5000 from working and hence hopefully reduce the amount of support requests by users who connect with port 5000 for whatever reason and then don't understand why their webcams won't work. Should probably only be merged once the fix for #95 has been merged, since this effectively makes OctoPi only serve OctoPrint if haproxy is actually running. --- src/filesystem/root/etc/default/octoprint | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/filesystem/root/etc/default/octoprint b/src/filesystem/root/etc/default/octoprint index b956a183..5389e9c5 100644 --- a/src/filesystem/root/etc/default/octoprint +++ b/src/filesystem/root/etc/default/octoprint @@ -3,6 +3,9 @@ # The init.d script will only run if this variable non-empty. OCTOPRINT_USER=pi +# To what host to bind daemon, default is 127.0.0.1 +HOST=127.0.0.1 + # On what port to run daemon, default is 5000 PORT=5000 @@ -10,7 +13,7 @@ PORT=5000 DAEMON=/home/pi/oprint/bin/octoprint # What arguments to pass to octoprint, usually no need to touch this -DAEMON_ARGS="--port=$PORT" +DAEMON_ARGS="--host=$HOST --port=$PORT" # Umask of files octoprint generates, Change this to 000 if running octoprint as its own, separate user UMASK=022 From 8ddca4fb5df98208d23570e68362c2d276b7def2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 9 Jun 2015 17:55:07 +0200 Subject: [PATCH 028/352] Added configuration for Software Update plugin The plugin now is bundled with the current devel of OctoPrint, this makes it work on OctoPi (although since this configuration limits it to updating to releases only nothing can be seen yet) --- src/filesystem/home/.octoprint/config.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/filesystem/home/.octoprint/config.yaml b/src/filesystem/home/.octoprint/config.yaml index 9332f778..576212e0 100755 --- a/src/filesystem/home/.octoprint/config.yaml +++ b/src/filesystem/home/.octoprint/config.yaml @@ -2,6 +2,12 @@ webcam: stream: /webcam/?action=stream snapshot: http://127.0.0.1:8080/?action=snapshot ffmpeg: /usr/bin/avconv +plugins: + softwareupdate: + checks: + update_folder: /home/pi/OctoPrint + octoprint_restart_command: sudo service octoprint restart + environment_restart_command: sudo shutdown -r now system: actions: - name: Shutdown From 19f2ff497e8b209696692e470f53084c997a624a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Thu, 11 Jun 2015 13:28:50 +0000 Subject: [PATCH 029/352] Moved mount/umount commands to functions --- src/common.sh | 17 +++++++++++++++++ src/octopi | 6 ++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/common.sh b/src/common.sh index 97d634a3..367673e3 100755 --- a/src/common.sh +++ b/src/common.sh @@ -50,3 +50,20 @@ function install_fail_on_error_trap() { trap 'previous_command=$this_command; this_command=$BASH_COMMAND' DEBUG trap 'if [ $? -ne 0 ]; then echo -e "\nexit $? due to $previous_command \nBUILD FAILED!"; fi' EXIT } + +function mount_image() { + image_path=$1 + mount_path=$2 + + # mount root and boot partition + sudo mount -o loop,offset=$((512*122880)) $image_path $mount_path + sudo mount -o loop,offset=$((512*8192)) $image_path $mount_path/boot +} + +function unmount_image() { + mount_path=$1 + + # unmount first boot, then root partition + sudo umount $mount_path/boot + sudo umount $mount_path +} diff --git a/src/octopi b/src/octopi index cdd70629..c2fd9a07 100755 --- a/src/octopi +++ b/src/octopi @@ -37,8 +37,7 @@ pushd $OCTOPI_WORKSPACE IMG_PATH=`ls | grep .img` # mount root and boot partition - sudo mount -o loop,offset=$((512*122880)) $IMG_PATH $MOUNT_PATH - sudo mount -o loop,offset=$((512*8192)) $IMG_PATH $MOUNT_PATH/boot + mount_image $IMG_PATH $MOUNT_PATH #Edit pi filesystem pushd $MOUNT_PATH @@ -63,8 +62,7 @@ pushd $OCTOPI_WORKSPACE popd # unmount first boot, then root partition - sudo umount $MOUNT_PATH/boot - sudo umount $MOUNT_PATH + unmount_image $MOUNT_PATH chmod 777 $IMG_PATH popd From 1a140e1c981c82bf4ff8b1f84dd9ef239b43bfe6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Fri, 12 Jun 2015 13:32:48 +0200 Subject: [PATCH 030/352] Fix for my own PR #106 ... because that one was buggy and I didn't notice until now, sorry. Data structure was slightly wrong, this should however now be correct. Sorry for that. --- src/filesystem/home/.octoprint/config.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/filesystem/home/.octoprint/config.yaml b/src/filesystem/home/.octoprint/config.yaml index 576212e0..51cc4c62 100755 --- a/src/filesystem/home/.octoprint/config.yaml +++ b/src/filesystem/home/.octoprint/config.yaml @@ -5,7 +5,8 @@ webcam: plugins: softwareupdate: checks: - update_folder: /home/pi/OctoPrint + octoprint: + update_folder: /home/pi/OctoPrint octoprint_restart_command: sudo service octoprint restart environment_restart_command: sudo shutdown -r now system: From 881d4165b2f85d62f863534420f93d80eccd397c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Sat, 13 Jun 2015 15:58:17 +0000 Subject: [PATCH 031/352] Refactoring of config options & added CuraEngine * Configuration now has all our own config settings which also need to be exported for the chroot script to pick them up prefixed with "OCTOPI_" -- this allows the exporting to happen automatically and also allows some more intelligent handling later because... * Repository URLs, which might be mirrored, follow a naming scheme ("OCTOPI__REPO_BUILD" and "OCTOPI__REPO_SHIP") through which separate URLs can be configured for the building phase and the final image. If the config sets both the build and ship URL, those will be used as-is by "gitclone", if only the ship URL is set but OCTOPI_BUILD_REPO_MIRROR is set, the build URL will be translated to the configured mirror, if no mirror is configured the ship URL will be used during build too. * If OCTOPI__REPO_BRANCH is set, during checkout with gitclone that branch will be used, otherwise no -b parameter will be provided to git clone. * Config values may be overriden by variant, flavor and finally local config. Priority is config.local > flavor > variant > default. * build script can also just print the config that would be used for the build and exit if the environment var CONFIG_ONLY is set to "yes" (e.g. CONFIG_ONLY=yes ./build) * Config options OCTOPI_INCLUDE_ to enable/disable inclusion of OctoPrint, haproxy, mjpgstreamer, CuraEngine and OctoPiPanel -- useful during quick debug builds where not everything is needed. * Initscripts for haproxy and for the SSL certificate generation * Logging for haproxy * Logrotate for haproxy and the webcam daemon log (now at /var/log) * Error trap should also unmount the image if it's mounted (second trap function added for chroot error trapping) * chroot now fails on errors * merged unpack* functions into one a bit more intelligent helper function This is way too big a commit, I know, but I started fiddling around on one end and then suddenly found myself revamping the chroot script to accomodate the configuration changes, then I tested if those changes worked with CuraEngine, and suddenly I had touched these many files that separating all of the work again would have cost me hours if not days (in order to test the individual steps in between). So a big sorry for that, I'll try to help understanding with line annotations... --- src/build | 24 +- src/chroot_script | 248 ++++++++++++------ src/common.sh | 100 +++++-- src/config | 115 ++++++-- src/filesystem/home/.octoprint/config.yaml | 2 + src/filesystem/home/scripts/genCert | 10 - src/filesystem/home/scripts/webcamDaemon | 17 +- src/filesystem/root/etc/default/haproxy | 13 + src/filesystem/root/etc/haproxy/haproxy.cfg | 3 +- src/filesystem/root/etc/init.d/gencert | 41 +++ src/filesystem/root/etc/init.d/haproxy | 205 +++++++++++++++ src/filesystem/root/etc/logrotate.d/haproxy | 13 + .../root/etc/logrotate.d/webcamDaemon | 10 + .../root/etc/rsyslog.d/49-haproxy.conf | 7 + src/octopi | 24 +- src/variants/bananapi-m1/config | 39 +-- src/variants/bananapi-m1/pre_chroot_script | 7 +- src/variants/example/config | 11 +- src/variants/example/config.nightly | 5 +- src/variants/example/post_chroot_script | 10 +- 20 files changed, 691 insertions(+), 213 deletions(-) delete mode 100755 src/filesystem/home/scripts/genCert create mode 100644 src/filesystem/root/etc/default/haproxy create mode 100755 src/filesystem/root/etc/init.d/gencert create mode 100755 src/filesystem/root/etc/init.d/haproxy create mode 100644 src/filesystem/root/etc/logrotate.d/haproxy create mode 100644 src/filesystem/root/etc/logrotate.d/webcamDaemon create mode 100644 src/filesystem/root/etc/rsyslog.d/49-haproxy.conf diff --git a/src/build b/src/build index 9dd99f17..05fde46e 100755 --- a/src/build +++ b/src/build @@ -1,12 +1,18 @@ #!/usr/bin/env bash +set -e + BUILD_SCRIPT__PATH=$(dirname $(realpath -s $BASH_SOURCE)) source ${BUILD_SCRIPT__PATH}/common.sh OCTOPI_PATH=$(dirname $(realpath -s $0)) +pushd $OCTOPI_PATH + export OCTOPI_COMMIT=`git rev-parse HEAD` +popd BUILD_VARIANT=default BUILD_FLAVOR=default +WORKSPACE_POSTFIX= if [ "$#" -gt 0 ]; then BUILD_VARIANT=$1 @@ -16,17 +22,27 @@ if [ "$#" -gt 1 ]; then fi if [ $BUILD_VARIANT != 'default' ]; then + WORKSPACE_POSTFIX=-$BUILD_VARIANT + export VARIANT_BASE="$OCTOPI_PATH/variants/$BUILD_VARIANT" [ -d $VARIANT_BASE ] || die "Could not find Variant $BUILD_VARIANT" - if [ $BUILD_FLAVOR == '' ] || [ $BUILD_FLAVOR == 'default' ]; then - FLAVOR_CONFIG=$VARIANT_BASE/config + + if [ $BUILD_FLAVOR == '' ] || [ $BUILD_FLAVOR == 'default' ] + then + VARIANT_CONFIG=$VARIANT_BASE/config + FLAVOR_CONFIG= else + VARIANT_CONFIG=$VARIANT_BASE/config FLAVOR_CONFIG=$VARIANT_BASE/config.$BUILD_FLAVOR fi - source $FLAVOR_CONFIG || die "Could not find config file $FLAVOR_CONFIG" + + if [ -n "$FLAVOR_CONFIG" ] && [ ! -f $FLAVOR_CONFIG ] + then + die "Could not find config file $FLAVOR_CONFIG" + fi fi echo -e "--> Building VARIANT $BUILD_VARIANT, FLAVOR $BUILD_FLAVOR" source $OCTOPI_PATH/config -source $OCTOPI_PATH/octopi +[ "$CONFIG_ONLY" == "yes" ] || source $OCTOPI_PATH/octopi diff --git a/src/chroot_script b/src/chroot_script index 6d361410..9c6a75bb 100755 --- a/src/chroot_script +++ b/src/chroot_script @@ -1,5 +1,6 @@ #!/usr/bin/env bash set -x +set -e # OctoPI generation script # Helper script that runs in a Raspbian chroot to create the OctoPI distro # Written by Guy Sheffer @@ -7,109 +8,136 @@ set -x source /common.sh -unpackHome -unpackBoot +unpack /filesystem/home /home/pi pi +unpack /filesystem/boot /boot apt-get update -apt-get remove -y --purge scratch squeak-plugins-scratch squeak-vm wolfram-engine python-minecraftpi minecraft-pi sonic-pi oracle-java8-jdk python-serial +apt-get remove -y --purge scratch squeak-plugins-scratch squeak-vm wolfram-engine python-minecraftpi minecraft-pi sonic-pi oracle-java8-jdk #apt-get octoprint virtualenv -apt-get -y --force-yes install python-virtualenv python-dev git python-numpy screen libts-bin +apt-get -y --force-yes install python2.7 python-virtualenv python-dev git screen libts-bin subversion cmake checkinstall pushd /home/pi - + #build virtualenv sudo -u pi virtualenv --system-site-packages oprint - if [ -n $OVERRIDE_OCTOPRINT ] + # OctoPrint & pyserial + if [ "$OCTOPI_INCLUDE_OCTOPRINT" == "yes" ] then + echo "--- Installing OctoPrint" + apt-get install -y --force-yes python-numpy python-netifaces + apt-get remove -y python-serial + + #pyserial that can handle non-standard baud rates + sudo -u pi svn co http://pyserial.svn.sourceforge.net/svnroot/pyserial/trunk pyserial + pushd pyserial/pyserial + sudo -u pi /home/pi/oprint/bin/python setup.py install + popd + #OctoPrint - gitclone https://github.com/foosel/OctoPrint.git + gitclone OCTOPI_OCTOPRINT_REPO OctoPrint pushd OctoPrint - git checkout $OCTOPRINT_BRANCH - sudo -u pi /home/pi/oprint/bin/python setup.py install + PIP_DEFAULT_TIMEOUT=60 sudo -u pi /home/pi/oprint/bin/python setup.py install popd fi #OctoPiPanel - gitclone https://github.com/jonaslorander/OctoPiPanel.git - pushd OctoPiPanel - git checkout $OCTOPIPANEL_BRANCH - sudo -u pi /home/pi/oprint/bin/pip install -r requirements.txt - popd + if [ "$OCTOPI_INCLUDE_OCTOPIPANEL" == "yes" ] + then + echo "--- Installing OctoPiPanel" + gitclone OCTOPI_OCTOPIPANEL_REPO OctoPiPanel + pushd OctoPiPanel + sudo -u pi /home/pi/oprint/bin/pip install -r requirements.txt + popd - #Make sure user pi has access to serial ports - sudo usermod -a -G tty pi - sudo usermod -a -G dialout pi - - #mjpg-streamer - sudo apt-get -y --force-yes install subversion libjpeg8-dev imagemagick libav-tools cmake libv4l-dev - gitclone https://github.com/jacksonliam/mjpg-streamer.git - pushd mjpg-streamer - mv mjpg-streamer-experimental/* . - sudo -u pi make - popd - - #Add pyserial that can handle non-standard baud rates - sudo -u pi svn co http://pyserial.svn.sourceforge.net/svnroot/pyserial/trunk pyserial - pushd pyserial - pushd pyserial - sudo -u pi /home/pi/oprint/bin/python setup.py install + #Add fbcp for TFT screens + gitclone OCTOPI_FBCP_REPO rpi-fbcp + pushd rpi-fbcp + sudo -u pi mkdir build + pushd build + sudo -u pi cmake .. + sudo -u pi make + install fbcp /usr/local/bin/fbcp + sudo -u pi make clean popd - popd + popd + fi + + #mjpg-streamer + if [ "$OCTOPI_INCLUDE_MJPGSTREAMER" == "yes" ] + then + echo "--- Installing mjpg-streamer" + apt-get -y --force-yes install libjpeg8-dev imagemagick libav-tools libv4l-dev + gitclone OCTOPI_MJPGSTREAMER_REPO mjpg-streamer + pushd mjpg-streamer + mv mjpg-streamer-experimental/* . + sudo -u pi make + popd + fi - #make autostart scripts + #CuraEngine + if [ "$OCTOPI_INCLUDE_CURAENGINE" == "yes" ] + then + echo "--- Installing CuraEngine" + folder=CuraEngine-$OCTOPI_CURAENGINE_VERSION + zipfile=$folder.zip + apt-get -y install gcc-4.7 g++-4.7 + sudo -u pi wget -O$zipfile $OCTOPI_CURAENGINE_ARCHIVE + sudo -u pi unzip $zipfile + pushd $folder + sudo -u pi wget https://gist.githubusercontent.com/foosel/f86d6a729c0187ff8a82/raw/3d4f152b924080f502d887d11269f27a2389d64d/CuraEngine.patch + sudo -u pi patch < CuraEngine.patch + sudo -u pi make CXX=g++-4.7 VERSION=$OCTOPI_CURAENGINE_VERSION + cp build/CuraEngine /usr/local/bin/cura_engine + popd + sudo -u pi rm -r $folder $zipfile + fi + + #setup haproxy for http and https, and webcam + if [ "$OCTOPI_INCLUDE_HAPROXY" == "yes" ] + then + echo "--- Installing haproxy" + export HAPROXY_VERSION=OCTOPI_HAPROXY_VERSION + sudo apt-get -y --force-yes install ssl-cert libssl-dev libpcre3-dev + rm /etc/ssl/private/ssl-cert-snakeoil.key /etc/ssl/certs/ssl-cert-snakeoil.pem + sudo -u pi wget $OCTOPI_HAPROXY_ARCHIVE + sudo -u pi tar xzvf haproxy-$OCTOPI_HAPROXY_VERSION.tar.gz + rm haproxy-$OCTOPI_HAPROXY_VERSION.tar.gz + sudo -u pi mv `ls | grep haproxy | head -n 1` haproxy-ss + pushd haproxy-ss + sudo -u pi make TARGET=linux2628 USE_LINUX_SPLICE=1 USE_LINUX_TPROXY=1 USE_PCRE=1 USE_OPENSSL=1 + mkdir -p /usr/local/share/man/man1 /usr/local/doc /usr/local/doc/haproxy + sudo checkinstall --default --pkgname haproxy --pkgversion 1.5 + popd + rm -rf haproxy-ss + + adduser --system --disabled-password --disabled-login --home /var/lib/haproxy \ + --no-create-home --quiet --force-badname --group haproxy + fi + + #make script executable pushd scripts chmod 755 webcamDaemon - chmod 755 genCert popd - #setup haproxy for http and https, and webcam - export HAPROXY_VERSION=1.5.8 - sudo apt-get -y --force-yes install ssl-cert libssl-dev libpcre3-dev checkinstall - rm /etc/ssl/private/ssl-cert-snakeoil.key /etc/ssl/certs/ssl-cert-snakeoil.pem - sudo -u pi wget http://www.haproxy.org/download/1.5/src/haproxy-${HAPROXY_VERSION}.tar.gz - sudo -u pi tar xzvf haproxy-${HAPROXY_VERSION}.tar.gz - rm haproxy-${HAPROXY_VERSION}.tar.gz - sudo -u pi mv `ls | grep haproxy | head -n 1` haproxy-ss - pushd haproxy-ss - sudo -u pi make TARGET=linux2628 USE_LINUX_SPLICE=1 USE_LINUX_TPROXY=1 USE_PCRE=1 USE_OPENSSL=1 - mkdir -p /usr/local/share/man/man1 /usr/local/doc /usr/local/doc/haproxy - sudo checkinstall --default --pkgname haproxy --pkgversion 1.5 - popd - rm -rf haproxy-ss - - adduser --system --disabled-password --disabled-login --home /var/lib/haproxy \ - --no-create-home --quiet --force-badname --group haproxy - - #Add fbcp for TFT screens - gitclone https://github.com/tasanakorn/rpi-fbcp - pushd rpi-fbcp - mkdir build - pushd build - cmake .. - make - install fbcp /usr/local/bin/fbcp - make clean - popd - popd popd -sed -i 's@exit 0@@' /etc/rc.local +#Make sure user pi has access to serial ports +usermod -a -G tty pi +usermod -a -G dialout pi -echo "/home/pi/scripts/genCert" >> /etc/rc.local -echo "sudo -u pi -s /bin/bash -c \"exec /home/pi/scripts/webcamDaemon > /home/pi/.octoprint/logs/webcam.log 2>&1\" &" >> /etc/rc.local -echo "/usr/local/sbin/haproxy -f /etc/haproxy/haproxy.cfg" >> /etc/rc.local -echo "exit 0" >> /etc/rc.local +# store octopi commit used to build this image +echo "$OCTOPI_COMMIT" > /etc/octopi_commit -#automatic startup +# allow pi user to run shutdown and service commands echo "pi ALL=NOPASSWD: /sbin/shutdown" > /etc/sudoers.d/octoprint-shutdown echo "pi ALL=NOPASSWD: /sbin/service" > /etc/sudoers.d/octoprint-service #reach printer by name sudo apt-get -y --force-yes install avahi-daemon -echo "$OVERRIDE_HOSTNAME" > /etc/hostname -sed -i -e "s@raspberrypi@$OVERRIDE_HOSTNAME@g" /etc/hosts +echo "$OCTOPI_OVERRIDE_HOSTNAME" > /etc/hostname +sed -i -e "s@raspberrypi@$OCTOPI_OVERRIDE_HOSTNAME@g" /etc/hosts # enable raspicam echo "# enable raspicam" >> /boot/config.txt @@ -117,10 +145,78 @@ echo "start_x=1" >> /boot/config.txt echo "gpu_mem=128" >> /boot/config.txt #unpack root in the end, so etc file are not overwritten, might need to add two roots int he future -unpackRoot - -#setup runlevels for initscripts -sudo update-rc.d octoprint defaults 99 +unpack /filesystem/root / + +##################################################################### +### setup services + +### OctoPrint + +if [ "$OCTOPI_INCLUDE_OCTOPRINT" == "yes" ] +then + update-rc.d octoprint defaults 95 +else + # let's remove the configs for system services we don't need + rm /etc/init.d/octoprint + rm /etc/default/octoprint +fi + +### haproxy + +if [ "$OCTOPI_INCLUDE_HAPROXY" == "yes" ] +then + update-rc.d gencert defaults + update-rc.d haproxy defaults 99 +else + # let's remove the configs for system services we don't need + rm /etc/init.d/gencert + rm /etc/init.d/haproxy + rm /etc/default/haproxy + rm /etc/logrotate.d/haproxy + rm /etc/rsyslog.d/49-haproxy.conf + + # also we need to make OctoPrint bind to all interfaces because otherwise + # it will be unaccessible... + [ -f /etc/default/octoprint ] && sed -i "s@HOST=127.0.0.1@HOST=0.0.0.0@" /etc/default/octoprint +fi + +### CuraEngine + +if [ ! "$OCTOPI_INCLUDE_CURAENGINE" == "yes" ] +then + # unconfigure the cura engine path in octoprint's config.yaml + sudo -u pi sed -i -e "s@cura_engine: /usr/local/bin/cura_engine@cura_engine:@g" /home/pi/.octoprint/config.yaml +fi + +### mjpg_streamer + +if [ "$OCTOPI_INCLUDE_MJPGSTREAMER" == "yes" ] +then + # create logging directory for webcam service + mkdir -p /var/log/webcamd + chown pi:pi /var/log/webcamd + + # add webcamDaemon script to rc.local + sed -i 's@exit 0@@' /etc/rc.local + echo "sudo -u pi -s /bin/bash -c \"exec /home/pi/scripts/webcamDaemon > /var/log/webcamd/webcam.log 2>&1\" &" >> /etc/rc.local + echo "exit 0" >> /etc/rc.local +else + rm /etc/logrotate.d/webcamDaemon +fi + +### OctoPiPanel + +if [ ! "$OCTOPI_INCLUDE_OCTOPIPANEL" == "yes" ] +then + # we don't need the tft setup stuff + rm /home/pi/scripts/OctoPiPanel + rm /home/pi/scripts/calibrate-rpi-display + rm /home/pi/scripts/enable-adafruit-pitft + rm /home/pi/scripts/enable-rpi-display + rm /boot/cmdline-pi-tft.txt + rm /etc/udev/rules.d/95-ads7846.rules +fi #cleanup -sudo apt-get clean +apt-get clean +apt-get autoremove -y diff --git a/src/common.sh b/src/common.sh index 367673e3..6684496a 100755 --- a/src/common.sh +++ b/src/common.sh @@ -14,41 +14,73 @@ function restoreLd(){ } function gitclone(){ -if [ "$GIT_REPO_OVERRIDE" != "" ] ; then - REPO=$GIT_REPO_OVERRIDE`echo $1 | awk -F '/' '{print $(NF)}'` - sudo -u pi git clone $REPO - REPO_DIR_NAME=$(echo ${REPO} | sed 's%^.*/\([^/]*\)\.git$%\1%g') - pushd ${REPO_DIR_NAME} - sudo -u pi git remote set-url origin $1 + # call like this: gitclone OCTOPI_OCTOPRINT_REPO someDirectory -- this will do: + # + # sudo -u pi git clone -b $OCTOPI_OCTOPRINT_REPO_BRANCH $OCTOPI_OCTOPRINT_REPO_BUILD someDirectory + # + # and if $OCTOPI_OCTOPRINT_REPO_BUILD != $OCTOPI_OCTOPRINT_REPO_SHIP also: + # + # pushd someDirectory + # sudo -u pi git remote set-url origin $OCTOPI_OCTOPRINT_REPO_SHIP + # popd + # + # if second parameter is not provided last URL segment of the BUILD repo URL + # minus the optional .git postfix will be used + + repo_build_var=$1_BUILD + repo_ship_var=$1_SHIP + repo_branch_var=$1_BRANCH + + repo_dir=$2 + if [ ! -n "$repo_dir" ] + then + repo_dir=$(echo ${REPO} | sed 's%^.*/\([^/]*\)\(\.git\)?$%\1%g') + fi + + build_repo=${!repo_build_var} + ship_repo=${!repo_ship_var} + branch=${!repo_branch_var} + + if [ ! -n "$build_repo" ] + then + build_repo=$ship_repo + fi + + if [ -n "$branch" ] + then + sudo -u pi git clone -b $branch "$build_repo" "$repo_dir" + else + sudo -u pi git clone "$build_repo" "$repo_dir" + fi + + if [ "$build_repo" == "$ship_repo" ] + then + pushd "$repo_dir" + sudo -u pi git remote set-url origin "$ship_repo" popd -else - sudo -u pi git clone $1 -fi + fi } -function unpackHome(){ - shopt -s dotglob - cp -v -r --preserve=mode,timestamps /filesystem/home/* /home/pi - shopt -u dotglob - chown -hR pi:pi /home/pi -} +function unpack() { + # call like this: unpack /path/to/source /target user -- this will copy + # all files & folders from source to target, preserving mode and timestamps + # and chown to user. If user is not provided, no chown will be performed -function unpackRoot(){ - shopt -s dotglob - cp -v -r --preserve=mode,timestamps /filesystem/root/* / - shopt -u dotglob -} + from=$1 + to=$2 + owner= + if [ "$#" -gt 2 ] + then + owner=$3 + fi -function unpackBoot(){ shopt -s dotglob - cp -v -r --preserve=mode,timestamps /filesystem/boot/* /boot + cp -v -r --preserve=mode,timestamps $from/* $to shopt -u dotglob -} - -function install_fail_on_error_trap() { - set -e - trap 'previous_command=$this_command; this_command=$BASH_COMMAND' DEBUG - trap 'if [ $? -ne 0 ]; then echo -e "\nexit $? due to $previous_command \nBUILD FAILED!"; fi' EXIT + if [ -n "$owner" ] + then + chown -hR $owner:$owner $to + fi } function mount_image() { @@ -67,3 +99,15 @@ function unmount_image() { sudo umount $mount_path/boot sudo umount $mount_path } + +function install_fail_on_error_trap() { + set -e + trap 'previous_command=$this_command; this_command=$BASH_COMMAND' DEBUG + trap 'if [ $? -ne 0 ]; then echo -e "\nexit $? due to $previous_command \nBUILD FAILED!" && echo "unmounting image..." && ( unmount_image $OCTOPI_MOUNT_PATH || true ); fi;' EXIT +} + +function install_chroot_fail_on_error_trap() { + set -e + trap 'previous_command=$this_command; this_command=$BASH_COMMAND' DEBUG + trap 'if [ $? -ne 0 ]; then echo -e "\nexit $? due to $previous_command \nBUILD FAILED!"; fi;' EXIT +} diff --git a/src/config b/src/config index ce8f88ab..cfc51218 100755 --- a/src/config +++ b/src/config @@ -1,28 +1,109 @@ CONFIG_DIR=$(dirname $(realpath -s $BASH_SOURCE)) -export OCTOPRINT_BRANCH=devel -export OCTOPIPANEL_BRANCH=devel -if [ -f $CONFIG_DIR/config.local ]; then +# Import the variant config if we have one + +if [ -n "$VARIANT_CONFIG" ] && [ -f $VARIANT_CONFIG ] +then + echo "Sourceing variant config $VARIANT_CONFIG..." + source $VARIANT_CONFIG +fi + +# Import the flavor config if we have one + +if [ -n "$FLAVOR_CONFIG" ] && [ -f $FLAVOR_CONFIG ] +then + echo "Sourcing flavor config $FLAVOR_CONFIG..." + source $FLAVOR_CONFIG +fi + +# Import the local config if we have one + +if [ -f $CONFIG_DIR/config.local ] +then + echo "Sourcing config.local..." source $CONFIG_DIR/config.local fi -[ -n "$SCRIPT_PATH" ] || export SCRIPT_PATH=$CONFIG_DIR -[ -n "$IMAGE_PATH" ] || export IMAGE_PATH=$SCRIPT_PATH/image +############################################################################### +# All our config settings must start with OCTOPI_ + +[ -n "$OCTOPI_SCRIPT_PATH" ] || OCTOPI_SCRIPT_PATH=$CONFIG_DIR +[ -n "$OCTOPI_IMAGE_PATH" ] || OCTOPI_IMAGE_PATH=$OCTOPI_SCRIPT_PATH/image + +[ -n "$OCTOPI_ZIP_IMG" ] || OCTOPI_ZIP_IMG=`ls -t $OCTOPI_IMAGE_PATH/*-raspbian*.zip | head -n 1` + +[ -n "$OCTOPI_WORKSPACE" ] || OCTOPI_WORKSPACE=$OCTOPI_SCRIPT_PATH/workspace$WORKSPACE_POSTFIX +[ -n "$OCTOPI_CHROOT_SCRIPT_PATH" ] || OCTOPI_CHROOT_SCRIPT_PATH=$OCTOPI_SCRIPT_PATH/chroot_script +[ -n "$OCTOPI_MOUNT_PATH" ] || OCTOPI_MOUNT_PATH=$OCTOPI_WORKSPACE/mount + +[ -n "$OCTOPI_OVERRIDE_HOSTNAME" ] || OCTOPI_OVERRIDE_HOSTNAME=octopi + +[ -n "$OCTOPI_BUILD_REPO_MIRROR" ] || OCTOPI_BUILD_REPO_MIRROR= -[ -n "$ZIP_IMG" ] || export ZIP_IMG=`ls -t $IMAGE_PATH/*-raspbian*.zip | head -n 1` +# OctoPrint repo & branch +[ -n "$OCTOPI_OCTOPRINT_REPO_SHIP" ] || OCTOPI_OCTOPRINT_REPO_SHIP=https://github.com/foosel/OctoPrint.git +[ -n "$OCTOPI_OCTOPRINT_REPO_BUILD" ] || OCTOPI_OCTOPRINT_REPO_BUILD= +[ -n "$OCTOPI_OCTOPRINT_REPO_BRANCH" ] || OCTOPI_OCTOPRINT_REPO_BRANCH=master +[ -n "$OCTOPI_INCLUDE_OCTOPRINT" ] || OCTOPI_INCLUDE_OCTOPRINT=yes -[ -n "$OCTOPI_WORKSPACE" ] || export OCTOPI_WORKSPACE=$SCRIPT_PATH/workspace -[ -n "$CHROOT_SCRIPT_PATH" ] || export CHROOT_SCRIPT_PATH=$SCRIPT_PATH/chroot_script -[ -n "$MOUNT_PATH" ] || export MOUNT_PATH=$OCTOPI_WORKSPACE/mount -[ -n "$OVERRIDE_HOSTNAME" ] || export OVERRIDE_HOSTNAME=octopi +# OctoPiPanel repo & branch +[ -n "$OCTOPI_OCTOPIPANEL_REPO_SHIP" ] || OCTOPI_OCTOPIPANEL_REPO_SHIP=https://github.com/jonaslorander/OctoPiPanel.git +[ -n "$OCTOPI_OCTOPIPANEL_REPO_BUILD" ] || OCTOPI_OCTOPIPANEL_REPO_BUILD= +[ -n "$OCTOPI_OCTOPIPANEL_REPO_BRANCH" ] || OCTOPI_OCTOPIPANEL_REPO_BRANCH=master +[ -n "$OCTOPI_FBCP_REPO_SHIP" ] || OCTOPI_FBCP_REPO_SHIP=https://github.com/tasanakorn/rpi-fbcp +[ -n "$OCTOPI_FBCP_REPO_BUILD" ] || OCTOPI_FBCP_REPO_BUILD=$OCTOPI_FBCP_REPO_SHIP +[ -n "$OCTOPI_FBCP_REPO_BRANCH" ] || OCTOPI_FBCP_REPO_BRANCH= +[ -n "$OCTOPI_INCLUDE_OCTOPIPANEL" ] || OCTOPI_INCLUDE_OCTOPIPANEL=yes + +# CuraEngine archive & version +[ -n "$OCTOPI_CURAENGINE_VERSION" ] || OCTOPI_CURAENGINE_VERSION=15.04 +[ -n "$OCTOPI_CURAENGINE_ARCHIVE" ] || OCTOPI_CURAENGINE_ARCHIVE=https://github.com/Ultimaker/CuraEngine/archive/$OCTOPI_CURAENGINE_VERSION.zip +[ -n "$OCTOPI_INCLUDE_CURAENGINE" ] || OCTOPI_INCLUDE_CURAENGINE=yes + +# mjpg streamer +[ -n "$OCTOPI_MJPGSTREAMER_REPO_SHIP" ] || OCTOPI_MJPGSTREAMER_REPO_SHIP=https://github.com/jacksonliam/mjpg-streamer.git +[ -n "$OCTOPI_MJPGSTREAMER_REPO_BUILD" ] || OCTOPI_MJPGSTREAMER_REPO_BUILD= +[ -n "$OCTOPI_MJPGSTREAMER_REPO_BRANCH" ] || OCTOPI_MJPGSTREAMER_REPO_BRANCH=master +[ -n "$OCTOPI_INCLUDE_MJPGSTREAMER" ] || OCTOPI_INCLUDE_MJPGSTREAMER=yes + +# HAProxy +[ -n "$OCTOPI_HAPROXY_VERSION" ] || OCTOPI_HAPROXY_VERSION=1.5.8 +[ -n "$OCTOPI_HAPROXY_ARCHIVE" ] || OCTOPI_HAPROXY_ARCHIVE=http://www.haproxy.org/download/1.5/src/haproxy-$OCTOPI_HAPROXY_VERSION.tar.gz +[ -n "$OCTOPI_INCLUDE_HAPROXY" ] || OCTOPI_INCLUDE_HAPROXY=yes + + +############################################################################### +# Rewrite any build urls that are not yet set if we have a repository mirror +# configured. + +if [ -n "$OCTOPI_BUILD_REPO_MIRROR" ] +then + vars=`compgen -A variable | grep '^OCTOPI_' | grep 'REPO_BUILD'` + for var in $vars + do + if [ ! -n "${!var}" ] + then + repo_ship_var=${var%_BUILD}_SHIP + original=${!repo_ship_var} + rewritten=$OCTOPI_BUILD_REPO_MIRROR`echo $original | awk -F '/' '{print $(NF)}'` + + echo "Rewriting build repo for $var from $original to $rewritten" + eval $var=$rewritten + fi + done +fi + +############################################################################### +# Print and export the final configuration. echo "================================================================" echo "Using the following config:" -echo "SCRIPT_PATH = $SCRIPT_PATH" -echo "IMAGE_PATH = $IMAGE_PATH" -echo "ZIP_IMG = $ZIP_IMG" -echo "OCTOPI_WORKSPACE = $OCTOPI_WORKSPACE" -echo "CHROOT_SCRIPT_PATH = $CHROOT_SCRIPT_PATH" -echo "MOUNT_PATH = $MOUNT_PATH" -echo "OVERRIDE_HOSTNAME = $OVERRIDE_HOSTNAME" + +vars=`compgen -A variable | grep '^OCTOPI_'` +for var in $vars +do + echo "$var = ${!var}" + eval export $var +done + echo "================================================================" diff --git a/src/filesystem/home/.octoprint/config.yaml b/src/filesystem/home/.octoprint/config.yaml index 51cc4c62..694e22b2 100755 --- a/src/filesystem/home/.octoprint/config.yaml +++ b/src/filesystem/home/.octoprint/config.yaml @@ -3,6 +3,8 @@ webcam: snapshot: http://127.0.0.1:8080/?action=snapshot ffmpeg: /usr/bin/avconv plugins: + cura: + cura_engine: /usr/local/bin/cura_engine softwareupdate: checks: octoprint: diff --git a/src/filesystem/home/scripts/genCert b/src/filesystem/home/scripts/genCert deleted file mode 100755 index 662b05d4..00000000 --- a/src/filesystem/home/scripts/genCert +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -keyfile=/etc/ssl/private/ssl-cert-snakeoil.key -pemfile=/etc/ssl/certs/ssl-cert-snakeoil.pem -certfile=/etc/ssl/snakeoil.pem - -if [ ! -f $keyfile ] || [ ! -s $keyfile ] || [ ! -f $pemfile ] || [ ! -s $pemfile ] || [ ! -f $certfile ] || [ ! -s $certfile ]; then - echo "Generating SSL certificate" - sudo make-ssl-cert generate-default-snakeoil --force-overwrite - sudo cat $keyfile $pemfile > $certfile -fi diff --git a/src/filesystem/home/scripts/webcamDaemon b/src/filesystem/home/scripts/webcamDaemon index 1874f818..3f5b37b6 100755 --- a/src/filesystem/home/scripts/webcamDaemon +++ b/src/filesystem/home/scripts/webcamDaemon @@ -24,13 +24,13 @@ function runMjpgStreamer { # starts up the RasPiCam function startRaspi { - logger "Starting Raspberry Pi camera" + logger -s "Starting Raspberry Pi camera" runMjpgStreamer "$MJPGSTREAMER_INPUT_RASPICAM $camera_raspi_options" } # starts up the USB webcam function startUsb { - logger "Starting USB webcam" + logger -s "Starting USB webcam" runMjpgStreamer "$MJPGSTREAMER_INPUT_USB $camera_usb_options" } @@ -39,9 +39,14 @@ function startUsb { vcgencmd version # echo configuration -echo camera: $camera -echo usb options: $camera_usb_options -echo raspi options: $camera_raspi_options +echo "Starting up webcamDaemon..." +echo "" +echo "--- Configuration: -----------------------------" +echo "camera: $camera" +echo "usb options: $camera_usb_options" +echo "raspi options: $camera_raspi_options" +echo "-----------------------------------------------" +echo "" # keep mjpg streamer running if some camera is attached while true; do @@ -56,3 +61,5 @@ while true; do sleep 120 done +echo "Goodbye..." +echo "" \ No newline at end of file diff --git a/src/filesystem/root/etc/default/haproxy b/src/filesystem/root/etc/default/haproxy new file mode 100644 index 00000000..a6ced24e --- /dev/null +++ b/src/filesystem/root/etc/default/haproxy @@ -0,0 +1,13 @@ +# Configuration for /etc/init.d/haproxy + +# Path to the haproxy executable, use this to override the default setting "/usr/bin/octoprint" +HAPROXY=/usr/local/sbin/haproxy + +# Log for the configtest run +CONFIGTEST_LOG=/var/log/haproxy_configtest.log + +# Additional arguments to pass to haproxy +EXTRA_ARGS= + +# Should we run at startup? +ENABLED=1 diff --git a/src/filesystem/root/etc/haproxy/haproxy.cfg b/src/filesystem/root/etc/haproxy/haproxy.cfg index c12058d0..2acfa3c0 100644 --- a/src/filesystem/root/etc/haproxy/haproxy.cfg +++ b/src/filesystem/root/etc/haproxy/haproxy.cfg @@ -2,8 +2,7 @@ global maxconn 4096 user haproxy group haproxy - daemon - log 127.0.0.1 local0 debug + log 127.0.0.1 local1 debug defaults log global diff --git a/src/filesystem/root/etc/init.d/gencert b/src/filesystem/root/etc/init.d/gencert new file mode 100755 index 00000000..ce17b2be --- /dev/null +++ b/src/filesystem/root/etc/init.d/gencert @@ -0,0 +1,41 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: gencert +# Required-Start: $local_fs +# Required-Stop: +# Default-Start: S +# Default-Stop: +# Short-Description: Make sure an SSL certificate is generated for haproxy on first boot +# Description: +### END INIT INFO + +. /lib/lsb/init-functions + +do_start () { + keyfile=/etc/ssl/private/ssl-cert-snakeoil.key + pemfile=/etc/ssl/certs/ssl-cert-snakeoil.pem + certfile=/etc/ssl/snakeoil.pem + + if [ ! -f $keyfile ] || [ ! -s $keyfile ] || [ ! -f $pemfile ] || [ ! -s $pemfile ] || [ ! -f $certfile ] || [ ! -s $certfile ]; then + echo "Generating SSL certificate" + sudo make-ssl-cert generate-default-snakeoil --force-overwrite + sudo cat $keyfile $pemfile > $certfile + fi +} + +case "$1" in + start|"") + do_start + ;; + restart|reload|force-reload) + echo "Error: argument '$1' not supported" >&2 + exit 3 + ;; + stop) + # No-op + ;; + *) + echo "Usage: octopi_first_boot [start|stop]" >&2 + exit 3 + ;; +esac diff --git a/src/filesystem/root/etc/init.d/haproxy b/src/filesystem/root/etc/init.d/haproxy new file mode 100755 index 00000000..ad59720c --- /dev/null +++ b/src/filesystem/root/etc/init.d/haproxy @@ -0,0 +1,205 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: haproxy +# Required-Start: $local_fs $network $remote_fs +# Required-Stop: $local_fs $remote_fs +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: fast and reliable load balancing reverse proxy +# Description: This file should be used to start and stop haproxy. +### END INIT INFO + +# Author: Arnaud Cornet +# adjusted for OctoPi by Gina Haeussge + +PATH=/usr/local/sbin:/sbin:/usr/sbin:/bin:/usr/bin +PIDFILE=/var/run/haproxy.pid +CONFIG=/etc/haproxy/haproxy.cfg +HAPROXY=/usr/local/sbin/haproxy +CONFIGTEST_LOG=/var/log/haproxy_configtest.log +EXTRAOPTS= +ENABLED=0 + +test -x $HAPROXY || exit 0 +test -f "$CONFIG" || exit 0 + +if [ -e /etc/default/haproxy ]; then + . /etc/default/haproxy +fi + +test "$ENABLED" != "0" || exit 0 + +[ -f /etc/default/rcS ] && . /etc/default/rcS +. /lib/lsb/init-functions + + +haproxy_start() +{ + start-stop-daemon --start --pidfile "$PIDFILE" \ + --exec $HAPROXY -- -f "$CONFIG" -D -p "$PIDFILE" \ + $EXTRAOPTS || return 2 + return 0 +} + +haproxy_stop() +{ + if [ ! -f $PIDFILE ] ; then + # This is a success according to LSB + return 0 + fi + for pid in $(cat $PIDFILE) ; do + /bin/kill $pid || return 4 + done + rm -f $PIDFILE + return 0 +} + +haproxy_reload() +{ + $HAPROXY -f "$CONFIG" -p $PIDFILE -D $EXTRAOPTS -sf $(cat $PIDFILE) \ + || return 2 + return 0 +} + +haproxy_status() +{ + if [ ! -f $PIDFILE ] ; then + # program not running + return 3 + fi + + for pid in $(cat $PIDFILE) ; do + if ! ps --no-headers p "$pid" | grep haproxy > /dev/null ; then + # program running, bogus pidfile + return 1 + fi + done + + return 0 +} + +haproxy_configtest() +{ + $HAPROXY -f "$CONFIG" -c > "$CONFIGTEST_LOG" 2>&1 + ret=$? + if [ $ret -eq 0 ]; then + # Valid config - remove $CONFIGTEST_LOG + rm "$CONFIGTEST_LOG" + fi + + return $ret +} + + +case "$1" in +start) + log_daemon_msg "Starting haproxy" "haproxy" + haproxy_start + ret=$? + case "$ret" in + 0) + log_end_msg 0 + ;; + 1) + log_end_msg 1 + echo "pid file '$PIDFILE' found, haproxy not started." + ;; + 2) + log_end_msg 1 + ;; + esac + exit $ret + ;; +stop) + log_daemon_msg "Stopping haproxy" "haproxy" + haproxy_stop + ret=$? + case "$ret" in + 0|1) + log_end_msg 0 + ;; + 2) + log_end_msg 1 + ;; + esac + exit $ret + ;; +reload|force-reload) + log_daemon_msg "Reloading haproxy" "haproxy" + haproxy_reload + case "$?" in + 0|1) + log_end_msg 0 + ;; + 2) + log_end_msg 1 + ;; + esac + ;; +restart) + log_daemon_msg "Checking haproxy configuration" "haproxy" + haproxy_configtest + ret=$? + case "$ret" in + 0) + log_end_msg 0 + ;; + 1) + log_end_msg 1 + echo "Restart process aborted." + echo "Check $CONFIGTEST_LOG for details." + # Abort restart + exit $ret + ;; + esac + log_daemon_msg "Restarting haproxy" "haproxy" + haproxy_stop + haproxy_start + case "$?" in + 0) + log_end_msg 0 + ;; + 1) + log_end_msg 1 + ;; + 2) + log_end_msg 1 + ;; + esac + ;; +status) + haproxy_status + ret=$? + case "$ret" in + 0) + echo "haproxy is running." + ;; + 1) + echo "haproxy dead, but $PIDFILE exists." + ;; + *) + echo "haproxy not running." + ;; + esac + exit $ret + ;; +configtest) + haproxy_configtest + ret=$? + case "$ret" in + 0) + echo "haproxy configuration is valid." + ;; + 1) + echo "haproxy configuration is NOT valid. Check $CONFIGTEST_LOG for details." + ;; + esac + exit $ret + ;; +*) + echo "Usage: /etc/init.d/haproxy {start|stop|reload|restart|status|configtest}" + exit 2 + ;; +esac + +: \ No newline at end of file diff --git a/src/filesystem/root/etc/logrotate.d/haproxy b/src/filesystem/root/etc/logrotate.d/haproxy new file mode 100644 index 00000000..af5b46e5 --- /dev/null +++ b/src/filesystem/root/etc/logrotate.d/haproxy @@ -0,0 +1,13 @@ +/var/log/haproxy*.log +{ + rotate 4 + weekly + missingok + notifempty + compress + delaycompress + sharedscripts + postrotate + reload rsyslog >/dev/null 2>&1 || true + endscript +} \ No newline at end of file diff --git a/src/filesystem/root/etc/logrotate.d/webcamDaemon b/src/filesystem/root/etc/logrotate.d/webcamDaemon new file mode 100644 index 00000000..1a6be0bf --- /dev/null +++ b/src/filesystem/root/etc/logrotate.d/webcamDaemon @@ -0,0 +1,10 @@ +/var/log/webcamd/webcam.log +{ + rotate 4 + weekly + missingok + notifempty + compress + delaycompress + sharedscripts +} \ No newline at end of file diff --git a/src/filesystem/root/etc/rsyslog.d/49-haproxy.conf b/src/filesystem/root/etc/rsyslog.d/49-haproxy.conf new file mode 100644 index 00000000..5745714c --- /dev/null +++ b/src/filesystem/root/etc/rsyslog.d/49-haproxy.conf @@ -0,0 +1,7 @@ +$ModLoad imudp +$UDPServerAddress 127.0.0.1 +$UDPServerRun 514 + +# ..and in any case, put these two in /etc/rsyslog.d/49-haproxy.conf: +local1.* -/var/log/haproxy_1.log +& ~ diff --git a/src/octopi b/src/octopi index c2fd9a07..b0142731 100755 --- a/src/octopi +++ b/src/octopi @@ -4,8 +4,7 @@ # Written by Guy Sheffer # GPL V3 -source $SCRIPT_PATH/common.sh -install_fail_on_error_trap +source $OCTOPI_SCRIPT_PATH/common.sh function execute_chroot_script() { #move OctoPi filesystem files @@ -16,7 +15,7 @@ function execute_chroot_script() { cp $2 chroot_script chmod 755 chroot_script - cp $SCRIPT_PATH/common.sh common.sh + cp $OCTOPI_SCRIPT_PATH/common.sh common.sh chmod 755 common.sh chroot . usr/bin/qemu-arm-static /bin/bash /chroot_script @@ -27,20 +26,23 @@ function execute_chroot_script() { } mkdir -p $OCTOPI_WORKSPACE -mkdir -p $MOUNT_PATH +mkdir -p $OCTOPI_MOUNT_PATH + +install_fail_on_error_trap $OCTOPI_MOUNT_PATH +unmount_image $OCTOPI_MOUNT_PATH || true pushd $OCTOPI_WORKSPACE if [ -e *.img ]; then rm *.img fi - unzip $ZIP_IMG - IMG_PATH=`ls | grep .img` + unzip $OCTOPI_ZIP_IMG + OCTOPI_IMG_PATH=`ls | grep .img` # mount root and boot partition - mount_image $IMG_PATH $MOUNT_PATH + mount_image $OCTOPI_IMG_PATH $OCTOPI_MOUNT_PATH #Edit pi filesystem - pushd $MOUNT_PATH + pushd $OCTOPI_MOUNT_PATH #make QEMU boot (remember to return) fixLd @@ -51,7 +53,7 @@ pushd $OCTOPI_WORKSPACE fi # execute the base chroot script - execute_chroot_script $SCRIPT_PATH $CHROOT_SCRIPT_PATH + execute_chroot_script $OCTOPI_SCRIPT_PATH $OCTOPI_CHROOT_SCRIPT_PATH # if building a variant, execute its post-chroot script if [ -n "$VARIANT_BASE" ] && [ -f $VARIANT_BASE/post_chroot_script ]; then @@ -62,7 +64,7 @@ pushd $OCTOPI_WORKSPACE popd # unmount first boot, then root partition - unmount_image $MOUNT_PATH - chmod 777 $IMG_PATH + unmount_image $OCTOPI_MOUNT_PATH + chmod 777 $OCTOPI_IMG_PATH popd diff --git a/src/variants/bananapi-m1/config b/src/variants/bananapi-m1/config index 0fd0f51f..4f560c37 100755 --- a/src/variants/bananapi-m1/config +++ b/src/variants/bananapi-m1/config @@ -1,38 +1 @@ -#!/usr/bin/env bash - -# make sure to export all the variables to make them available to the chroot scripts as well - -# customize the hostname -#export OVERRIDE_HOSTNAME=blueberrypi - -# skip octoprint installation in main build script -#export OVERRIDE_OCTOPRINT=yes - -CONFIG_DIR=$(realpath -s $(dirname $(realpath -s $BASH_SOURCE))/../../) -VARIANT=$(basename $(dirname $(realpath -s $BASH_SOURCE))) -export OCTOPRINT_BRANCH=devel -export OCTOPIPANEL_BRANCH=devel - -if [ -f $CONFIG_DIR/config.local ]; then - source $CONFIG_DIR/config.local -fi - -[ -n "$SCRIPT_PATH" ] || export SCRIPT_PATH=$CONFIG_DIR -[ -n "$IMAGE_PATH" ] || export IMAGE_PATH=$SCRIPT_PATH/image-varients -[ -n "$ZIP_IMG" ] || export ZIP_IMG=`ls -t $IMAGE_PATH/*-raspbian-bpi-R1-M1*.zip | head -n 1` -[ -n "$OCTOPI_WORKSPACE" ] || export OCTOPI_WORKSPACE=$SCRIPT_PATH/workspace-${VARIANT} -[ -n "$CHROOT_SCRIPT_PATH" ] || export CHROOT_SCRIPT_PATH=$SCRIPT_PATH/chroot_script -[ -n "$MOUNT_PATH" ] || export MOUNT_PATH=$OCTOPI_WORKSPACE/mount -[ -n "$OVERRIDE_HOSTNAME" ] || export OVERRIDE_HOSTNAME=octopi - -echo "================================================================" -echo "Using the following config:" -echo "SCRIPT_PATH = $SCRIPT_PATH" -echo "IMAGE_PATH = $IMAGE_PATH" -echo "ZIP_IMG = $ZIP_IMG" -echo "OCTOPI_WORKSPACE = $OCTOPI_WORKSPACE" -echo "CHROOT_SCRIPT_PATH = $CHROOT_SCRIPT_PATH" -echo "MOUNT_PATH = $MOUNT_PATH" -echo "OVERRIDE_HOSTNAME = $OVERRIDE_HOSTNAME" -echo "================================================================" - +OCTOPI_ZIP_IMG=`ls -t $IMAGE_PATH/*-raspbian-bpi-R1-M1*.zip | head -n 1` diff --git a/src/variants/bananapi-m1/pre_chroot_script b/src/variants/bananapi-m1/pre_chroot_script index d8c00877..da988bb9 100755 --- a/src/variants/bananapi-m1/pre_chroot_script +++ b/src/variants/bananapi-m1/pre_chroot_script @@ -1,12 +1,11 @@ #!/usr/bin/env bash +set -x source /common.sh - -# exit script on any error -install_fail_on_error_trap +install_chroot_fail_on_error_trap # install dhclient.conf and possibly other files -unpackRoot +unpack /filesystem/root / #cleanup apt-get clean diff --git a/src/variants/example/config b/src/variants/example/config index 3ce7b42b..0f638e0b 100755 --- a/src/variants/example/config +++ b/src/variants/example/config @@ -1,9 +1,4 @@ -#!/usr/bin/env bash +# variant example, flavor default: override hostname & custom config setting -# make sure to export all the variables to make them available to the chroot scripts as well - -# customize the hostname -export OVERRIDE_HOSTNAME=blueberrypi - -# skip octoprint installation in main build script -export OVERRIDE_OCTOPRINT=yes +OCTOPI_OVERRIDE_HOSTNAME=blueberrypi +OCTOPI_EXAMPLE_CUSTOM="Hello there" diff --git a/src/variants/example/config.nightly b/src/variants/example/config.nightly index 679aae89..209b3bd4 100755 --- a/src/variants/example/config.nightly +++ b/src/variants/example/config.nightly @@ -1,4 +1,3 @@ -#!/usr/bin/env bash +# variant example, flavor nightly: override hostname & octoprint branch -export OVERRIDE_HOSTNAME=blueberrypi -export OVERRIDE_OCTOPRINT=no +OCTOPI_OCTOPRINT_REPO_BRANCH=devel diff --git a/src/variants/example/post_chroot_script b/src/variants/example/post_chroot_script index b05e4e88..da988bb9 100755 --- a/src/variants/example/post_chroot_script +++ b/src/variants/example/post_chroot_script @@ -1,15 +1,11 @@ #!/usr/bin/env bash +set -x source /common.sh - -# exit script on any error -install_fail_on_error_trap - -#change the hostname -sed -i 's@octopi@example@' /etc/hosts +install_chroot_fail_on_error_trap # install dhclient.conf and possibly other files -unpackRoot +unpack /filesystem/root / #cleanup apt-get clean From d0bd2b53ffb66d2a6ba9839345cbfb12f75a2544 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 15 Jun 2015 10:00:33 +0000 Subject: [PATCH 032/352] Moved filesystem/home to filesystem/home/pi Preparation for adding filesystem/home/root --- src/chroot_script | 2 +- src/filesystem/home/{ => pi}/.octoprint/config.yaml | 0 src/filesystem/home/{ => pi}/scripts/OctoPiPanel | 0 src/filesystem/home/{ => pi}/scripts/calibrate-rpi-display | 0 src/filesystem/home/{ => pi}/scripts/enable-adafruit-pitft | 0 src/filesystem/home/{ => pi}/scripts/enable-rpi-display | 0 src/filesystem/home/{ => pi}/scripts/webcamDaemon | 0 7 files changed, 1 insertion(+), 1 deletion(-) rename src/filesystem/home/{ => pi}/.octoprint/config.yaml (100%) mode change 100755 => 100644 rename src/filesystem/home/{ => pi}/scripts/OctoPiPanel (100%) rename src/filesystem/home/{ => pi}/scripts/calibrate-rpi-display (100%) rename src/filesystem/home/{ => pi}/scripts/enable-adafruit-pitft (100%) rename src/filesystem/home/{ => pi}/scripts/enable-rpi-display (100%) rename src/filesystem/home/{ => pi}/scripts/webcamDaemon (100%) diff --git a/src/chroot_script b/src/chroot_script index 9c6a75bb..2c461cbf 100755 --- a/src/chroot_script +++ b/src/chroot_script @@ -8,7 +8,7 @@ set -e source /common.sh -unpack /filesystem/home /home/pi pi +unpack /filesystem/home/pi /home/pi pi unpack /filesystem/boot /boot apt-get update diff --git a/src/filesystem/home/.octoprint/config.yaml b/src/filesystem/home/pi/.octoprint/config.yaml old mode 100755 new mode 100644 similarity index 100% rename from src/filesystem/home/.octoprint/config.yaml rename to src/filesystem/home/pi/.octoprint/config.yaml diff --git a/src/filesystem/home/scripts/OctoPiPanel b/src/filesystem/home/pi/scripts/OctoPiPanel similarity index 100% rename from src/filesystem/home/scripts/OctoPiPanel rename to src/filesystem/home/pi/scripts/OctoPiPanel diff --git a/src/filesystem/home/scripts/calibrate-rpi-display b/src/filesystem/home/pi/scripts/calibrate-rpi-display similarity index 100% rename from src/filesystem/home/scripts/calibrate-rpi-display rename to src/filesystem/home/pi/scripts/calibrate-rpi-display diff --git a/src/filesystem/home/scripts/enable-adafruit-pitft b/src/filesystem/home/pi/scripts/enable-adafruit-pitft similarity index 100% rename from src/filesystem/home/scripts/enable-adafruit-pitft rename to src/filesystem/home/pi/scripts/enable-adafruit-pitft diff --git a/src/filesystem/home/scripts/enable-rpi-display b/src/filesystem/home/pi/scripts/enable-rpi-display similarity index 100% rename from src/filesystem/home/scripts/enable-rpi-display rename to src/filesystem/home/pi/scripts/enable-rpi-display diff --git a/src/filesystem/home/scripts/webcamDaemon b/src/filesystem/home/pi/scripts/webcamDaemon similarity index 100% rename from src/filesystem/home/scripts/webcamDaemon rename to src/filesystem/home/pi/scripts/webcamDaemon From fac94a776e92936f295220791333066054c23da6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 15 Jun 2015 13:58:42 +0000 Subject: [PATCH 033/352] Better unpack using cp path/. instead of cp path/* The latter can have unexpected side effects if only one folder is contained within path/ --- src/common.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/common.sh b/src/common.sh index 6684496a..733c68c1 100755 --- a/src/common.sh +++ b/src/common.sh @@ -13,6 +13,12 @@ function restoreLd(){ sed -i 's@\#/usr/lib/arm-linux-gnueabihf/libcofi_rpi.so@/usr/lib/arm-linux-gnueabihf/libcofi_rpi.so@' etc/ld.so.preload } +function pause() { + # little debug helper, will pause until enter is pressed and display provided + # message + read -p "$*" +} + function gitclone(){ # call like this: gitclone OCTOPI_OCTOPRINT_REPO someDirectory -- this will do: # @@ -74,9 +80,10 @@ function unpack() { owner=$3 fi - shopt -s dotglob - cp -v -r --preserve=mode,timestamps $from/* $to - shopt -u dotglob + # $from/. may look funny, but does exactly what we want, copy _contents_ + # from $from to $to, but not $from itself, without the need to glob -- see + # http://stackoverflow.com/a/4645159/2028598 + cp -v -r --preserve=mode,timestamps $from/. $to if [ -n "$owner" ] then chown -hR $owner:$owner $to From 07ab28e0c0d01cf6ca2412ab0acd6a75b12d0b86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 15 Jun 2015 15:27:55 +0000 Subject: [PATCH 034/352] Fix: Actually do set the ship repo url But only if it's NOT equal to the build repo url. --- src/common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common.sh b/src/common.sh index 733c68c1..1f948eeb 100755 --- a/src/common.sh +++ b/src/common.sh @@ -59,7 +59,7 @@ function gitclone(){ sudo -u pi git clone "$build_repo" "$repo_dir" fi - if [ "$build_repo" == "$ship_repo" ] + if [ "$build_repo" != "$ship_repo" ] then pushd "$repo_dir" sudo -u pi git remote set-url origin "$ship_repo" From 2cd53c44bf6242f9d68ddac0b2b9d471b2e69866 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 15 Jun 2015 09:38:30 +0000 Subject: [PATCH 035/352] Added wrapper script for git for sudo This will be found first when executing sudo git and checks whether it is running with super user privileges and if so refuses to do that and instead just prints a friendly message to please run git without sudo. Reason: Apparently users tend to do a "sudo git pull" when updating OctoPrint, effectively screwing up their permissions in the process and then running into problems later on. This should hopefully act as an educational measure to stop this from happening. --- src/chroot_script | 6 ++++++ src/filesystem/home/root/bin/git | 9 +++++++++ 2 files changed, 15 insertions(+) create mode 100644 src/filesystem/home/root/bin/git diff --git a/src/chroot_script b/src/chroot_script index 2c461cbf..4250f631 100755 --- a/src/chroot_script +++ b/src/chroot_script @@ -9,6 +9,7 @@ set -e source /common.sh unpack /filesystem/home/pi /home/pi pi +unpack /filesystem/home/root /root root unpack /filesystem/boot /boot apt-get update @@ -139,6 +140,11 @@ sudo apt-get -y --force-yes install avahi-daemon echo "$OCTOPI_OVERRIDE_HOSTNAME" > /etc/hostname sed -i -e "s@raspberrypi@$OCTOPI_OVERRIDE_HOSTNAME@g" /etc/hosts +#make sure users don't run git with sudo, thus breaking permissions, by adding /root/bin to the +#default sudo path and placing a git wrapper script there that checks if it's run as root +sed -i "s@secure_path=\"@secure_path=\"/root/bin:@g" /etc/sudoers +chmod +x /root/bin/git + # enable raspicam echo "# enable raspicam" >> /boot/config.txt echo "start_x=1" >> /boot/config.txt diff --git a/src/filesystem/home/root/bin/git b/src/filesystem/home/root/bin/git new file mode 100644 index 00000000..31f499d5 --- /dev/null +++ b/src/filesystem/home/root/bin/git @@ -0,0 +1,9 @@ +#!/bin/bash + +if [ "$(id -u)" == "0" ] +then + echo "Please run git without sudo, your regular user account is enough :)" 2>&1 + exit 1 +fi + +/usr/bin/git "$@" \ No newline at end of file From 2a3d79ffee2d5aa5c8b6c54f9b5d090db60e1592 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Fri, 19 Jun 2015 04:16:57 +0300 Subject: [PATCH 036/352] Removing dead mirror --- README.rst | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.rst b/README.rst index dbc32042..46363acf 100644 --- a/README.rst +++ b/README.rst @@ -13,8 +13,6 @@ Where to get it? Official mirror is `here `_ -Alternative mirror is `here `_ - Nightly builds are avilable `here `_ How to use it? From fb6331edb82f408c99fd83be372188a2137f796e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Wed, 17 Jun 2015 19:15:52 +0200 Subject: [PATCH 037/352] Create a log file of the whole build --- src/build | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/build b/src/build index 05fde46e..ab9c69f8 100755 --- a/src/build +++ b/src/build @@ -2,6 +2,11 @@ set -e +[ -n "$LOG" ] || LOG="build.log" + +define(){ IFS='\n' read -r -d '' ${1} || true; } + +define SCRIPT <<'EOF' BUILD_SCRIPT__PATH=$(dirname $(realpath -s $BASH_SOURCE)) source ${BUILD_SCRIPT__PATH}/common.sh @@ -46,3 +51,6 @@ echo -e "--> Building VARIANT $BUILD_VARIANT, FLAVOR $BUILD_FLAVOR" source $OCTOPI_PATH/config [ "$CONFIG_ONLY" == "yes" ] || source $OCTOPI_PATH/octopi +EOF + +[ "$LOG" != "no" ] && (eval "$SCRIPT" 2>&1 | tee "$LOG") || eval "$SCRIPT" From 9a7306dc735419caa893c62003a4061a640fc07e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Wed, 17 Jun 2015 19:31:39 +0200 Subject: [PATCH 038/352] Enabled proper discovery of OctoPrint Install pybonjour & set external port in config.yaml to publish _octoprint._tcp and _http._tcp mdns services on. Pybonjour also needs avahi-daemon and libavahi-compat-libdnssd1, so moved avahi-daemon up and added the latter --- src/chroot_script | 6 ++++-- src/filesystem/home/pi/.octoprint/config.yaml | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/chroot_script b/src/chroot_script index 2c461cbf..13ec9a73 100755 --- a/src/chroot_script +++ b/src/chroot_script @@ -15,7 +15,7 @@ apt-get update apt-get remove -y --purge scratch squeak-plugins-scratch squeak-vm wolfram-engine python-minecraftpi minecraft-pi sonic-pi oracle-java8-jdk #apt-get octoprint virtualenv -apt-get -y --force-yes install python2.7 python-virtualenv python-dev git screen libts-bin subversion cmake checkinstall +apt-get -y --force-yes install python2.7 python-virtualenv python-dev git screen libts-bin subversion cmake checkinstall avahi-daemon libavahi-compat-libdnssd1 pushd /home/pi @@ -35,6 +35,9 @@ pushd /home/pi sudo -u pi /home/pi/oprint/bin/python setup.py install popd + #pybonjour (for mdns discovery) + sudo -u pi /home/pi/oprint/bin/pip install pybonjour + #OctoPrint gitclone OCTOPI_OCTOPRINT_REPO OctoPrint pushd OctoPrint @@ -135,7 +138,6 @@ echo "pi ALL=NOPASSWD: /sbin/shutdown" > /etc/sudoers.d/octoprint-shutdown echo "pi ALL=NOPASSWD: /sbin/service" > /etc/sudoers.d/octoprint-service #reach printer by name -sudo apt-get -y --force-yes install avahi-daemon echo "$OCTOPI_OVERRIDE_HOSTNAME" > /etc/hostname sed -i -e "s@raspberrypi@$OCTOPI_OVERRIDE_HOSTNAME@g" /etc/hosts diff --git a/src/filesystem/home/pi/.octoprint/config.yaml b/src/filesystem/home/pi/.octoprint/config.yaml index 694e22b2..c7eb4f9c 100644 --- a/src/filesystem/home/pi/.octoprint/config.yaml +++ b/src/filesystem/home/pi/.octoprint/config.yaml @@ -5,6 +5,8 @@ webcam: plugins: cura: cura_engine: /usr/local/bin/cura_engine + discovery: + publicPort: 80 softwareupdate: checks: octoprint: From 6893ec3dd0a0a088a7b66e4938ee2563eb294209 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 15 Jun 2015 13:45:50 +0200 Subject: [PATCH 039/352] Fixes webcamDaemon for Logitech C170 For whatever reason using the -f parameter with that specific camera model causes it to just not output any image. mjpgstreamer will start up just fine and not log an error or anything, the camera will appear to start up too, but when connecting to the webcam stream nothing will be displayed at all. Just removing the -f parameter in this case fixes it completely. This patch adds a new check to the webcamDaemon when starting up a USB webcam which checks the webcams USB vid and pid against a list of webcams known not to work with -f (right now that's just the C170, but more can be added easily by the user through the new additional_brokenfps_usb_devices option in /boot/octopi.txt) and if a match is found strips the -f parameter from the camera options. This is the only way I found I could make a C170 work. It would probably be cleaner to try to debug what's going wrong in mjpgstreamer there, but since that might as well be a problem with the chipset driver of the C170, this is a workaround that should at least yield a picture at a default frame rate. --- src/filesystem/boot/octopi.txt | 22 ++++++++++++ src/filesystem/home/pi/scripts/webcamDaemon | 38 +++++++++++++++++++-- 2 files changed, 58 insertions(+), 2 deletions(-) diff --git a/src/filesystem/boot/octopi.txt b/src/filesystem/boot/octopi.txt index d2427b3e..56b1c0fb 100644 --- a/src/filesystem/boot/octopi.txt +++ b/src/filesystem/boot/octopi.txt @@ -18,6 +18,28 @@ # #camera_usb_options="-r 640x480 -f 10" +### Additional webcam devices known to cause problems with -f +# +# Apparently there a some devices out there that with the current +# mjpg_streamer release do not support the -f parameter (for specifying +# the capturing framerate) and will just refuse to output an image if it +# is supplied. +# +# The webcam daemon will detect those devices by their USB Vendor and Product +# ID and remove the -f parameter from the options provided to mjpg_streamer. +# +# By default, this is done for the following devices: +# Logitech C170 (046d:082b) +# +# Using the following option it is possible to add additional devices. If +# your webcam happens to show above symptoms, try determining your cam's +# vendor and product id via lsusb, activating the line below by removing # and +# adding it as shown examplatory. +# +# If this fixes your problem, please report it back so we can include the device +# out of the box. +#additional_brokenfps_usb_devices=("046d:082b" "aabb:ccdd") + ### additional options to supply to MJPG Streamer for the RasPi Cam # # See https://github.com/foosel/OctoPrint/wiki/MJPG-Streamer-configuration diff --git a/src/filesystem/home/pi/scripts/webcamDaemon b/src/filesystem/home/pi/scripts/webcamDaemon index 3f5b37b6..1563ed54 100755 --- a/src/filesystem/home/pi/scripts/webcamDaemon +++ b/src/filesystem/home/pi/scripts/webcamDaemon @@ -8,11 +8,14 @@ MJPGSTREAMER_INPUT_RASPICAM="input_raspicam.so" camera="auto" camera_usb_options="-r 640x480 -f 10" camera_raspi_options="-fps 10" +additional_brokenfps_usb_devices=() if [ -e "/boot/octopi.txt" ]; then source "/boot/octopi.txt" fi +brokenfps_usb_devices=("046d:082b" "${additional_brokenfps_usb_devices[@]}") + # runs MJPG Streamer, using the provided input plugin + configuration function runMjpgStreamer { input=$1 @@ -30,8 +33,39 @@ function startRaspi { # starts up the USB webcam function startUsb { + options="$camera_usb_options" + device="video0" + + extracted_device=`echo $options | sed 's@.*-d /dev/\(video[0-9]+\).*@\1@'` + if [ "$extracted_device" != "$options" ] + then + # the camera options refer to another device, use that for determining product + device=$extracted_device + fi + + uevent_file="/sys/class/video4linux/$device/device/uevent" + if [ -e $uevent_file ]; then + # let's see what kind of webcam we have here, fetch vid and pid... + product=`cat $uevent_file | grep PRODUCT | cut -d"=" -f2` + vid=`echo $product | cut -d"/" -f1` + pid=`echo $product | cut -d"/" -f2` + vidpid=`printf "%04x:%04x" "0x$vid" "0x$pid"` + + # ... then look if it is in our list of known broken-fps-devices and if so remove + # the -f parameter from the options (if it's in there, else that's just a no-op) + for identifier in ${brokenfps_usb_devices[@]}; + do + if [ "$vidpid" = "$identifier" ]; then + echo + echo "Camera model $vidpid is known to not work with -f parameter, stripping it out" + echo + options=`echo $options | sed -e "s/\(\s\+\|^\)-f\s\+[0-9]\+//g"` + fi + done + fi + logger -s "Starting USB webcam" - runMjpgStreamer "$MJPGSTREAMER_INPUT_USB $camera_usb_options" + runMjpgStreamer "$MJPGSTREAMER_INPUT_USB $options" } # we need this to prevent the later calls to vcgencmd from blocking @@ -62,4 +96,4 @@ while true; do done echo "Goodbye..." -echo "" \ No newline at end of file +echo "" From b74e173b4563f1ed9c025010934ccc2d1a479396 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Wed, 24 Jun 2015 17:25:27 +0000 Subject: [PATCH 040/352] Allows network configuration without booting /etc/network/interfaces file is modified such that it includes a new file /boot/octopi-network.txt which contains sample config snippets for getting wifi connectivity configured for WPA/WPA2-PSK, WEP and unencrypted and also for a static IP on a virtual second ethernet port. This way after flashing the image to the SD the user can just edit that file (which is on the root of the FAT partition which desktop OSs should usually offer to access just when plugging in the card), uncomment the matching configuration snippet, fill in the credentials (SSID and password, or just the SSID in case of an unencrypted WiFi), save, put the card in the Pi's SD card slot and their USB WiFi dongle in a USB port, boot and have their Pi directly on their network. No more cable needed, no problem to quickly change the config when being on the move with the Pi. Note that I tested this with the new 15-05-05 Raspbian image (that includes that dhcpcd stuff), hence the "manual" mode on the wifi config segments instead of "dhcp". Test by flashing, editing the octopi-network.txt according to my local WiFi setup, booting and verifying I could immediately connect. Next step: netconnectd for everyone ;) --- src/chroot_script | 5 +++ src/filesystem/boot/octopi-network.txt | 53 ++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 src/filesystem/boot/octopi-network.txt diff --git a/src/chroot_script b/src/chroot_script index 853e085e..1c889803 100755 --- a/src/chroot_script +++ b/src/chroot_script @@ -152,6 +152,11 @@ echo "# enable raspicam" >> /boot/config.txt echo "start_x=1" >> /boot/config.txt echo "gpu_mem=128" >> /boot/config.txt +# allow network configuration via /boot/octopi-network.txt +sed -i "s@wpa-conf@# wpa-conf@g" /etc/network/interfaces +sed -i "s@iface wlan@# iface wlan@g" /etc/network/interfaces +echo "source /boot/octopi-network.txt" >> /etc/network/interfaces + #unpack root in the end, so etc file are not overwritten, might need to add two roots int he future unpack /filesystem/root / diff --git a/src/filesystem/boot/octopi-network.txt b/src/filesystem/boot/octopi-network.txt new file mode 100644 index 00000000..785067b4 --- /dev/null +++ b/src/filesystem/boot/octopi-network.txt @@ -0,0 +1,53 @@ +# You can use this file to manually set up your network configuration. +# +# This file is included into /etc/network/interfaces, so anything that +# works by editing that file is also possible here. + +### WIFI CONFIGURATION ###################################################### +# The three segments below should cover you in most cases if you run +# a wifi network that uses either WPA/WPA2 or WEP encryption. +# +# Just uncomment the lines prefixed with a single # of the configuration +# that matches your wifi setup and fill in SSID and passphrase. + +## WPA/WPA2 secured +#iface wlan0 inet manual +# wpa-ssid "put SSID here" +# wpa-psk "put password here" + +## WEP secured +#iface wlan0 inet manual +# wireless-essid "put SSID here" +# wireless-key "put password here" + +## Open/unsecured +#iface wlan0 inet manual +# wireless-essid "put SSID here" +# wireless-mode managed + +### WIRED CONFIGURATION ##################################################### +# The following segment allows you to configure your wired connection +# with a static IP. +# +# Just uncomment the lines prefixed with a single #. Then connect +# a cable to the Pi and another system, e.g. a Laptop, and set that +# other system's network configuration to: +# +# address: 192.168.250.10 +# netmask: 255.255.255.0 +# broadcast: 192.168.250.255 +# +# You can then reach the Pi from the system's browser by going to +# +# http://192.168.250.1 +# +# or +# +# http://octopi.local + +#auto eth0:1 +#iface eth0:1 inet static +# address 192.168.250.1 +# netmask 255.255.255.0 +# broadcast 192.168.250.255 + From 862afc7db4e963fa179439837e932096a73fe3ea Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Thu, 25 Jun 2015 12:18:21 +0300 Subject: [PATCH 041/352] Add jenkins rules if we run out of space on the image --- src/jenkins-ci/console_parsing | 1 + 1 file changed, 1 insertion(+) diff --git a/src/jenkins-ci/console_parsing b/src/jenkins-ci/console_parsing index 0f88926a..7033082d 100644 --- a/src/jenkins-ci/console_parsing +++ b/src/jenkins-ci/console_parsing @@ -1,3 +1,4 @@ error /BUILD FAILED/ error /mv: cannot stat/ error /md5sum: * No such file or directory/ +error /Error is not recoverable: exiting now/ From a11738cd5b6d3442c4e4ee92d648c2aec8adf48e Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Thu, 25 Jun 2015 12:22:59 +0300 Subject: [PATCH 042/352] Update nightly build scripts to match the change at #112 --- src/nightly_build_scripts/octopi_nightly_build | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/nightly_build_scripts/octopi_nightly_build b/src/nightly_build_scripts/octopi_nightly_build index 6e108496..177c48f4 100755 --- a/src/nightly_build_scripts/octopi_nightly_build +++ b/src/nightly_build_scripts/octopi_nightly_build @@ -14,7 +14,11 @@ pushd ${OCTOPIPATH} umount ${OCTOPIPATH}/src/workspace/mount/boot umount ${OCTOPIPATH}/src/workspace/mount git pull origin devel - export GIT_REPO_OVERRIDE='http://gnet.homelinux.com/git/' + export OCTOPI_OCTOPRINT_REPO_BUILD='http://localhost/git/OctoPrint.git/' + export OCTOPI_OCTOPIPANEL_REPO_BUILD='http://localhost/git/OctoPiPanel.git/' + export OCTOPI_FBCP_REPO_BUILD='http://localhost/git/rpi-fbcp.git/' + export OCTOPI_MJPGSTREAMER_REPO_BUILD='http://localhost/git/mjpg-streamer.git/' + ${OCTOPIPATH}/src/build $1 pushd src ${OCTOPIPATH}/src/release $1 From 099a3475f859ff5f2c254097f1a5354cb3548eb4 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Thu, 25 Jun 2015 12:25:20 +0300 Subject: [PATCH 043/352] Update premissions --- src/nightly_build_scripts/build_local_mirrors | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 src/nightly_build_scripts/build_local_mirrors diff --git a/src/nightly_build_scripts/build_local_mirrors b/src/nightly_build_scripts/build_local_mirrors old mode 100644 new mode 100755 From 8544af01c2587dc2d490f256633da2b2af84c122 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Thu, 25 Jun 2015 12:28:31 +0300 Subject: [PATCH 044/352] Add README for nightly build scripts --- src/nightly_build_scripts/README.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 src/nightly_build_scripts/README.rst diff --git a/src/nightly_build_scripts/README.rst b/src/nightly_build_scripts/README.rst new file mode 100644 index 00000000..ac417a15 --- /dev/null +++ b/src/nightly_build_scripts/README.rst @@ -0,0 +1,11 @@ +OctoPi Nightly Build Scripts +============================ + +The scripts in this folder are used to build OctoPi nightly. +The are also two scripts that help you checkout mirrors of the git repos used in the build, the cloning would not be done remotely fromt he github repos. + +* build_local_mirrors - Run this once to clone repos in to /var/www/git folder . +* update_git_mirrors - Run this before each build in order to update the mirrors. +* octopi_nightly_build - Run this to build OctoPi, can be set to run with sudo without a password so an executor like Jenkins can run it. + + From 5310a92e73c4a87477118cbbc75c4f7975f94590 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Thu, 25 Jun 2015 12:47:52 +0300 Subject: [PATCH 045/352] Updated docs to include Cura, and add a word about variants --- README.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.rst b/README.rst index 46363acf..8e3ef526 100644 --- a/README.rst +++ b/README.rst @@ -28,6 +28,7 @@ Features * `OctoPrint `_ host software for 3d printers out of the box * `Raspbian `_ tweaked for maximum preformance for printing out of the box * `mjpg-streamer with RaspiCam support `_ for live viewing of prints and timelapse video creation. +* `CuraEngine `_ pre-installed for slicing directly on the Raspberry Pi * `OctoPiPanel `_, which is an LCD display app that works with OctoPrint * Configuration scripts for verious LCD displays @@ -59,6 +60,15 @@ You can build it by issuing the following commands:: cd .. sudo modprobe loop sudo bash -x ./build + +Building OctoPi Variants +~~~~~~~~~~~~~~~~~~~~~~~~ + +OctoPi supports building variants, which are builds with changes from the main relesae build. An example and other variants are avilable in the folder ``src/variants/example``. + +To build a variant use: + +sudo bash -x ./build [Variant] Usage ~~~~~ From deb1b1f70a18f9ff354387054a63e3af9b31d0a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Fri, 26 Jun 2015 07:21:36 +0000 Subject: [PATCH 046/352] Turned webcamDaemon into new service webcamd Can now be started/stopped/restarted via regular sudo service webcamd (start|stop|restart) Should make it easier to experiment with configuration and even allow some configuration plugin for OctoPrint at a later date if need be. --- src/chroot_script | 20 +-- .../scripts/webcamDaemon => root/bin/webcamd} | 49 +++++-- src/filesystem/root/etc/default/webcamd | 13 ++ src/filesystem/root/etc/init.d/webcamd | 137 ++++++++++++++++++ .../etc/logrotate.d/{webcamDaemon => webcamd} | 4 +- 5 files changed, 194 insertions(+), 29 deletions(-) rename src/filesystem/home/{pi/scripts/webcamDaemon => root/bin/webcamd} (75%) create mode 100644 src/filesystem/root/etc/default/webcamd create mode 100755 src/filesystem/root/etc/init.d/webcamd rename src/filesystem/root/etc/logrotate.d/{webcamDaemon => webcamd} (78%) diff --git a/src/chroot_script b/src/chroot_script index 1c889803..93d943f7 100755 --- a/src/chroot_script +++ b/src/chroot_script @@ -119,11 +119,6 @@ pushd /home/pi adduser --system --disabled-password --disabled-login --home /var/lib/haproxy \ --no-create-home --quiet --force-badname --group haproxy fi - - #make script executable - pushd scripts - chmod 755 webcamDaemon - popd popd @@ -205,16 +200,13 @@ fi if [ "$OCTOPI_INCLUDE_MJPGSTREAMER" == "yes" ] then - # create logging directory for webcam service - mkdir -p /var/log/webcamd - chown pi:pi /var/log/webcamd - - # add webcamDaemon script to rc.local - sed -i 's@exit 0@@' /etc/rc.local - echo "sudo -u pi -s /bin/bash -c \"exec /home/pi/scripts/webcamDaemon > /var/log/webcamd/webcam.log 2>&1\" &" >> /etc/rc.local - echo "exit 0" >> /etc/rc.local + # make webcamd autostart + update-rc.d webcamd defaults else - rm /etc/logrotate.d/webcamDaemon + rm /etc/logrotate.d/webcamd + rm /etc/init.d/webcamd + rm /etc/default/webcamd + rm /root/bin/webcamd fi ### OctoPiPanel diff --git a/src/filesystem/home/pi/scripts/webcamDaemon b/src/filesystem/home/root/bin/webcamd similarity index 75% rename from src/filesystem/home/pi/scripts/webcamDaemon rename to src/filesystem/home/root/bin/webcamd index 1563ed54..fb359492 100755 --- a/src/filesystem/home/pi/scripts/webcamDaemon +++ b/src/filesystem/home/root/bin/webcamd @@ -16,13 +16,30 @@ fi brokenfps_usb_devices=("046d:082b" "${additional_brokenfps_usb_devices[@]}") +# cleans up when the script receives a SIGINT or SIGTERM +function cleanup() { + # make sure that all child processed die when we die + local pids=$(jobs -pr) + [ -n "$pids" ] && kill $pids + exit 0 +} + +# says goodbye when the script shuts down +function goodbye() { + # say goodbye + echo "" + echo "Goodbye..." + echo "" +} + # runs MJPG Streamer, using the provided input plugin + configuration function runMjpgStreamer { input=$1 - pushd $MJPGSTREAMER_HOME - echo Running ./mjpg_streamer -o "output_http.so -w ./www" -i "$input" - LD_LIBRARY_PATH=. ./mjpg_streamer -o "output_http.so -w ./www" -i "$input" - popd + pushd $MJPGSTREAMER_HOME > /dev/null 2>&1 + echo Running ./mjpg_streamer -o "output_http.so -w ./www" -i "$input" + LD_LIBRARY_PATH=. ./mjpg_streamer -o "output_http.so -w ./www" -i "$input" & + wait + popd > /dev/null 2>&1 } # starts up the RasPiCam @@ -68,32 +85,38 @@ function startUsb { runMjpgStreamer "$MJPGSTREAMER_INPUT_USB $options" } -# we need this to prevent the later calls to vcgencmd from blocking -# I have no idea why, but that's how it is... -vcgencmd version +# make sure our cleanup function gets called when we receive SIGINT, SIGTERM +trap "cleanup" SIGINT SIGTERM +# say goodbye when we EXIT +trap "goodbye" EXIT # echo configuration echo "Starting up webcamDaemon..." echo "" -echo "--- Configuration: -----------------------------" +echo "--- Configuration: ----------------------------" echo "camera: $camera" echo "usb options: $camera_usb_options" echo "raspi options: $camera_raspi_options" echo "-----------------------------------------------" echo "" +# we need this to prevent the later calls to vcgencmd from blocking +# I have no idea why, but that's how it is... +vcgencmd version > /dev/null 2>&1 + # keep mjpg streamer running if some camera is attached while true; do if [ -e "/dev/video0" ] && { [ "$camera" = "auto" ] || [ "$camera" = "usb" ] ; }; then startUsb + sleep 30 & + wait elif [ "`vcgencmd get_camera`" = "supported=1 detected=1" ] && { [ "$camera" = "auto" ] || [ "$camera" = "raspi" ] ; }; then startRaspi + sleep 30 & + wait else echo "No camera detected, trying again in two minutes" + sleep 120 & + wait fi - - sleep 120 done - -echo "Goodbye..." -echo "" diff --git a/src/filesystem/root/etc/default/webcamd b/src/filesystem/root/etc/default/webcamd new file mode 100644 index 00000000..cdbae578 --- /dev/null +++ b/src/filesystem/root/etc/default/webcamd @@ -0,0 +1,13 @@ +# Configuration for /etc/init.d/webcamd + +# Daemon +DAEMON=/root/bin/webcamd + +# Log file to use +LOG=/var/log/webcamd.log + +# User to run under +USER=pi + +# Should we run at startup? +ENABLED=1 diff --git a/src/filesystem/root/etc/init.d/webcamd b/src/filesystem/root/etc/init.d/webcamd new file mode 100755 index 00000000..a7cf3959 --- /dev/null +++ b/src/filesystem/root/etc/init.d/webcamd @@ -0,0 +1,137 @@ +#!/bin/sh + +### BEGIN INIT INFO +# Provides: webcamd +# Required-Start: $local_fs networking +# Required-Stop: +# Should-Start: +# Should-Stop: +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: webcam daemon +# Description: Starts the OctoPi webcam daemon with the user specified config in +# /etc/default/webcamd. +### END INIT INFO + +# Author: Gina Haeussge + +PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin +DESC="Webcam Daemon" +NAME="webcamd" +DAEMON=/root/bin/webcamd +USER=pi +PIDFILE=/var/run/$NAME.pid +PKGNAME=webcamd +SCRIPTNAME=/etc/init.d/$PKGNAME +LOG=/var/log/webcamd.log + +# Read configuration variable file if it is present +[ -r /etc/default/$PKGNAME ] && . /etc/default/$PKGNAME + +# Exit if the octoprint is not installed +[ -x "$DAEMON" ] || exit 0 + +# Load the VERBOSE setting and other rcS variables +[ -f /etc/default/rcS ] && . /etc/default/rcS + +# Define LSB log_* functions. +# Depend on lsb-base (>= 3.0-6) to ensure that this file is present. +. /lib/lsb/init-functions + +if [ -z "$ENABLED" -o "$ENABLED" != "1" ] +then + log_warning_msg "Not starting $PKGNAME, edit /etc/default/$PKGNAME to start it." + exit 0 +fi + +# +# Function to verify if a pid is alive +# +is_alive() +{ + pid=`cat $1` > /dev/null 2>&1 + kill -0 $pid > /dev/null 2>&1 + return $? +} + +# +# Function that starts the daemon/service +# +do_start() +{ + # Return + # 0 if daemon has been started + # 1 if daemon was already running + # 2 if daemon could not be started + + is_alive $PIDFILE + RETVAL="$?" + + if [ $RETVAL != 0 ]; then + start-stop-daemon --start --background --no-close --quiet --pidfile $PIDFILE --make-pidfile \ + --startas /bin/bash --chuid $USER --user $USER -- -c "exec $DAEMON" >> $LOG 2>&1 + RETVAL="$?" + fi +} + +# +# Function that stops the daemon/service +# +do_stop() +{ + # Return + # 0 if daemon has been stopped + # 1 if daemon was already stopped + # 2 if daemon could not be stopped + # other if a failure occurred + + start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --user $USER --pidfile $PIDFILE + RETVAL="$?" + [ "$RETVAL" = "2" ] && return 2 + + rm -f $PIDFILE + + [ "$RETVAL" = "0" ] && return 0 || return 1 +} + +case "$1" in + start) + [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" + do_start + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + stop) + [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" + do_stop + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + restart) + log_daemon_msg "Restarting $DESC" "$NAME" + do_stop + case "$?" in + 0|1) + do_start + case "$?" in + 0) log_end_msg 0 ;; + 1) log_end_msg 1 ;; # Old process is still running + *) log_end_msg 1 ;; # Failed to start + esac + ;; + *) + # Failed to stop + log_end_msg 1 + ;; + esac + ;; + *) + echo "Usage: $SCRIPTNAME {start|stop|restart}" >&2 + exit 3 + ;; +esac + diff --git a/src/filesystem/root/etc/logrotate.d/webcamDaemon b/src/filesystem/root/etc/logrotate.d/webcamd similarity index 78% rename from src/filesystem/root/etc/logrotate.d/webcamDaemon rename to src/filesystem/root/etc/logrotate.d/webcamd index 1a6be0bf..5c148ac0 100644 --- a/src/filesystem/root/etc/logrotate.d/webcamDaemon +++ b/src/filesystem/root/etc/logrotate.d/webcamd @@ -1,4 +1,4 @@ -/var/log/webcamd/webcam.log +/var/log/webcam.log { rotate 4 weekly @@ -7,4 +7,4 @@ compress delaycompress sharedscripts -} \ No newline at end of file +} From 907d4044113b5a412e35010c50cf46614657becd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Sat, 27 Jun 2015 07:33:48 +0000 Subject: [PATCH 047/352] Suppress error when using restart command When issuing one of the restart/reboot/shutdown commands from the system menu, the request could not be acknowledged anymore because the server was already gone, leading to the client displaying an error for the command execution just before the offline overlay. To stop things like this from happening, 1.2.0 introduced two new parameters for system actions, asnyc and ignore. async makes the request return without waiting for the result of the command's execution. ignore makes the client ignore any errors in the command's execution. The combination of both yields successful restarts/reboots/ shutdowns without scary messages. --- src/filesystem/home/pi/.octoprint/config.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/filesystem/home/pi/.octoprint/config.yaml b/src/filesystem/home/pi/.octoprint/config.yaml index c7eb4f9c..51daab56 100644 --- a/src/filesystem/home/pi/.octoprint/config.yaml +++ b/src/filesystem/home/pi/.octoprint/config.yaml @@ -19,11 +19,17 @@ system: command: sudo shutdown -h now action: shutdown confirm: You are about to shutdown the system. + async: true + ignore: true - name: Reboot command: sudo shutdown -r now action: reboot confirm: You are about to reboot the system + async: true + ignore: true - name: Restart OctoPrint command: sudo service octoprint restart action: restart confirm: You are about to restart OctoPrint + async: true + ignore: true From e4cc3cf4076d4c1e9c33b6d086d616bde69cadff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Sat, 27 Jun 2015 12:00:46 +0000 Subject: [PATCH 048/352] README update: usage instructions & typos Added some more steps to the usage instructions for the new network setup mechanism and explained CuraEngine setup needs slicing profile to be added by the user. Also fixed typos where I stumbled over them. --- README.rst | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/README.rst b/README.rst index 8e3ef526..2b3198d5 100644 --- a/README.rst +++ b/README.rst @@ -13,18 +13,25 @@ Where to get it? Official mirror is `here `_ -Nightly builds are avilable `here `_ +Nightly builds are available `here `_ How to use it? -------------- -#. unzip the image and dd it to an sd card like any other Raspberry Pi image -#. boot the pi and connect it to a lan or wifi network, like any other Rasbpian installation. -#. OctoPrint is located at `http://octopi.local `_ and also at `https://octopi.local `_. Since the SSL certificate is self signed (and generated upon first boot), you will get a certificate warning at the latter location, please ignore it. -#. If a webcam was plugged in, MJPG-streamer is on port 8080. You can reach it at: `http://octopi.local:8080/?action=stream `_. It is also setup so that you can reach it under `http://octopi.local/webcam/?action=stream `_ and SSL respectively. +#. Unzip the image and install it to an sd card `like any other Raspberry Pi image `_ +#. Configure your WiFi by editing ``octopi-network.txt`` on the root of the flashed card when using it like a thumb drive +#. Boot the Pi from the card +#. Log into your Pi via SSH (it is located at ``octopi.local`` `if your computer supports bonjour `_ or the IP address assigned by your router), default username is "pi", default password is "raspberry", change the password using the ``passwd`` command and expand the filesystem of the SD card through the corresponding option when running ``sudo raspi-config``. + +OctoPrint is located at `http://octopi.local `_ and also at `https://octopi.local `_. Since the SSL certificate is self signed (and generated upon first boot), you will get a certificate warning at the latter location, please ignore it. + +If a USB webcam or the Raspberry Pi camera is detected, MJPG-streamer will be started automatically as webcam server. OctoPrint on OctoPi ships with correctly configured stream and snapshot URLs pointing at it. If necessary, you can reach it under `http://octopi.local/webcam/?action=stream `_ and SSL respectively, or directly on its configured port 8080: `http://octopi.local:8080/?action=stream `_. + +CuraEngine is installed and OctoPrint ships pre-configured with the correct path to utilize it for on-board-slicing. Just import a Cura Slicing Profile in OctoPrint's settings and start slicing directly on your Pi. Features -------- + * `OctoPrint `_ host software for 3d printers out of the box * `Raspbian `_ tweaked for maximum preformance for printing out of the box * `mjpg-streamer with RaspiCam support `_ for live viewing of prints and timelapse video creation. From 5557f97431bf5a3dc5b907d3292c7fa6b57bf7af Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Sun, 28 Jun 2015 16:43:11 +0300 Subject: [PATCH 049/352] Update code block --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 2b3198d5..d8954e20 100644 --- a/README.rst +++ b/README.rst @@ -75,7 +75,7 @@ OctoPi supports building variants, which are builds with changes from the main r To build a variant use: -sudo bash -x ./build [Variant] + sudo bash -x ./build [Variant] Usage ~~~~~ From 530b046c601d3b879d720f08ccb49d08e30bf495 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Sun, 28 Jun 2015 16:57:35 +0300 Subject: [PATCH 050/352] Fix typo in syntax --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index d8954e20..aaf1eeef 100644 --- a/README.rst +++ b/README.rst @@ -73,7 +73,7 @@ Building OctoPi Variants OctoPi supports building variants, which are builds with changes from the main relesae build. An example and other variants are avilable in the folder ``src/variants/example``. -To build a variant use: +To build a variant use:: sudo bash -x ./build [Variant] From 9052ed829be91cd04f9b6c4c01d505ffcb7b914c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Thu, 9 Jul 2015 12:47:06 +0000 Subject: [PATCH 051/352] Added mapper for network configuration Will decide between OctoPi and Raspbian type of network configuration depending on whether the user set up a network configuration in /boot/octopi-network.txt or not. A mapping script will try to see if it can find an uncommented line iface $IFACE-octopi in /boot/octopi-network.txt. If so, the user obviously used this method to setup their network credentials (the lines are usually all commented out) and $IFACE will be mapped to use the $IFACE-octopi definition from that file. If no such line is found, $IFACE will be mapped to $IFACE-raspbian, which is the default wlan0/wlan1 configuration shipped with vanilla Raspbian. See also #122 --- src/chroot_script | 8 ++++++-- src/filesystem/boot/octopi-network.txt | 6 +++--- src/filesystem/home/root/bin/map_iface | 13 +++++++++++++ src/filesystem/root/etc/logrotate.d/map_iface.log | 10 ++++++++++ 4 files changed, 32 insertions(+), 5 deletions(-) create mode 100755 src/filesystem/home/root/bin/map_iface create mode 100644 src/filesystem/root/etc/logrotate.d/map_iface.log diff --git a/src/chroot_script b/src/chroot_script index 93d943f7..a440941a 100755 --- a/src/chroot_script +++ b/src/chroot_script @@ -148,8 +148,12 @@ echo "start_x=1" >> /boot/config.txt echo "gpu_mem=128" >> /boot/config.txt # allow network configuration via /boot/octopi-network.txt -sed -i "s@wpa-conf@# wpa-conf@g" /etc/network/interfaces -sed -i "s@iface wlan@# iface wlan@g" /etc/network/interfaces +sed -i "s@iface wlan0 @iface wlan0-raspbian @g" /etc/network/interfaces +sed -i "s@iface wlan1 @iface wlan1-raspbian @g" /etc/network/interfaces +echo "mapping wlan0" >> /etc/network/interfaces +echo " script /root/bin/map_iface" >> /etc/network/interfaces +echo "mapping wlan1" >> /etc/network/interfaces +echo " script /root/bin/map_iface" >> /etc/network/interfaces echo "source /boot/octopi-network.txt" >> /etc/network/interfaces #unpack root in the end, so etc file are not overwritten, might need to add two roots int he future diff --git a/src/filesystem/boot/octopi-network.txt b/src/filesystem/boot/octopi-network.txt index 785067b4..17343a35 100644 --- a/src/filesystem/boot/octopi-network.txt +++ b/src/filesystem/boot/octopi-network.txt @@ -11,17 +11,17 @@ # that matches your wifi setup and fill in SSID and passphrase. ## WPA/WPA2 secured -#iface wlan0 inet manual +#iface wlan0-octopi inet manual # wpa-ssid "put SSID here" # wpa-psk "put password here" ## WEP secured -#iface wlan0 inet manual +#iface wlan0-octopi inet manual # wireless-essid "put SSID here" # wireless-key "put password here" ## Open/unsecured -#iface wlan0 inet manual +#iface wlan0-octopi inet manual # wireless-essid "put SSID here" # wireless-mode managed diff --git a/src/filesystem/home/root/bin/map_iface b/src/filesystem/home/root/bin/map_iface new file mode 100755 index 00000000..f8fa3b3f --- /dev/null +++ b/src/filesystem/home/root/bin/map_iface @@ -0,0 +1,13 @@ +#!/bin/sh +set -e + +IFACE=$1 + +if grep -q "^\s*iface $IFACE-octopi " /boot/octopi-network.txt +then + echo "$IFACE-octopi" + echo "Using /boot/octopi-network.txt for configuring $IFACE..." >> /var/log/map_iface.log +else + echo "$IFACE-raspbian" + echo "Using original Raspbian configuration for configuring $IFACE..." >> /var/log/map_iface.log +fi diff --git a/src/filesystem/root/etc/logrotate.d/map_iface.log b/src/filesystem/root/etc/logrotate.d/map_iface.log new file mode 100644 index 00000000..f7526a13 --- /dev/null +++ b/src/filesystem/root/etc/logrotate.d/map_iface.log @@ -0,0 +1,10 @@ +/var/log/map_iface.log +{ + rotate 1 + daily + missingok + notifempty + compress + delaycompress + sharedscripts +} From 1f6daa6974694f5b9d81ede8e4ab14cd4afd9ab9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Wed, 22 Jul 2015 11:35:40 +0200 Subject: [PATCH 052/352] Allow specification of an additional pre/postscript We might not want a custom variant for something like having to swap resolv.conf or similar just to make the image buildable on certain environments, so this adds a build environment specific additional means to inject scripts into the build process. --- src/config | 3 +++ src/octopi | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/config b/src/config index cfc51218..ff31abb9 100755 --- a/src/config +++ b/src/config @@ -27,6 +27,9 @@ fi ############################################################################### # All our config settings must start with OCTOPI_ +[ -n "$OCTOPI_PRESCRIPT"] || OCTOPI_PRESCRIPT= +[ -n "$OCTOPI_POSTSCRIPT"] || OCTOPI_POSTSCRIPT= + [ -n "$OCTOPI_SCRIPT_PATH" ] || OCTOPI_SCRIPT_PATH=$CONFIG_DIR [ -n "$OCTOPI_IMAGE_PATH" ] || OCTOPI_IMAGE_PATH=$OCTOPI_SCRIPT_PATH/image diff --git a/src/octopi b/src/octopi index b0142731..37ede5a0 100755 --- a/src/octopi +++ b/src/octopi @@ -47,6 +47,12 @@ pushd $OCTOPI_WORKSPACE #make QEMU boot (remember to return) fixLd #sed -i 's@include /etc/ld.so.conf.d/\*.conf@\#include /etc/ld.so.conf.d/\*.conf@' etc/ld.so.conf + + # if an additional pre-script is defined, execute that now + if [ -n "$OCTOPI_PRESCRIPT" ] && [ -f $OCTOPI_PRESCRIPT/chroot_script ]; then + execute_chroot_script $OCTOPI_PRESCRIPT $OCTOPI_PRESCRIPT/chroot_script + fi + # if building a variant, execute its pre-chroot script if [ -n "$VARIANT_BASE" ] && [ -f $VARIANT_BASE/pre_chroot_script ]; then execute_chroot_script $VARIANT_BASE $VARIANT_BASE/pre_chroot_script @@ -59,6 +65,11 @@ pushd $OCTOPI_WORKSPACE if [ -n "$VARIANT_BASE" ] && [ -f $VARIANT_BASE/post_chroot_script ]; then execute_chroot_script $VARIANT_BASE $VARIANT_BASE/post_chroot_script fi + + # if an additional post-script is defined, execute that now + if [ -n "$OCTOPI_POSTSCRIPT" ] && [ -f $OCTOPI_POSTSCRIPT/chroot_script ]; then + execute_chroot_script $OCTOPI_POSTSCRIPT $OCTOPI_POSTSCRIPT/chroot_script + fi restoreLd popd From ea3bab610e1b8ee92767c49316e30d8753125734 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Wed, 22 Jul 2015 11:45:36 +0200 Subject: [PATCH 053/352] Fixed broken brackets --- src/config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/config b/src/config index ff31abb9..c789ad92 100755 --- a/src/config +++ b/src/config @@ -27,8 +27,8 @@ fi ############################################################################### # All our config settings must start with OCTOPI_ -[ -n "$OCTOPI_PRESCRIPT"] || OCTOPI_PRESCRIPT= -[ -n "$OCTOPI_POSTSCRIPT"] || OCTOPI_POSTSCRIPT= +[ -n "$OCTOPI_PRESCRIPT" ] || OCTOPI_PRESCRIPT= +[ -n "$OCTOPI_POSTSCRIPT" ] || OCTOPI_POSTSCRIPT= [ -n "$OCTOPI_SCRIPT_PATH" ] || OCTOPI_SCRIPT_PATH=$CONFIG_DIR [ -n "$OCTOPI_IMAGE_PATH" ] || OCTOPI_IMAGE_PATH=$OCTOPI_SCRIPT_PATH/image From 920547871beb1dff4caf5b3fe72e79db3a1430c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Wed, 22 Jul 2015 13:34:39 +0200 Subject: [PATCH 054/352] Some debug output --- src/octopi | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/octopi b/src/octopi index 37ede5a0..8f1061b2 100755 --- a/src/octopi +++ b/src/octopi @@ -50,11 +50,13 @@ pushd $OCTOPI_WORKSPACE # if an additional pre-script is defined, execute that now if [ -n "$OCTOPI_PRESCRIPT" ] && [ -f $OCTOPI_PRESCRIPT/chroot_script ]; then + echo "Injecting environment pre script from $OCTOPI_PRESCRIPT..." execute_chroot_script $OCTOPI_PRESCRIPT $OCTOPI_PRESCRIPT/chroot_script fi # if building a variant, execute its pre-chroot script if [ -n "$VARIANT_BASE" ] && [ -f $VARIANT_BASE/pre_chroot_script ]; then + echo "Injecting variant pre script from $VARIANT_BASE..." execute_chroot_script $VARIANT_BASE $VARIANT_BASE/pre_chroot_script fi @@ -63,11 +65,13 @@ pushd $OCTOPI_WORKSPACE # if building a variant, execute its post-chroot script if [ -n "$VARIANT_BASE" ] && [ -f $VARIANT_BASE/post_chroot_script ]; then + echo "Injecting variant post script from $VARIANT_BASE..." execute_chroot_script $VARIANT_BASE $VARIANT_BASE/post_chroot_script fi # if an additional post-script is defined, execute that now if [ -n "$OCTOPI_POSTSCRIPT" ] && [ -f $OCTOPI_POSTSCRIPT/chroot_script ]; then + echo "Injecting environment post script from $OCTOPI_POSTSCRIPT..." execute_chroot_script $OCTOPI_POSTSCRIPT $OCTOPI_POSTSCRIPT/chroot_script fi From cafc6ea4630f79c6040857518b7e3461c628e09e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Wed, 22 Jul 2015 14:25:57 +0200 Subject: [PATCH 055/352] Fetch pyserial from pypi, that's patched too --- src/chroot_script | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/chroot_script b/src/chroot_script index a440941a..aaab8628 100755 --- a/src/chroot_script +++ b/src/chroot_script @@ -31,11 +31,8 @@ pushd /home/pi apt-get remove -y python-serial #pyserial that can handle non-standard baud rates - sudo -u pi svn co http://pyserial.svn.sourceforge.net/svnroot/pyserial/trunk pyserial - pushd pyserial/pyserial - sudo -u pi /home/pi/oprint/bin/python setup.py install - popd - + sudo -u pi /home/pi/oprint/bin/pip install pyserial==2.7 + #pybonjour (for mdns discovery) sudo -u pi /home/pi/oprint/bin/pip install pybonjour From d38620b2254942ac506c68e4e4f52f6d2c96c0aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Wed, 22 Jul 2015 15:20:34 +0200 Subject: [PATCH 056/352] Cleanup trap to take care of child processes on exit --- src/build | 1 + src/chroot_script | 1 + src/common.sh | 12 ++++++++++++ src/octopi | 1 + 4 files changed, 15 insertions(+) diff --git a/src/build b/src/build index ab9c69f8..7616a116 100755 --- a/src/build +++ b/src/build @@ -9,6 +9,7 @@ define(){ IFS='\n' read -r -d '' ${1} || true; } define SCRIPT <<'EOF' BUILD_SCRIPT__PATH=$(dirname $(realpath -s $BASH_SOURCE)) source ${BUILD_SCRIPT__PATH}/common.sh +install_cleanup_trap OCTOPI_PATH=$(dirname $(realpath -s $0)) pushd $OCTOPI_PATH diff --git a/src/chroot_script b/src/chroot_script index aaab8628..4cb081fa 100755 --- a/src/chroot_script +++ b/src/chroot_script @@ -7,6 +7,7 @@ set -e # GPL V3 source /common.sh +install_cleanup_trap unpack /filesystem/home/pi /home/pi pi unpack /filesystem/home/root /root root diff --git a/src/common.sh b/src/common.sh index 1f948eeb..92c36f7b 100755 --- a/src/common.sh +++ b/src/common.sh @@ -107,6 +107,13 @@ function unmount_image() { sudo umount $mount_path } +function cleanup() { + # make sure that all child processed die when we die + local pids=$(jobs -pr) + [ -n "$pids" ] && kill $pids + exit 0 +} + function install_fail_on_error_trap() { set -e trap 'previous_command=$this_command; this_command=$BASH_COMMAND' DEBUG @@ -118,3 +125,8 @@ function install_chroot_fail_on_error_trap() { trap 'previous_command=$this_command; this_command=$BASH_COMMAND' DEBUG trap 'if [ $? -ne 0 ]; then echo -e "\nexit $? due to $previous_command \nBUILD FAILED!"; fi;' EXIT } + +function install_cleanup_trap() { + set -e + trap "cleanup" SIGINT SIGTERM +} diff --git a/src/octopi b/src/octopi index 8f1061b2..c2f35d7a 100755 --- a/src/octopi +++ b/src/octopi @@ -28,6 +28,7 @@ function execute_chroot_script() { mkdir -p $OCTOPI_WORKSPACE mkdir -p $OCTOPI_MOUNT_PATH +install_cleanup_trap install_fail_on_error_trap $OCTOPI_MOUNT_PATH unmount_image $OCTOPI_MOUNT_PATH || true From 1849019a6e1bf296446411c1f683046f3bcae69f Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Tue, 4 Aug 2015 13:52:41 +0300 Subject: [PATCH 057/352] Increment version to 0.13.0 --- src/filesystem/root/etc/octopi_version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/filesystem/root/etc/octopi_version b/src/filesystem/root/etc/octopi_version index ac454c6a..54d1a4f2 100644 --- a/src/filesystem/root/etc/octopi_version +++ b/src/filesystem/root/etc/octopi_version @@ -1 +1 @@ -0.12.0 +0.13.0 From 0b0914c0fcda0e6641fa9dd41eb1ce331d15970d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 31 Aug 2015 14:15:45 +0000 Subject: [PATCH 058/352] Added wiringPi to image `gpio` commands should work directly for toggling pins etc. Should fix #51 @guysoft Please verify that the adjusted nightly build scripts are ok this way, I use the source repositories directly instead of working with mirrors. --- src/chroot_script | 9 +++++++++ src/config | 5 +++++ src/nightly_build_scripts/build_local_mirrors | 1 + src/nightly_build_scripts/octopi_nightly_build | 1 + 4 files changed, 16 insertions(+) diff --git a/src/chroot_script b/src/chroot_script index a440941a..a2cae4ca 100755 --- a/src/chroot_script +++ b/src/chroot_script @@ -119,6 +119,15 @@ pushd /home/pi adduser --system --disabled-password --disabled-login --home /var/lib/haproxy \ --no-create-home --quiet --force-badname --group haproxy fi + + if [ "$OCTOPI_INCLUDE_WIRINGPI" == "yes" ] + then + echo "--- Installing WiringPi" + gitclone OCTOPI_WIRINGPI_REPO wiringPi + pushd wiringPi + sudo -u pi ./build + popd + fi popd diff --git a/src/config b/src/config index cfc51218..945622b7 100755 --- a/src/config +++ b/src/config @@ -71,6 +71,11 @@ fi [ -n "$OCTOPI_HAPROXY_ARCHIVE" ] || OCTOPI_HAPROXY_ARCHIVE=http://www.haproxy.org/download/1.5/src/haproxy-$OCTOPI_HAPROXY_VERSION.tar.gz [ -n "$OCTOPI_INCLUDE_HAPROXY" ] || OCTOPI_INCLUDE_HAPROXY=yes +# WiringPi +[ -n "$OCTOPI_WIRINGPI_REPO_SHIP" ] || OCTOPI_WIRINGPI_REPO_SHIP=git://git.drogon.net/wiringPi +[ -n "$OCTOPI_WIRINGPI_REPO_BUILD" ] || OCTOPI_WIRINGPI_REPO_BUILD= +[ -n "$OCTOPI_WIRINGPI_REPO_BRANCH" ] || OCTOPI_WIRINGPI_REPO_BRANCH=master +[ -n "$OCTOPI_INCLUDE_WIRINGPI" ] || OCTOPI_INCLUDE_WIRINGPI=yes ############################################################################### # Rewrite any build urls that are not yet set if we have a repository mirror diff --git a/src/nightly_build_scripts/build_local_mirrors b/src/nightly_build_scripts/build_local_mirrors index 684f4b0f..d75cf2c7 100755 --- a/src/nightly_build_scripts/build_local_mirrors +++ b/src/nightly_build_scripts/build_local_mirrors @@ -3,4 +3,5 @@ git clone --mirror https://github.com/foosel/OctoPrint git clone --mirror https://github.com/jonaslorander/OctoPiPanel.git git clone --mirror https://github.com/jacksonliam/mjpg-streamer.git git clone --mirror https://github.com/tasanakorn/rpi-fbcp +git clone --mirror git://git.drogon.net/wiringPi popd diff --git a/src/nightly_build_scripts/octopi_nightly_build b/src/nightly_build_scripts/octopi_nightly_build index 177c48f4..b0de644d 100755 --- a/src/nightly_build_scripts/octopi_nightly_build +++ b/src/nightly_build_scripts/octopi_nightly_build @@ -18,6 +18,7 @@ pushd ${OCTOPIPATH} export OCTOPI_OCTOPIPANEL_REPO_BUILD='http://localhost/git/OctoPiPanel.git/' export OCTOPI_FBCP_REPO_BUILD='http://localhost/git/rpi-fbcp.git/' export OCTOPI_MJPGSTREAMER_REPO_BUILD='http://localhost/git/mjpg-streamer.git/' + export OCTOPI_WIRINGPI_REPO_BUILD='http://localhost/git/wiringPi.git/' ${OCTOPIPATH}/src/build $1 pushd src From eee2ad9c3a99164950e356b5e852338c3f59a005 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Wed, 28 Oct 2015 00:55:03 +0200 Subject: [PATCH 059/352] Get build to work on Debian Jessie fixes #149 --- src/chroot_script | 5 +++-- src/common.sh | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/chroot_script b/src/chroot_script index a2cae4ca..ec7c0eb3 100755 --- a/src/chroot_script +++ b/src/chroot_script @@ -13,7 +13,7 @@ unpack /filesystem/home/root /root root unpack /filesystem/boot /boot apt-get update -apt-get remove -y --purge scratch squeak-plugins-scratch squeak-vm wolfram-engine python-minecraftpi minecraft-pi sonic-pi oracle-java8-jdk +apt-get remove -y --purge scratch squeak-plugins-scratch squeak-vm wolfram-engine python-minecraftpi minecraft-pi sonic-pi oracle-java8-jdk bluej greenfoot #apt-get octoprint virtualenv apt-get -y --force-yes install python2.7 python-virtualenv python-dev git screen libts-bin subversion cmake checkinstall avahi-daemon libavahi-compat-libdnssd1 @@ -37,7 +37,8 @@ pushd /home/pi popd #pybonjour (for mdns discovery) - sudo -u pi /home/pi/oprint/bin/pip install pybonjour + #sudo -u pi /home/pi/oprint/bin/pip install pybonjour + sudo -u pi /home/pi/oprint/bin/pip install https://pybonjour.googlecode.com/files/pybonjour-1.1.1.tar.gz #OctoPrint gitclone OCTOPI_OCTOPRINT_REPO OctoPrint diff --git a/src/common.sh b/src/common.sh index 1f948eeb..466b57bc 100755 --- a/src/common.sh +++ b/src/common.sh @@ -7,10 +7,12 @@ function die () { function fixLd(){ sed -i 's@/usr/lib/arm-linux-gnueabihf/libcofi_rpi.so@\#/usr/lib/arm-linux-gnueabihf/libcofi_rpi.so@' etc/ld.so.preload + sed -i 's@/usr/lib/arm-linux-gnueabihf/libarmmem.so@\#/usr/lib/arm-linux-gnueabihf/libarmmem.so@' etc/ld.so.preload } function restoreLd(){ sed -i 's@\#/usr/lib/arm-linux-gnueabihf/libcofi_rpi.so@/usr/lib/arm-linux-gnueabihf/libcofi_rpi.so@' etc/ld.so.preload + sed -i 's@\#/usr/lib/arm-linux-gnueabihf/libarmmem.so@/usr/lib/arm-linux-gnueabihf/libarmmem.so@' etc/ld.so.preload } function pause() { @@ -97,6 +99,7 @@ function mount_image() { # mount root and boot partition sudo mount -o loop,offset=$((512*122880)) $image_path $mount_path sudo mount -o loop,offset=$((512*8192)) $image_path $mount_path/boot + sudo mount -o bind /dev $mount_path/dev } function unmount_image() { @@ -104,6 +107,7 @@ function unmount_image() { # unmount first boot, then root partition sudo umount $mount_path/boot + sudo umount $mount_path/dev sudo umount $mount_path } From 6938879bdfa2d3b4ec27ac91dc656f2d84472fdf Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Wed, 28 Oct 2015 01:08:56 +0200 Subject: [PATCH 060/352] Remove more junk from jessie #149 --- src/chroot_script | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/chroot_script b/src/chroot_script index ec7c0eb3..5c75202d 100755 --- a/src/chroot_script +++ b/src/chroot_script @@ -13,7 +13,7 @@ unpack /filesystem/home/root /root root unpack /filesystem/boot /boot apt-get update -apt-get remove -y --purge scratch squeak-plugins-scratch squeak-vm wolfram-engine python-minecraftpi minecraft-pi sonic-pi oracle-java8-jdk bluej greenfoot +apt-get remove -y --purge scratch squeak-plugins-scratch squeak-vm wolfram-engine python-minecraftpi minecraft-pi sonic-pi oracle-java8-jdk bluej greenfoot libreoffice-common libreoffice-core freepats #apt-get octoprint virtualenv apt-get -y --force-yes install python2.7 python-virtualenv python-dev git screen libts-bin subversion cmake checkinstall avahi-daemon libavahi-compat-libdnssd1 From 278b54593a3cb38252323e1f9763cfaa1a749408 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Wed, 28 Oct 2015 01:44:54 +0200 Subject: [PATCH 061/352] Add apt-get autoremove to clean even more stuff --- src/chroot_script | 1 + 1 file changed, 1 insertion(+) diff --git a/src/chroot_script b/src/chroot_script index 5c75202d..14f851b6 100755 --- a/src/chroot_script +++ b/src/chroot_script @@ -14,6 +14,7 @@ unpack /filesystem/boot /boot apt-get update apt-get remove -y --purge scratch squeak-plugins-scratch squeak-vm wolfram-engine python-minecraftpi minecraft-pi sonic-pi oracle-java8-jdk bluej greenfoot libreoffice-common libreoffice-core freepats +apt-get autoremove -y #apt-get octoprint virtualenv apt-get -y --force-yes install python2.7 python-virtualenv python-dev git screen libts-bin subversion cmake checkinstall avahi-daemon libavahi-compat-libdnssd1 From fec45f2c1f30ced23f062d7f4bf30719c1e906b5 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Fri, 30 Oct 2015 18:17:17 +0200 Subject: [PATCH 062/352] Add container static html generation script --- .../generate_nightly_page.js | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/nightly_build_scripts/generate_nightly_page.js diff --git a/src/nightly_build_scripts/generate_nightly_page.js b/src/nightly_build_scripts/generate_nightly_page.js new file mode 100644 index 00000000..1a38673f --- /dev/null +++ b/src/nightly_build_scripts/generate_nightly_page.js @@ -0,0 +1,36 @@ + var pkgcloud = require('pkgcloud'), fs = require('fs'), path = require('path'); + + if(!String.prototype.startsWith){ + String.prototype.startsWith = function (str) { + return !this.indexOf(str); + } +} + + var client = require('pkgcloud').storage.createClient({ + provider: 'google', + keyFilename: path.join(__dirname, 'key.json'), // path to a JSON key file + //#projectId: 'eco-channel-658' // project id +}); + + var cointainer = "octoprint"; + + client.getFiles(cointainer, function (err, files) { + + var stream = fs.createWriteStream(path.join(__dirname, 'index.html')); + + + stream.write("OctoPrint Nightly builds

OctoPi Nightly Builds

\n"); + files.sort(function(a,b) { + if (a.name.startsWith("bananapi") && b.name.startsWith("octopi")) return 1; + if (b.name.startsWith("bananapi") && a.name.startsWith("octopi")) return -1; + if(a.timeCreated < b.timeCreated) return 1; + if(a.timeCreated > b.timeCreated) return -1; + return 0; + } +).forEach(function(fileObj) { + + stream.write('\n"); + }); + stream.write("
' + fileObj.name + " " + fileObj.timeCreated +"
\n"); + + }); \ No newline at end of file From 25327130e2e623fa582c0ed46b60529ff0e6132b Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Tue, 3 Nov 2015 20:00:28 +0200 Subject: [PATCH 063/352] Update nightly scripts to handle jessie build #149 --- src/nightly_build_scripts/octopi_nightly_build | 1 + 1 file changed, 1 insertion(+) diff --git a/src/nightly_build_scripts/octopi_nightly_build b/src/nightly_build_scripts/octopi_nightly_build index b0de644d..8a639662 100755 --- a/src/nightly_build_scripts/octopi_nightly_build +++ b/src/nightly_build_scripts/octopi_nightly_build @@ -12,6 +12,7 @@ rm ${OCTOPIPATH}/src/workspace/*.zip pushd ${OCTOPIPATH} umount ${OCTOPIPATH}/src/workspace/mount/boot + umount ${OCTOPIPATH}/src/workspace/mount/dev umount ${OCTOPIPATH}/src/workspace/mount git pull origin devel export OCTOPI_OCTOPRINT_REPO_BUILD='http://localhost/git/OctoPrint.git/' From 34650dc585641f08e4e16870e664ac3473e36b71 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Thu, 19 Nov 2015 11:52:02 +0200 Subject: [PATCH 064/352] Fix missing of netowrk error detection in Jenkins #158 --- src/jenkins-ci/console_parsing | 1 + 1 file changed, 1 insertion(+) diff --git a/src/jenkins-ci/console_parsing b/src/jenkins-ci/console_parsing index 7033082d..b24cd12e 100644 --- a/src/jenkins-ci/console_parsing +++ b/src/jenkins-ci/console_parsing @@ -2,3 +2,4 @@ error /BUILD FAILED/ error /mv: cannot stat/ error /md5sum: * No such file or directory/ error /Error is not recoverable: exiting now/ +error /Network is unreachable/ From b071c6e94367c7f7183ef5f592b1109cc93fac92 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Thu, 26 Nov 2015 17:23:17 +0200 Subject: [PATCH 065/352] Disable GUI on boot in jessie #149 --- src/chroot_script | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/chroot_script b/src/chroot_script index 14f851b6..1201304c 100755 --- a/src/chroot_script +++ b/src/chroot_script @@ -173,6 +173,9 @@ unpack /filesystem/root / ##################################################################### ### setup services +### Disable GUI at start +systemctl disable lightdm.service + ### OctoPrint if [ "$OCTOPI_INCLUDE_OCTOPRINT" == "yes" ] From fde4395725a4499f3e6eb6bae0177f1bddbb09ce Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Sat, 28 Nov 2015 19:18:54 +0200 Subject: [PATCH 066/352] Add auto detection of second partition so we can build the new version of jessie release on 2015-11-21, also addes dependency for gawk and sfdisk --- README.rst | 2 +- src/common.sh | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index aaf1eeef..cdba97dc 100644 --- a/README.rst +++ b/README.rst @@ -59,7 +59,7 @@ OctoPi can be built from Debian, Ubuntu, Raspbian, or even OctoPi. Build requires about 2.5 GB of free space available. You can build it by issuing the following commands:: - sudo apt-get install realpath qemu-user-static + sudo apt-get install gawk util-linux realpath qemu-user-static git clone https://github.com/guysoft/OctoPi.git cd OctoPi/src/image diff --git a/src/common.sh b/src/common.sh index 466b57bc..25cb5955 100755 --- a/src/common.sh +++ b/src/common.sh @@ -97,7 +97,8 @@ function mount_image() { mount_path=$2 # mount root and boot partition - sudo mount -o loop,offset=$((512*122880)) $image_path $mount_path + # dump the partition table, locate the line 7 with the sector of seond partition + sudo mount -o loop,offset=$(($(sfdisk -d $image_path | sed '7q;d' | awk '{print $4-0}') * 512)) sudo mount -o loop,offset=$((512*8192)) $image_path $mount_path/boot sudo mount -o bind /dev $mount_path/dev } From 822186f01dfd9bb70da459976c3709c2da417e2c Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Sat, 28 Nov 2015 19:47:54 +0200 Subject: [PATCH 067/352] Fix typo --- src/common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common.sh b/src/common.sh index 25cb5955..8e02b303 100755 --- a/src/common.sh +++ b/src/common.sh @@ -98,7 +98,7 @@ function mount_image() { # mount root and boot partition # dump the partition table, locate the line 7 with the sector of seond partition - sudo mount -o loop,offset=$(($(sfdisk -d $image_path | sed '7q;d' | awk '{print $4-0}') * 512)) + sudo mount -o loop,offset=$(($(sfdisk -d $image_path | sed '7q;d' | awk '{print $4-0}') * 512)) $image_path $mount_path sudo mount -o loop,offset=$((512*8192)) $image_path $mount_path/boot sudo mount -o bind /dev $mount_path/dev } From ce2409d882b2f57c630f576a9d7044bd8a14fbf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Thu, 3 Dec 2015 18:33:47 +0000 Subject: [PATCH 068/352] Make oprint a non-system-side-package virtualenv This way we can use up to date versions of urllib3 etc that do not have bugs... --- src/chroot_script | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/chroot_script b/src/chroot_script index 1201304c..84f6c3c8 100755 --- a/src/chroot_script +++ b/src/chroot_script @@ -17,19 +17,23 @@ apt-get remove -y --purge scratch squeak-plugins-scratch squeak-vm wolfram-engin apt-get autoremove -y #apt-get octoprint virtualenv -apt-get -y --force-yes install python2.7 python-virtualenv python-dev git screen libts-bin subversion cmake checkinstall avahi-daemon libavahi-compat-libdnssd1 +apt-get -y --force-yes install python2.7 python-virtualenv python-dev git screen libts-bin subversion cmake checkinstall avahi-daemon libavahi-compat-libdnssd1 libffi-dev libssl-dev pushd /home/pi #build virtualenv - sudo -u pi virtualenv --system-site-packages oprint + sudo -u pi virtualenv oprint + # first lets upgrade pip (the shipped version is way too old...) + sudo -u pi /home/pi/oprint/bin/pip install --upgrade pip + + # we also want pyopenssl so we have a secure SSL context available + sudo -u pi /home/pi/oprint/bin/pip install pyopenssl ndg-httpsclient pyasn1 cryptography + # OctoPrint & pyserial if [ "$OCTOPI_INCLUDE_OCTOPRINT" == "yes" ] then echo "--- Installing OctoPrint" - apt-get install -y --force-yes python-numpy python-netifaces - apt-get remove -y python-serial #pyserial that can handle non-standard baud rates sudo -u pi svn co http://pyserial.svn.sourceforge.net/svnroot/pyserial/trunk pyserial From 9be32fd8cc5ec286aaccbcd58e1c9d3a2cbb4c8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Thu, 3 Dec 2015 18:35:15 +0000 Subject: [PATCH 069/352] Better image offset calculation for mounting Greps for file system types of boot and root partition instead of relying on line numbers in sfdisks output --- src/common.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/common.sh b/src/common.sh index 8e02b303..301c0995 100755 --- a/src/common.sh +++ b/src/common.sh @@ -96,10 +96,15 @@ function mount_image() { image_path=$1 mount_path=$2 + # dump the partition table, locate boot partition of type "c" and root + # partition of type "83" + fdisk_output=$(sfdisk -d $image_path) + boot_offset=$(($(echo "$fdisk_output" | grep "Id= c" | awk '{print $4-0}') * 512)) + root_offset=$(($(echo "$fdisk_output" | grep "Id=83" | awk '{print $4-0}') * 512)) + # mount root and boot partition - # dump the partition table, locate the line 7 with the sector of seond partition - sudo mount -o loop,offset=$(($(sfdisk -d $image_path | sed '7q;d' | awk '{print $4-0}') * 512)) $image_path $mount_path - sudo mount -o loop,offset=$((512*8192)) $image_path $mount_path/boot + sudo mount -o loop,offset=$root_offset $image_path $mount_path/ + sudo mount -o loop,offset=$boot_offset $image_path $mount_path/boot sudo mount -o bind /dev $mount_path/dev } From ae4963fa021ed0a1432ad15d8eda9037f74b59fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Fri, 4 Dec 2015 08:22:25 +0000 Subject: [PATCH 070/352] A bind mount of /dev/pts is sufficient No need for full /dev tree... --- src/common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common.sh b/src/common.sh index 301c0995..c7991b61 100755 --- a/src/common.sh +++ b/src/common.sh @@ -105,7 +105,7 @@ function mount_image() { # mount root and boot partition sudo mount -o loop,offset=$root_offset $image_path $mount_path/ sudo mount -o loop,offset=$boot_offset $image_path $mount_path/boot - sudo mount -o bind /dev $mount_path/dev + sudo mount -o bind /dev/pts $mount_path/dev/pts } function unmount_image() { From 8b23643bd10f0f3dacc1eb9f5516a5d576b009bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Fri, 4 Dec 2015 15:49:28 +0000 Subject: [PATCH 071/352] Added ability to resize root partition If OCTOPI_IMAGE_ENLARGEROOT is set to a size (in MB), the root partition of the raspbian image will be enlarged by that size before starting the actual build. This helps in situations where the image doesn't ship with enough space to perform the build. If OCTOPI_IMAGE_RESIZEROOT is set to a size (in MB), after the build the image will be resized to its minimal size plus the provided size. 200 MB appears to be a good value here. --- src/common.sh | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/config | 8 +++++ src/octopi | 13 +++++++ 3 files changed, 119 insertions(+) diff --git a/src/common.sh b/src/common.sh index c7991b61..26aa1061 100755 --- a/src/common.sh +++ b/src/common.sh @@ -128,3 +128,101 @@ function install_chroot_fail_on_error_trap() { trap 'previous_command=$this_command; this_command=$BASH_COMMAND' DEBUG trap 'if [ $? -ne 0 ]; then echo -e "\nexit $? due to $previous_command \nBUILD FAILED!"; fi;' EXIT } + +function enlarge_ext() { + # call like this: enlarge_ext /path/to/image partition size + # + # will enlarge partition number on /path/to/image by MB + image=$1 + partition=$2 + size=$3 + + echo "Adding $size MB to partition $partition of $image" + start=$(sfdisk -d $image | grep "$image$partition" | awk '{print $4-0}') + offset=$(($start*512)) + dd if=/dev/zero bs=1M count=$size >> $image + fdisk $image </dev/null | grep -i "minimum size" | awk -F: '{print $2-0}') + + e2fminsize_bytes=$(($e2fminsize * $e2fblocksize)) + e2ftarget_bytes=$(($buffer * 1024 * 1024 + $e2fminsize_bytes)) + + e2fminsize_mb=$(($e2fminsize_bytes / 1024 / 1024)) + e2fminsize_blocks=$(($e2fminsize_bytes / 512 + 1)) + e2ftarget_mb=$(($e2ftarget_bytes / 1024 / 1024)) + e2ftarget_blocks=$(($e2ftarget_bytes / 512 + 1)) + + echo "Minimum size is $e2fminsize_mb MB ($e2fminsize file system blocks, $e2fminsize_blocks blocks), resizing to $e2ftarget_mb MB ($e2ftarget_blocks blocks)" + + echo "Resizing file system to $e2target_blocks blocks..." + resize2fs $LODEV ${e2ftarget_blocks}s + losetup -d $LODEV + trap - EXIT + + new_end=$(($start + $e2ftarget_blocks)) + + echo "Resizing partition to end at $start + $e2ftarget_blocsk = $new_end blocks..." + fdisk $image < Date: Fri, 4 Dec 2015 15:57:02 +0000 Subject: [PATCH 072/352] Automatically resize to full SD size on first boot --- src/chroot_script | 2 + src/filesystem/boot/octopi.txt | 7 +++ src/filesystem/root/etc/init.d/prepare_resize | 46 +++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100755 src/filesystem/root/etc/init.d/prepare_resize diff --git a/src/chroot_script b/src/chroot_script index 84f6c3c8..aa201fa5 100755 --- a/src/chroot_script +++ b/src/chroot_script @@ -180,6 +180,8 @@ unpack /filesystem/root / ### Disable GUI at start systemctl disable lightdm.service +update-rc.d prepare_resize defaults + ### OctoPrint if [ "$OCTOPI_INCLUDE_OCTOPRINT" == "yes" ] diff --git a/src/filesystem/boot/octopi.txt b/src/filesystem/boot/octopi.txt index 56b1c0fb..258cb1c2 100644 --- a/src/filesystem/boot/octopi.txt +++ b/src/filesystem/boot/octopi.txt @@ -1,3 +1,10 @@ +### Configure whether to automatically resize the SD on first boot +# +# Available options are: +# - yes: perform resize +# - no: don't perform resize +perform_resize="yes" + ### Configure which camera to use # # Available options are: diff --git a/src/filesystem/root/etc/init.d/prepare_resize b/src/filesystem/root/etc/init.d/prepare_resize new file mode 100755 index 00000000..67d8071b --- /dev/null +++ b/src/filesystem/root/etc/init.d/prepare_resize @@ -0,0 +1,46 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: prepare_resize +# Required-Start: $local_fs +# Required-Stop: +# Default-Start: 3 +# Default-Stop: +# Short-Description: Prepare resize on first boot... +# Description: +### END INIT INFO + +. /lib/lsb/init-functions + +do_start () { + . /boot/octopi.txt + + if [ "$perform_resize" != "yes" ] + then + log_failure_msg "Resize on boot is disabled" + exit 1 + fi + + /usr/bin/raspi-config --expand-rootfs >> /var/log/prepare_resize + /usr/sbin/update-rc.d prepare_resize remove >> /var/log/prepare_resize + + log_success_msg "Resize prepared, rebooting to apply..." + /sbin/reboot +} + +echo "First parameter is $1" >> /var/log/prepare_resize +case "$1" in + start|"") + do_start + ;; + restart|reload|force-reload) + echo "Error: argument '$1' not supported" >&2 + exit 3 + ;; + stop) + # No-op + ;; + *) + echo "Usage: prepare_resize [start|stop]" >&2 + exit 3 + ;; +esac From 011b993307f999d3ac7c7d2744ceb62c8e4de578 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Fri, 4 Dec 2015 15:58:11 +0000 Subject: [PATCH 073/352] Fixed a typo while at it --- src/filesystem/root/etc/init.d/gencert | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/filesystem/root/etc/init.d/gencert b/src/filesystem/root/etc/init.d/gencert index ce17b2be..03d3cc71 100755 --- a/src/filesystem/root/etc/init.d/gencert +++ b/src/filesystem/root/etc/init.d/gencert @@ -35,7 +35,7 @@ case "$1" in # No-op ;; *) - echo "Usage: octopi_first_boot [start|stop]" >&2 + echo "Usage: gencert [start|stop]" >&2 exit 3 ;; esac From 555e7842874c08a3b8e1989d4d3d2d80e647bd45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Fri, 4 Dec 2015 16:08:26 +0000 Subject: [PATCH 074/352] Speed up preparation of oprint environment We fetch the raspbian packages and use the precompiled versions of the pyopenssl related libraries instead of having the build spend what feels like hours on building the cryptography module. We also no longer need to manually install pyserial, the version on pypi is fixed and OctoPrint will pull that in automatically. --- src/chroot_script | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/chroot_script b/src/chroot_script index aa201fa5..3a3bc1b9 100755 --- a/src/chroot_script +++ b/src/chroot_script @@ -28,21 +28,27 @@ pushd /home/pi sudo -u pi /home/pi/oprint/bin/pip install --upgrade pip # we also want pyopenssl so we have a secure SSL context available - sudo -u pi /home/pi/oprint/bin/pip install pyopenssl ndg-httpsclient pyasn1 cryptography + # since that stuff takes ages to compile during build, we do a somewhat dirty + # trick here by installing the raspbian versions, copying the libs over + # to our virtualenv and then purging the raspbian versions again + apt-get -y --force-yes install python-openssl python-cryptography + from=/usr/lib/python2.7/dist-packages + to=/home/pi/oprint/lib/python2.7/site-packages + for pattern in "cffi*" "cryptography*" "OpenSSL*" "ply*" "pycparser*" "pyOpenSSL*" "six*" + do + cp -v -r --preserve=mode,timestamps $from/$pattern $to/ + done + apt-get remove -y --purge python-openssl python-cryptography + apt-get autoremove -y + chown -R pi.pi /home/pi/oprint + sudo -u pi /home/pi/oprint/bin/pip install ndg-httpsclient pyasn1 # OctoPrint & pyserial if [ "$OCTOPI_INCLUDE_OCTOPRINT" == "yes" ] then echo "--- Installing OctoPrint" - #pyserial that can handle non-standard baud rates - sudo -u pi svn co http://pyserial.svn.sourceforge.net/svnroot/pyserial/trunk pyserial - pushd pyserial/pyserial - sudo -u pi /home/pi/oprint/bin/python setup.py install - popd - #pybonjour (for mdns discovery) - #sudo -u pi /home/pi/oprint/bin/pip install pybonjour sudo -u pi /home/pi/oprint/bin/pip install https://pybonjour.googlecode.com/files/pybonjour-1.1.1.tar.gz #OctoPrint From 5fe0208dab6a44586d96e8a0a9e5f7876c2ba62d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Fri, 4 Dec 2015 16:13:23 +0000 Subject: [PATCH 075/352] Support apt proxy & prevent service start If a local apt proxy (such as apt-cacher-ng) is setup, its host:port can be provided in order to speed up builds. Instead of packing the image local apt cache into the mounted image file, a directory on the build server can be specified to bind mount. Consequentially the unmount helper function has been modified to always unmount everything that is mounted beneath the configured mount point. --- src/chroot_script | 16 ++++++++++++++++ src/common.sh | 8 +++++--- src/config | 6 ++++++ src/octopi | 5 +++++ 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/chroot_script b/src/chroot_script index 3a3bc1b9..404a1c4e 100755 --- a/src/chroot_script +++ b/src/chroot_script @@ -8,6 +8,15 @@ set -e source /common.sh +if [ -n "$OCTOPI_APT_PROXY" ] +then + echo "Acquire::http { Proxy \"http://$OCTOPI_APT_PROXY\"; };" > /etc/apt/apt.conf.d/02octopi_build_proxy +fi + +# prevent any installed services from automatically starting (I'm looking at you haproxy) +echo exit 101 > /usr/sbin/policy-rc.d +chmod +x /usr/sbin/policy-rc.d + unpack /filesystem/home/pi /home/pi pi unpack /filesystem/home/root /root root unpack /filesystem/boot /boot @@ -255,3 +264,10 @@ fi #cleanup apt-get clean apt-get autoremove -y + +rm -r /usr/sbin/policy-rc.d + +if [ -n "$OCTOPI_APT_PROXY" ] +then + rm -r /etc/apt/apt.conf.d/02octopi_build_proxy +fi diff --git a/src/common.sh b/src/common.sh index 26aa1061..63d3de69 100755 --- a/src/common.sh +++ b/src/common.sh @@ -112,9 +112,11 @@ function unmount_image() { mount_path=$1 # unmount first boot, then root partition - sudo umount $mount_path/boot - sudo umount $mount_path/dev - sudo umount $mount_path + for m in $(sudo mount | grep /data/octopi/workspace/mount | awk '{print $3}' | sort -r) + do + echo "Unmounting $m..." + sudo umount $m + done } function install_fail_on_error_trap() { diff --git a/src/config b/src/config index 3b124c2c..71f8f376 100755 --- a/src/config +++ b/src/config @@ -43,6 +43,12 @@ fi # provided size in MB [ -n "$OCTOPI_IMAGE_RESIZEROOT" ] || OCTOPI_IMAGE_RESIZEROOT= +# a local directory on the build server to bind mount under /var/cache/apt +[ -n "$OCTOPI_APT_CACHE" ] || OCTOPI_APT_CACHE=$OCTOPI_WORKSPACE/aptcache + +# a host:port combo for a apt-proxy (such as apt-cacher-ng) to use +[ -n "$OCTOPI_APT_PROXY" ] || OCTOPI_APT_PROXY= + [ -n "$OCTOPI_OVERRIDE_HOSTNAME" ] || OCTOPI_OVERRIDE_HOSTNAME=octopi # a git mirror to use for git clones instead of original remotes diff --git a/src/octopi b/src/octopi index fe71d6f3..cbfdfccc 100755 --- a/src/octopi +++ b/src/octopi @@ -47,6 +47,11 @@ pushd $OCTOPI_WORKSPACE # mount root and boot partition mount_image $OCTOPI_IMG_PATH $OCTOPI_MOUNT_PATH + if [ -n "$OCTOPI_APT_CACHE" ] + then + mkdir -p "$OCTOPI_APT_CACHE" + mount --bind "$OCTOPI_APT_CACHE" $OCTOPI_MOUNT_PATH/var/cache/apt + fi #Edit pi filesystem pushd $OCTOPI_MOUNT_PATH From c5f4e23b43895e0b12740615025cc4025cc12c2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Fri, 4 Dec 2015 16:15:38 +0000 Subject: [PATCH 076/352] Remove nodered if its installed --- src/chroot_script | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/chroot_script b/src/chroot_script index 404a1c4e..259a00db 100755 --- a/src/chroot_script +++ b/src/chroot_script @@ -22,7 +22,8 @@ unpack /filesystem/home/root /root root unpack /filesystem/boot /boot apt-get update -apt-get remove -y --purge scratch squeak-plugins-scratch squeak-vm wolfram-engine python-minecraftpi minecraft-pi sonic-pi oracle-java8-jdk bluej greenfoot libreoffice-common libreoffice-core freepats +# in case we are building from a regular raspbian image instead of the lite one... +apt-get remove -y --purge scratch squeak-plugins-scratch squeak-vm wolfram-engine python-minecraftpi minecraft-pi sonic-pi oracle-java8-jdk bluej greenfoot libreoffice-common libreoffice-core freepats nodered apt-get autoremove -y #apt-get octoprint virtualenv From d3a8991879e5ae5c9c6d21e0bcaf55b3356e02b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Fri, 4 Dec 2015 16:16:34 +0000 Subject: [PATCH 077/352] WiringPi and haproxy are now in raspbian No need to compile ourselves --- src/chroot_script | 28 +-- src/config | 5 - src/filesystem/root/etc/default/haproxy | 13 -- src/filesystem/root/etc/init.d/haproxy | 205 ------------------ src/filesystem/root/etc/logrotate.d/haproxy | 13 -- .../root/etc/rsyslog.d/49-haproxy.conf | 7 - 6 files changed, 3 insertions(+), 268 deletions(-) delete mode 100644 src/filesystem/root/etc/default/haproxy delete mode 100755 src/filesystem/root/etc/init.d/haproxy delete mode 100644 src/filesystem/root/etc/logrotate.d/haproxy delete mode 100644 src/filesystem/root/etc/rsyslog.d/49-haproxy.conf diff --git a/src/chroot_script b/src/chroot_script index 259a00db..ed955df5 100755 --- a/src/chroot_script +++ b/src/chroot_script @@ -94,7 +94,7 @@ pushd /home/pi if [ "$OCTOPI_INCLUDE_MJPGSTREAMER" == "yes" ] then echo "--- Installing mjpg-streamer" - apt-get -y --force-yes install libjpeg8-dev imagemagick libav-tools libv4l-dev + apt-get -y --force-yes --no-install-recommends install libjpeg8-dev imagemagick libav-tools libv4l-dev gitclone OCTOPI_MJPGSTREAMER_REPO mjpg-streamer pushd mjpg-streamer mv mjpg-streamer-experimental/* . @@ -124,31 +124,14 @@ pushd /home/pi if [ "$OCTOPI_INCLUDE_HAPROXY" == "yes" ] then echo "--- Installing haproxy" - export HAPROXY_VERSION=OCTOPI_HAPROXY_VERSION - sudo apt-get -y --force-yes install ssl-cert libssl-dev libpcre3-dev + apt-get -y --force-yes install ssl-cert haproxy rm /etc/ssl/private/ssl-cert-snakeoil.key /etc/ssl/certs/ssl-cert-snakeoil.pem - sudo -u pi wget $OCTOPI_HAPROXY_ARCHIVE - sudo -u pi tar xzvf haproxy-$OCTOPI_HAPROXY_VERSION.tar.gz - rm haproxy-$OCTOPI_HAPROXY_VERSION.tar.gz - sudo -u pi mv `ls | grep haproxy | head -n 1` haproxy-ss - pushd haproxy-ss - sudo -u pi make TARGET=linux2628 USE_LINUX_SPLICE=1 USE_LINUX_TPROXY=1 USE_PCRE=1 USE_OPENSSL=1 - mkdir -p /usr/local/share/man/man1 /usr/local/doc /usr/local/doc/haproxy - sudo checkinstall --default --pkgname haproxy --pkgversion 1.5 - popd - rm -rf haproxy-ss - - adduser --system --disabled-password --disabled-login --home /var/lib/haproxy \ - --no-create-home --quiet --force-badname --group haproxy fi if [ "$OCTOPI_INCLUDE_WIRINGPI" == "yes" ] then echo "--- Installing WiringPi" - gitclone OCTOPI_WIRINGPI_REPO wiringPi - pushd wiringPi - sudo -u pi ./build - popd + apt-get install wiringpi fi popd @@ -214,14 +197,9 @@ fi if [ "$OCTOPI_INCLUDE_HAPROXY" == "yes" ] then update-rc.d gencert defaults - update-rc.d haproxy defaults 99 else # let's remove the configs for system services we don't need rm /etc/init.d/gencert - rm /etc/init.d/haproxy - rm /etc/default/haproxy - rm /etc/logrotate.d/haproxy - rm /etc/rsyslog.d/49-haproxy.conf # also we need to make OctoPrint bind to all interfaces because otherwise # it will be unaccessible... diff --git a/src/config b/src/config index 71f8f376..7df96336 100755 --- a/src/config +++ b/src/config @@ -81,14 +81,9 @@ fi [ -n "$OCTOPI_INCLUDE_MJPGSTREAMER" ] || OCTOPI_INCLUDE_MJPGSTREAMER=yes # HAProxy -[ -n "$OCTOPI_HAPROXY_VERSION" ] || OCTOPI_HAPROXY_VERSION=1.5.8 -[ -n "$OCTOPI_HAPROXY_ARCHIVE" ] || OCTOPI_HAPROXY_ARCHIVE=http://www.haproxy.org/download/1.5/src/haproxy-$OCTOPI_HAPROXY_VERSION.tar.gz [ -n "$OCTOPI_INCLUDE_HAPROXY" ] || OCTOPI_INCLUDE_HAPROXY=yes # WiringPi -[ -n "$OCTOPI_WIRINGPI_REPO_SHIP" ] || OCTOPI_WIRINGPI_REPO_SHIP=git://git.drogon.net/wiringPi -[ -n "$OCTOPI_WIRINGPI_REPO_BUILD" ] || OCTOPI_WIRINGPI_REPO_BUILD= -[ -n "$OCTOPI_WIRINGPI_REPO_BRANCH" ] || OCTOPI_WIRINGPI_REPO_BRANCH=master [ -n "$OCTOPI_INCLUDE_WIRINGPI" ] || OCTOPI_INCLUDE_WIRINGPI=yes ############################################################################### diff --git a/src/filesystem/root/etc/default/haproxy b/src/filesystem/root/etc/default/haproxy deleted file mode 100644 index a6ced24e..00000000 --- a/src/filesystem/root/etc/default/haproxy +++ /dev/null @@ -1,13 +0,0 @@ -# Configuration for /etc/init.d/haproxy - -# Path to the haproxy executable, use this to override the default setting "/usr/bin/octoprint" -HAPROXY=/usr/local/sbin/haproxy - -# Log for the configtest run -CONFIGTEST_LOG=/var/log/haproxy_configtest.log - -# Additional arguments to pass to haproxy -EXTRA_ARGS= - -# Should we run at startup? -ENABLED=1 diff --git a/src/filesystem/root/etc/init.d/haproxy b/src/filesystem/root/etc/init.d/haproxy deleted file mode 100755 index ad59720c..00000000 --- a/src/filesystem/root/etc/init.d/haproxy +++ /dev/null @@ -1,205 +0,0 @@ -#!/bin/sh -### BEGIN INIT INFO -# Provides: haproxy -# Required-Start: $local_fs $network $remote_fs -# Required-Stop: $local_fs $remote_fs -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: fast and reliable load balancing reverse proxy -# Description: This file should be used to start and stop haproxy. -### END INIT INFO - -# Author: Arnaud Cornet -# adjusted for OctoPi by Gina Haeussge - -PATH=/usr/local/sbin:/sbin:/usr/sbin:/bin:/usr/bin -PIDFILE=/var/run/haproxy.pid -CONFIG=/etc/haproxy/haproxy.cfg -HAPROXY=/usr/local/sbin/haproxy -CONFIGTEST_LOG=/var/log/haproxy_configtest.log -EXTRAOPTS= -ENABLED=0 - -test -x $HAPROXY || exit 0 -test -f "$CONFIG" || exit 0 - -if [ -e /etc/default/haproxy ]; then - . /etc/default/haproxy -fi - -test "$ENABLED" != "0" || exit 0 - -[ -f /etc/default/rcS ] && . /etc/default/rcS -. /lib/lsb/init-functions - - -haproxy_start() -{ - start-stop-daemon --start --pidfile "$PIDFILE" \ - --exec $HAPROXY -- -f "$CONFIG" -D -p "$PIDFILE" \ - $EXTRAOPTS || return 2 - return 0 -} - -haproxy_stop() -{ - if [ ! -f $PIDFILE ] ; then - # This is a success according to LSB - return 0 - fi - for pid in $(cat $PIDFILE) ; do - /bin/kill $pid || return 4 - done - rm -f $PIDFILE - return 0 -} - -haproxy_reload() -{ - $HAPROXY -f "$CONFIG" -p $PIDFILE -D $EXTRAOPTS -sf $(cat $PIDFILE) \ - || return 2 - return 0 -} - -haproxy_status() -{ - if [ ! -f $PIDFILE ] ; then - # program not running - return 3 - fi - - for pid in $(cat $PIDFILE) ; do - if ! ps --no-headers p "$pid" | grep haproxy > /dev/null ; then - # program running, bogus pidfile - return 1 - fi - done - - return 0 -} - -haproxy_configtest() -{ - $HAPROXY -f "$CONFIG" -c > "$CONFIGTEST_LOG" 2>&1 - ret=$? - if [ $ret -eq 0 ]; then - # Valid config - remove $CONFIGTEST_LOG - rm "$CONFIGTEST_LOG" - fi - - return $ret -} - - -case "$1" in -start) - log_daemon_msg "Starting haproxy" "haproxy" - haproxy_start - ret=$? - case "$ret" in - 0) - log_end_msg 0 - ;; - 1) - log_end_msg 1 - echo "pid file '$PIDFILE' found, haproxy not started." - ;; - 2) - log_end_msg 1 - ;; - esac - exit $ret - ;; -stop) - log_daemon_msg "Stopping haproxy" "haproxy" - haproxy_stop - ret=$? - case "$ret" in - 0|1) - log_end_msg 0 - ;; - 2) - log_end_msg 1 - ;; - esac - exit $ret - ;; -reload|force-reload) - log_daemon_msg "Reloading haproxy" "haproxy" - haproxy_reload - case "$?" in - 0|1) - log_end_msg 0 - ;; - 2) - log_end_msg 1 - ;; - esac - ;; -restart) - log_daemon_msg "Checking haproxy configuration" "haproxy" - haproxy_configtest - ret=$? - case "$ret" in - 0) - log_end_msg 0 - ;; - 1) - log_end_msg 1 - echo "Restart process aborted." - echo "Check $CONFIGTEST_LOG for details." - # Abort restart - exit $ret - ;; - esac - log_daemon_msg "Restarting haproxy" "haproxy" - haproxy_stop - haproxy_start - case "$?" in - 0) - log_end_msg 0 - ;; - 1) - log_end_msg 1 - ;; - 2) - log_end_msg 1 - ;; - esac - ;; -status) - haproxy_status - ret=$? - case "$ret" in - 0) - echo "haproxy is running." - ;; - 1) - echo "haproxy dead, but $PIDFILE exists." - ;; - *) - echo "haproxy not running." - ;; - esac - exit $ret - ;; -configtest) - haproxy_configtest - ret=$? - case "$ret" in - 0) - echo "haproxy configuration is valid." - ;; - 1) - echo "haproxy configuration is NOT valid. Check $CONFIGTEST_LOG for details." - ;; - esac - exit $ret - ;; -*) - echo "Usage: /etc/init.d/haproxy {start|stop|reload|restart|status|configtest}" - exit 2 - ;; -esac - -: \ No newline at end of file diff --git a/src/filesystem/root/etc/logrotate.d/haproxy b/src/filesystem/root/etc/logrotate.d/haproxy deleted file mode 100644 index af5b46e5..00000000 --- a/src/filesystem/root/etc/logrotate.d/haproxy +++ /dev/null @@ -1,13 +0,0 @@ -/var/log/haproxy*.log -{ - rotate 4 - weekly - missingok - notifempty - compress - delaycompress - sharedscripts - postrotate - reload rsyslog >/dev/null 2>&1 || true - endscript -} \ No newline at end of file diff --git a/src/filesystem/root/etc/rsyslog.d/49-haproxy.conf b/src/filesystem/root/etc/rsyslog.d/49-haproxy.conf deleted file mode 100644 index 5745714c..00000000 --- a/src/filesystem/root/etc/rsyslog.d/49-haproxy.conf +++ /dev/null @@ -1,7 +0,0 @@ -$ModLoad imudp -$UDPServerAddress 127.0.0.1 -$UDPServerRun 514 - -# ..and in any case, put these two in /etc/rsyslog.d/49-haproxy.conf: -local1.* -/var/log/haproxy_1.log -& ~ From a3228be50c32bf45f9fdf9576f65cd22b5039c49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Fri, 4 Dec 2015 16:17:16 +0000 Subject: [PATCH 078/352] Record the name of the image from which we built --- src/chroot_script | 1 + 1 file changed, 1 insertion(+) diff --git a/src/chroot_script b/src/chroot_script index ed955df5..d9584ce8 100755 --- a/src/chroot_script +++ b/src/chroot_script @@ -142,6 +142,7 @@ usermod -a -G dialout pi # store octopi commit used to build this image echo "$OCTOPI_COMMIT" > /etc/octopi_commit +echo "$OCTOPI_BUILDBASE" > /etc/octopi_buildbase # allow pi user to run shutdown and service commands echo "pi ALL=NOPASSWD: /sbin/shutdown" > /etc/sudoers.d/octoprint-shutdown From a0b626a77f4317e5fd3778a386288c5076fec541 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Fri, 4 Dec 2015 16:17:43 +0000 Subject: [PATCH 079/352] Allow specifying the git clone depth We don't need the full git history for most of our dependencies (OctoPrint is an exception here for now since it currently needs the git history to determine the version for anything but the master branch) --- src/common.sh | 26 ++++++++++++++++++++++---- src/config | 3 +++ 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/common.sh b/src/common.sh index 63d3de69..7e6300c7 100755 --- a/src/common.sh +++ b/src/common.sh @@ -24,7 +24,7 @@ function pause() { function gitclone(){ # call like this: gitclone OCTOPI_OCTOPRINT_REPO someDirectory -- this will do: # - # sudo -u pi git clone -b $OCTOPI_OCTOPRINT_REPO_BRANCH $OCTOPI_OCTOPRINT_REPO_BUILD someDirectory + # sudo -u pi git clone -b $OCTOPI_OCTOPRINT_REPO_BRANCH --depth $OCTOPI_OCTOPRINT_REPO_DEPTH $OCTOPI_OCTOPRINT_REPO_BUILD someDirectory # # and if $OCTOPI_OCTOPRINT_REPO_BUILD != $OCTOPI_OCTOPRINT_REPO_SHIP also: # @@ -38,6 +38,7 @@ function gitclone(){ repo_build_var=$1_BUILD repo_ship_var=$1_SHIP repo_branch_var=$1_BRANCH + repo_depth_var=$1_DEPTH repo_dir=$2 if [ ! -n "$repo_dir" ] @@ -45,6 +46,17 @@ function gitclone(){ repo_dir=$(echo ${REPO} | sed 's%^.*/\([^/]*\)\(\.git\)?$%\1%g') fi + repo_depth=${!repo_depth_var} + if [ -n "$repo_depth" ] + then + depth=$repo_depth + else + if [ "$#" -gt 2 ] + then + depth=$3 + fi + fi + build_repo=${!repo_build_var} ship_repo=${!repo_ship_var} branch=${!repo_branch_var} @@ -54,13 +66,19 @@ function gitclone(){ build_repo=$ship_repo fi + clone_params= if [ -n "$branch" ] then - sudo -u pi git clone -b $branch "$build_repo" "$repo_dir" - else - sudo -u pi git clone "$build_repo" "$repo_dir" + clone_params="-b $branch" fi + if [ -n "$depth" ] + then + clone_params="$clone_params --depth $depth" + fi + + sudo -u pi git clone $clone_params "$build_repo" "$repo_dir" + if [ "$build_repo" != "$ship_repo" ] then pushd "$repo_dir" diff --git a/src/config b/src/config index 7df96336..82b46107 100755 --- a/src/config +++ b/src/config @@ -64,9 +64,11 @@ fi [ -n "$OCTOPI_OCTOPIPANEL_REPO_SHIP" ] || OCTOPI_OCTOPIPANEL_REPO_SHIP=https://github.com/jonaslorander/OctoPiPanel.git [ -n "$OCTOPI_OCTOPIPANEL_REPO_BUILD" ] || OCTOPI_OCTOPIPANEL_REPO_BUILD= [ -n "$OCTOPI_OCTOPIPANEL_REPO_BRANCH" ] || OCTOPI_OCTOPIPANEL_REPO_BRANCH=master +[ -n "$OCTOPI_OCTOPIPANEL_REPO_DEPTH" ] || OCTOPI_OCTOPIPANEL_REPO_DEPTH=1 [ -n "$OCTOPI_FBCP_REPO_SHIP" ] || OCTOPI_FBCP_REPO_SHIP=https://github.com/tasanakorn/rpi-fbcp [ -n "$OCTOPI_FBCP_REPO_BUILD" ] || OCTOPI_FBCP_REPO_BUILD=$OCTOPI_FBCP_REPO_SHIP [ -n "$OCTOPI_FBCP_REPO_BRANCH" ] || OCTOPI_FBCP_REPO_BRANCH= +[ -n "$OCTOPI_FBCP_REPO_DEPTH" ] || OCTOPI_FBCP_REPO_DEPTH=1 [ -n "$OCTOPI_INCLUDE_OCTOPIPANEL" ] || OCTOPI_INCLUDE_OCTOPIPANEL=yes # CuraEngine archive & version @@ -78,6 +80,7 @@ fi [ -n "$OCTOPI_MJPGSTREAMER_REPO_SHIP" ] || OCTOPI_MJPGSTREAMER_REPO_SHIP=https://github.com/jacksonliam/mjpg-streamer.git [ -n "$OCTOPI_MJPGSTREAMER_REPO_BUILD" ] || OCTOPI_MJPGSTREAMER_REPO_BUILD= [ -n "$OCTOPI_MJPGSTREAMER_REPO_BRANCH" ] || OCTOPI_MJPGSTREAMER_REPO_BRANCH=master +[ -n "$OCTOPI_MJPGSTREAMER_REPO_DEPTH" ] || OCTOPI_MJPGSTREAMER_REPO_DEPTH=1 [ -n "$OCTOPI_INCLUDE_MJPGSTREAMER" ] || OCTOPI_INCLUDE_MJPGSTREAMER=yes # HAProxy From eb471148c518852f0607e9c2dadd93fdb1162f97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Fri, 4 Dec 2015 16:19:05 +0000 Subject: [PATCH 080/352] Removed misleading comment That line does WAY more than just take care of the virtualenv by now... --- src/chroot_script | 1 - 1 file changed, 1 deletion(-) diff --git a/src/chroot_script b/src/chroot_script index d9584ce8..f2fc999e 100755 --- a/src/chroot_script +++ b/src/chroot_script @@ -26,7 +26,6 @@ apt-get update apt-get remove -y --purge scratch squeak-plugins-scratch squeak-vm wolfram-engine python-minecraftpi minecraft-pi sonic-pi oracle-java8-jdk bluej greenfoot libreoffice-common libreoffice-core freepats nodered apt-get autoremove -y -#apt-get octoprint virtualenv apt-get -y --force-yes install python2.7 python-virtualenv python-dev git screen libts-bin subversion cmake checkinstall avahi-daemon libavahi-compat-libdnssd1 libffi-dev libssl-dev pushd /home/pi From dabca99066472ef697ac0d9a3c1274251d4a2437 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Fri, 4 Dec 2015 16:24:17 +0000 Subject: [PATCH 081/352] Resizing the root by default probably is a good idea --- src/config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config b/src/config index 82b46107..d4f502ed 100755 --- a/src/config +++ b/src/config @@ -41,7 +41,7 @@ fi # if set will resize root partition on image after build to minimum size + # provided size in MB -[ -n "$OCTOPI_IMAGE_RESIZEROOT" ] || OCTOPI_IMAGE_RESIZEROOT= +[ -n "$OCTOPI_IMAGE_RESIZEROOT" ] || OCTOPI_IMAGE_RESIZEROOT=200 # a local directory on the build server to bind mount under /var/cache/apt [ -n "$OCTOPI_APT_CACHE" ] || OCTOPI_APT_CACHE=$OCTOPI_WORKSPACE/aptcache From 1a4c185256781df6f44efb17c9620b60135dbf3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Fri, 4 Dec 2015 16:24:37 +0000 Subject: [PATCH 082/352] Added a jessielite variant Currently only makes sure there's enough space to even perform the build. We definitely need to make default raspbian the variant (with prior uninstall in a pre-chroot) and the lite based image the default though IMHO --- src/variants/jessielite/config | 1 + 1 file changed, 1 insertion(+) create mode 100644 src/variants/jessielite/config diff --git a/src/variants/jessielite/config b/src/variants/jessielite/config new file mode 100644 index 00000000..65f30cd1 --- /dev/null +++ b/src/variants/jessielite/config @@ -0,0 +1 @@ +OCTOPI_IMAGE_ENLARGEROOT=250 From 94f3e20fd11b548124e32f72324033c2f51f37a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Sat, 5 Dec 2015 13:44:10 +0000 Subject: [PATCH 083/352] Fixed an error in common.sh Accidentally commited absolute path instead of variable. --- src/common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common.sh b/src/common.sh index 7e6300c7..766f6303 100755 --- a/src/common.sh +++ b/src/common.sh @@ -130,7 +130,7 @@ function unmount_image() { mount_path=$1 # unmount first boot, then root partition - for m in $(sudo mount | grep /data/octopi/workspace/mount | awk '{print $3}' | sort -r) + for m in $(sudo mount | grep $mount_path | awk '{print $3}' | sort -r) do echo "Unmounting $m..." sudo umount $m From d342be30412572ab401bdc877f77e1baa0ae596b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Sat, 5 Dec 2015 13:57:53 +0000 Subject: [PATCH 084/352] Even better image mounting Instead of matching partition types, match partition number. --- src/common.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/common.sh b/src/common.sh index 26aa1061..b6b48eec 100755 --- a/src/common.sh +++ b/src/common.sh @@ -96,11 +96,14 @@ function mount_image() { image_path=$1 mount_path=$2 - # dump the partition table, locate boot partition of type "c" and root - # partition of type "83" + # dump the partition table, locate boot partition and root partition + boot_partition=1 + root_partition=2 fdisk_output=$(sfdisk -d $image_path) - boot_offset=$(($(echo "$fdisk_output" | grep "Id= c" | awk '{print $4-0}') * 512)) - root_offset=$(($(echo "$fdisk_output" | grep "Id=83" | awk '{print $4-0}') * 512)) + boot_offset=$(($(echo "$fdisk_output" | grep "$image_path$boot_partition" | awk '{print $4-0}') * 512)) + root_offset=$(($(echo "$fdisk_output" | grep "$image_path$root_partition" | awk '{print $4-0}') * 512)) + + echo "Mounting image $image_path on $mount_path, offset for boot partition is $boot_offset, offset for root partition is $root_offset" # mount root and boot partition sudo mount -o loop,offset=$root_offset $image_path $mount_path/ From c2dcdac022ce0651ea88a3568759825a30af2965 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Wed, 9 Dec 2015 13:22:20 +0100 Subject: [PATCH 085/352] Added link to latest stable image to README That way people don't have to find the right file in the mirror anymore, and we also can utilize our load balancing. --- README.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.rst b/README.rst index cdba97dc..dc758099 100644 --- a/README.rst +++ b/README.rst @@ -11,6 +11,11 @@ This repository contains the source script to generate the distribution out of a Where to get it? ---------------- +Download the latest stable build via this button: + +.. image:: https://i.imgur.com/NvUOGfS.png + :target: https://octopi.octoprint.org/latest + Official mirror is `here `_ Nightly builds are available `here `_ From fcabeb94bef387e184c6b304ee54c3a3d593c824 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Wed, 9 Dec 2015 17:13:24 +0100 Subject: [PATCH 086/352] Nicer layour for the nightly page Nightlies are now limited to max. 14 entries. --- .gitignore | 1 + .../generate_nightly_page.js | 248 +++++++++++++++--- src/nightly_build_scripts/template.html | 76 ++++++ 3 files changed, 290 insertions(+), 35 deletions(-) create mode 100644 src/nightly_build_scripts/template.html diff --git a/.gitignore b/.gitignore index 4774137a..01d9f4cb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ src/config.local src/image/*.zip +**/key.json diff --git a/src/nightly_build_scripts/generate_nightly_page.js b/src/nightly_build_scripts/generate_nightly_page.js index 1a38673f..445f26fc 100644 --- a/src/nightly_build_scripts/generate_nightly_page.js +++ b/src/nightly_build_scripts/generate_nightly_page.js @@ -1,36 +1,214 @@ - var pkgcloud = require('pkgcloud'), fs = require('fs'), path = require('path'); - - if(!String.prototype.startsWith){ - String.prototype.startsWith = function (str) { - return !this.indexOf(str); - } -} - - var client = require('pkgcloud').storage.createClient({ - provider: 'google', - keyFilename: path.join(__dirname, 'key.json'), // path to a JSON key file - //#projectId: 'eco-channel-658' // project id -}); - - var cointainer = "octoprint"; - - client.getFiles(cointainer, function (err, files) { - - var stream = fs.createWriteStream(path.join(__dirname, 'index.html')); - - - stream.write("OctoPrint Nightly builds

OctoPi Nightly Builds

\n"); - files.sort(function(a,b) { - if (a.name.startsWith("bananapi") && b.name.startsWith("octopi")) return 1; - if (b.name.startsWith("bananapi") && a.name.startsWith("octopi")) return -1; - if(a.timeCreated < b.timeCreated) return 1; - if(a.timeCreated > b.timeCreated) return -1; - return 0; +/** + * Usage: node generate_nightly_page.js [ [ []]] + * + * keyfile: + * The key.json file to use for authentication + * outputfile: + * The file where to write the output to + * templatefile: + * The HTML template to use, supports the following placeholders: + * - "{{ title }}" - will be replaced with page title + * - "{{ description }}" - will be replaced with page description + * - "{{ content }}" - will be replaced with page content + * + * Setup: + * npm install pkgcloud + * For NodeJS < 0.10 also + * npm install readable-stream + */ + +//~~ setup + +// imports + +var pkgcloud = require('pkgcloud'), + fs = require('fs'), + path = require('path'), + stream = require('stream'), + util = require('util'); + +// polyfills + +if (!String.prototype.startsWith) { + String.prototype.startsWith = function (str) { + return !this.indexOf(str); + } +} + +if (!String.prototype.endsWith) { + String.prototype.endsWith = function(searchString, position) { + var subjectString = this.toString(); + if (typeof position !== 'number' || !isFinite(position) || Math.floor(position) !== position || position > subjectString.length) { + position = subjectString.length; + } + position -= searchString.length; + var lastIndex = subjectString.indexOf(searchString, position); + return lastIndex !== -1 && lastIndex === position; + }; +} + +//~~ argument parsing + +// key file to use => ./key.json or first command line argument +var keyfile = path.join(__dirname, 'key.json'); +if (process.argv.length >= 3) { + keyfile = process.argv[2]; +} + +// output file => ./index.html or second command line argument +var outputfile = path.join(__dirname, 'index.html'); +if (process.argv.length >= 4) { + outputfile = process.argv[3]; +} + +// template file ==> ./template.html or third command line argument +var templatefile = path.join(__dirname, 'template.html'); +if (process.argv.length >= 5) { + templatefile = process.argv[4]; +} + +//~~ helpers + +var filterByExtension = function(fileObjs, extensions) { + return fileObjs.filter(function (obj) { + var name = obj.name; + return extensions.some(function (extension) { return name.endsWith(extension); }) + }); +} + +var filterByName = function(fileObjs, name) { + return fileObjs.filter(function (obj) { return obj.name.startsWith(name) }); +} + +var filterNameByRegex = function(fileObjs, regex) { + return fileObjs.filter(function (obj) { return regex.test(obj.name) }); +} + +var stripLeading = function(name, toStrip) { + return name.substring(toStrip.length); +} + +var sortByDate = function(a, b) { + if (a.timeCreated < b.timeCreated) return 1; + if (a.timeCreated > b.timeCreated) return -1; + return 0; +} + +var formatDate = function(date) { + return date.replace(/T/, ' ').replace(/\..+/, '') + " UTC"; +} + +var formatSize = function(bytes) { + // Formats the given file size in bytes + if (!bytes) return "-"; + + var units = ["bytes", "KB", "MB"]; + for (var i = 0; i < units.length; i++) { + if (bytes < 1024) { + return bytes.toFixed(1) + units[i]; + } + bytes /= 1024; + } + return bytes.toFixed(1) + "GB"; +} + +var convertHash = function(hash) { + // Converts a hash from base64 to hex + return new Buffer(hash, 'base64').toString('hex'); +} + +var outputTable = function(fileObjs, s, nameProcessor, limit) { + // Outputs an HTML table to for the provided , limiting them to + // and preprocessing the filename with + + limit = limit || 20; + + s.write('
\n'); + s.write('\n'); + + // sort by date and limit + fileObjs.sort(sortByDate).slice(0, limit).forEach(function(fileObj) { + console.log("Processing file object: %j", fileObj); + + var url = "https://storage.googleapis.com/octoprint/" + fileObj.name; + var name = nameProcessor(fileObj.name); + + s.write(''); + s.write('"); + s.write('"); + s.write(""); + s.write(""); + s.write("\n"); + }); + + s.write('
NameCreation DateSizeMD5 Hash
' + name + "' + formatDate(fileObj.timeCreated) + "" + formatSize(fileObj.size) + "" + convertHash(fileObj.md5Hash) + "
\n'); +} + +var outputPage = function(files, s) { + // Outputs the page for to stream , using the template. + var title = "OctoPi Downloads"; + var description = "OctoPi Downloads"; + + var Writable = stream.Writable || require('readable-stream').Writable; + function StringStream(options) { + Writable.call(this, options); + this.buffer = ""; } -).forEach(function(fileObj) { - - stream.write('' + fileObj.name + " " + fileObj.timeCreated +" \n"); - }); - stream.write("\n"); - - }); \ No newline at end of file + util.inherits(StringStream, Writable); + StringStream.prototype._write = function (chunk, enc, cb) { + this.buffer += chunk; + cb(); + }; + + var output = new StringStream(); + + output.write(""); + + output.write("

Raspberry Pi

\n"); + + output.write("

Stable Builds

\n") + outputTable(filterNameByRegex(files, /^stable\/.*octopi-(wheezy|jessie)-.*/), + output, + function(name) { return stripLeading(name, "stable/") }, + 3); + + output.write("

Nightly Builds

\n"); + output.write("Warning: These builds are untested and can be unstable and/or broken. If in doubt use a stable build."); + outputTable(filterNameByRegex(files.filter(function (obj) { return !obj.name.startsWith("stable/") && !obj.name.startsWith("bananapi-m1/") }), /octopi-(wheezy|jessie)-/), + output, + function(name) { return name }, + 14); + + output.write("

Banana Pi M1

\n") + + output.write("

Nightly Builds

\n"); + output.write("Warning: These builds are untested and can be unstable and/or broken."); + outputTable(filterNameByRegex(files, /^bananapi-m1\//), + output, + function(name) { return stripLeading(name, "bananapi-m1/") }, + 14); + + var content = output.buffer; + fs.readFile(templatefile, "utf8", function (err, template) { + var result = template.replace(/{{ content }}/g, content) + .replace(/{{ title }}/g, title) + .replace(/{{ description }}/g, description); + s.write(result); + }) + +} + +//~~ action and go + +// construct client +var client = require('pkgcloud').storage.createClient({ + provider: 'google', + keyFilename: keyfile, // path to a JSON key file +}); +var container = "octoprint"; + +// fetch our files and render our page +client.getFiles(container, function (err, files) { + var stream = fs.createWriteStream(outputfile); + outputPage(filterByExtension(files, [".zip"]), stream); +}); diff --git a/src/nightly_build_scripts/template.html b/src/nightly_build_scripts/template.html new file mode 100644 index 00000000..88989d1b --- /dev/null +++ b/src/nightly_build_scripts/template.html @@ -0,0 +1,76 @@ + + + + + + + + + {{ title }} + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+
+
+ {{ content }} +
+
+
+
+
+ + + + + From dbd5328dc92060bb68884b3e8a919dae30a9734f Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Thu, 10 Dec 2015 15:15:28 +0200 Subject: [PATCH 087/352] Unmount /dev/pts and not /dev introduced in #165 --- src/nightly_build_scripts/octopi_nightly_build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nightly_build_scripts/octopi_nightly_build b/src/nightly_build_scripts/octopi_nightly_build index 8a639662..ed1e1c15 100755 --- a/src/nightly_build_scripts/octopi_nightly_build +++ b/src/nightly_build_scripts/octopi_nightly_build @@ -12,7 +12,7 @@ rm ${OCTOPIPATH}/src/workspace/*.zip pushd ${OCTOPIPATH} umount ${OCTOPIPATH}/src/workspace/mount/boot - umount ${OCTOPIPATH}/src/workspace/mount/dev + umount ${OCTOPIPATH}/src/workspace/mount/dev/pts umount ${OCTOPIPATH}/src/workspace/mount git pull origin devel export OCTOPI_OCTOPRINT_REPO_BUILD='http://localhost/git/OctoPrint.git/' From 973862abca8daa7bedf231201d42a82003e2c514 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Thu, 10 Dec 2015 19:08:41 +0100 Subject: [PATCH 088/352] Added a clean up script Should be executed _before_ generating the index. Will remove all nightlies for RPi and BPi that are older than 14 days. --- src/nightly_build_scripts/cleanup_storage.js | 108 +++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 src/nightly_build_scripts/cleanup_storage.js diff --git a/src/nightly_build_scripts/cleanup_storage.js b/src/nightly_build_scripts/cleanup_storage.js new file mode 100644 index 00000000..971be31a --- /dev/null +++ b/src/nightly_build_scripts/cleanup_storage.js @@ -0,0 +1,108 @@ +/** + * Usage: node cleanup_storage.js [] + * + * action: + * "print" or "delete" + * keyfile: + * The key.json file to use for authentication + * + * Setup: + * npm install pkgcloud + */ + +//~~ setup + +// imports + +var pkgcloud = require('pkgcloud'), + fs = require('fs'), + path = require('path'); + +// polyfills + +if (!String.prototype.startsWith) { + String.prototype.startsWith = function (str) { + return !this.indexOf(str); + } +} + +if (!String.prototype.endsWith) { + String.prototype.endsWith = function(searchString, position) { + var subjectString = this.toString(); + if (typeof position !== 'number' || !isFinite(position) || Math.floor(position) !== position || position > subjectString.length) { + position = subjectString.length; + } + position -= searchString.length; + var lastIndex = subjectString.indexOf(searchString, position); + return lastIndex !== -1 && lastIndex === position; + }; +} + +//~~ argument parsing + +// "delete" -> delete, "print" -> only print +if (process.argv.length < 3) { + console.log("Missing mandatory action parameter"); + process.exit(); +} +var action = process.argv[2]; + +// key file to use => ./key.json or second command line argument +var keyfile = path.join(__dirname, 'key.json'); +if (process.argv.length >= 4) { + keyfile = process.argv[3]; +} + +//~~ helpers + +var sortByDate = function(a, b) { + if (a.timeCreated < b.timeCreated) return 1; + if (a.timeCreated > b.timeCreated) return -1; + return 0; +} + +//~~ action and go + +// construct client +var client = require('pkgcloud').storage.createClient({ + provider: 'google', + keyFilename: keyfile, // path to a JSON key file +}); +var container = "octoprint"; + +// fetch our files and render our page +var matchers = [ + { + matcher: function(obj) { return !obj.name.startsWith("stable/") && !obj.name.startsWith("bananapi-m1/") && /octopi-(wheezy|jessie)-/.test(obj.name); }, + limit: 14 + }, + { + matcher: function(obj) { return /^bananapi-m1\//.test(obj.name); }, + limit: 14 + } +] + +var now = new Date(); +client.getFiles(container, function (err, files) { + matchers.forEach(function(m) { + var cutoff = new Date(); + cutoff.setDate(now.getDate() - m.limit); + + var filesToDelete = files.filter(m.matcher) + .filter(function(obj) { return new Date(Date.parse(obj.timeCreated)) < cutoff }); + + filesToDelete.forEach(function (file) { + if (action == "delete") { + client.removeFile(container, encodeURIComponent(file.name), function(err) { + if (err) { + console.log("Error deleting " + file.name + ": " + err); + } else { + console.log("Deleted " + file.name + " on " + container); + } + }); + } else { + console.log("Would now delete " + file.name + " on " + container); + } + }); + }); +}); From 2366ed20d2d0a350836de1b6e8ef1380494d0670 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Fri, 11 Dec 2015 12:03:02 +0100 Subject: [PATCH 089/352] Allow specification of an additional pre/postscript We might not want a custom variant for something like having to swap resolv.conf or similar just to make the image buildable on certain environments, so this adds a build environment specific additional means to inject scripts into the build process. Example: build server that requires a special set of nameservers in /etc/resolv.conf during build. --- src/config | 5 ++++- src/octopi | 17 ++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/config b/src/config index d4f502ed..b423991d 100755 --- a/src/config +++ b/src/config @@ -4,7 +4,7 @@ CONFIG_DIR=$(dirname $(realpath -s $BASH_SOURCE)) if [ -n "$VARIANT_CONFIG" ] && [ -f $VARIANT_CONFIG ] then - echo "Sourceing variant config $VARIANT_CONFIG..." + echo "Sourcing variant config $VARIANT_CONFIG..." source $VARIANT_CONFIG fi @@ -27,6 +27,9 @@ fi ############################################################################### # All our config settings must start with OCTOPI_ +[ -n "$OCTOPI_PRESCRIPT" ] || OCTOPI_PRESCRIPT= +[ -n "$OCTOPI_POSTSCRIPT" ] || OCTOPI_POSTSCRIPT= + [ -n "$OCTOPI_SCRIPT_PATH" ] || OCTOPI_SCRIPT_PATH=$CONFIG_DIR [ -n "$OCTOPI_IMAGE_PATH" ] || OCTOPI_IMAGE_PATH=$OCTOPI_SCRIPT_PATH/image diff --git a/src/octopi b/src/octopi index cbfdfccc..72876812 100755 --- a/src/octopi +++ b/src/octopi @@ -59,8 +59,16 @@ pushd $OCTOPI_WORKSPACE #make QEMU boot (remember to return) fixLd #sed -i 's@include /etc/ld.so.conf.d/\*.conf@\#include /etc/ld.so.conf.d/\*.conf@' etc/ld.so.conf + + # if an additional pre-script is defined, execute that now + if [ -n "$OCTOPI_PRESCRIPT" ] && [ -f $OCTOPI_PRESCRIPT/chroot_script ]; then + echo "Injecting environment pre script from $OCTOPI_PRESCRIPT..." + execute_chroot_script $OCTOPI_PRESCRIPT $OCTOPI_PRESCRIPT/chroot_script + fi + # if building a variant, execute its pre-chroot script if [ -n "$VARIANT_BASE" ] && [ -f $VARIANT_BASE/pre_chroot_script ]; then + echo "Injecting variant pre script from $VARIANT_BASE..." execute_chroot_script $VARIANT_BASE $VARIANT_BASE/pre_chroot_script fi @@ -69,9 +77,16 @@ pushd $OCTOPI_WORKSPACE # if building a variant, execute its post-chroot script if [ -n "$VARIANT_BASE" ] && [ -f $VARIANT_BASE/post_chroot_script ]; then + echo "Injecting variant post script from $VARIANT_BASE..." execute_chroot_script $VARIANT_BASE $VARIANT_BASE/post_chroot_script fi - + + # if an additional post-script is defined, execute that now + if [ -n "$OCTOPI_POSTSCRIPT" ] && [ -f $OCTOPI_POSTSCRIPT/chroot_script ]; then + echo "Injecting environment post script from $OCTOPI_POSTSCRIPT..." + execute_chroot_script $OCTOPI_POSTSCRIPT $OCTOPI_POSTSCRIPT/chroot_script + fi + restoreLd popd From 89d44687a815aa551aa0f0db68a68accf61f8062 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Fri, 11 Dec 2015 12:24:26 +0100 Subject: [PATCH 090/352] Cleanup trap to take care of child processes on exit --- src/build | 1 + src/chroot_script | 1 + src/common.sh | 12 ++++++++++++ src/octopi | 1 + 4 files changed, 15 insertions(+) diff --git a/src/build b/src/build index ab9c69f8..7616a116 100755 --- a/src/build +++ b/src/build @@ -9,6 +9,7 @@ define(){ IFS='\n' read -r -d '' ${1} || true; } define SCRIPT <<'EOF' BUILD_SCRIPT__PATH=$(dirname $(realpath -s $BASH_SOURCE)) source ${BUILD_SCRIPT__PATH}/common.sh +install_cleanup_trap OCTOPI_PATH=$(dirname $(realpath -s $0)) pushd $OCTOPI_PATH diff --git a/src/chroot_script b/src/chroot_script index f2fc999e..0c97a1a9 100755 --- a/src/chroot_script +++ b/src/chroot_script @@ -7,6 +7,7 @@ set -e # GPL V3 source /common.sh +install_cleanup_trap if [ -n "$OCTOPI_APT_PROXY" ] then diff --git a/src/common.sh b/src/common.sh index 00020ba6..766cd3db 100755 --- a/src/common.sh +++ b/src/common.sh @@ -140,6 +140,13 @@ function unmount_image() { done } +function cleanup() { + # make sure that all child processed die when we die + local pids=$(jobs -pr) + [ -n "$pids" ] && kill $pids && sleep 5 && kill -9 $pids + exit 0 +} + function install_fail_on_error_trap() { set -e trap 'previous_command=$this_command; this_command=$BASH_COMMAND' DEBUG @@ -152,6 +159,11 @@ function install_chroot_fail_on_error_trap() { trap 'if [ $? -ne 0 ]; then echo -e "\nexit $? due to $previous_command \nBUILD FAILED!"; fi;' EXIT } +function install_cleanup_trap() { + set -e + trap "cleanup" SIGINT SIGTERM + } + function enlarge_ext() { # call like this: enlarge_ext /path/to/image partition size # diff --git a/src/octopi b/src/octopi index 72876812..70a357d1 100755 --- a/src/octopi +++ b/src/octopi @@ -28,6 +28,7 @@ function execute_chroot_script() { mkdir -p $OCTOPI_WORKSPACE mkdir -p $OCTOPI_MOUNT_PATH +install_cleanup_trap install_fail_on_error_trap $OCTOPI_MOUNT_PATH unmount_image $OCTOPI_MOUNT_PATH || true From f392e0e49e78b04aaa20d457e25e8e93746e3682 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Fri, 11 Dec 2015 13:47:35 +0100 Subject: [PATCH 091/352] Added option to unmount_image to kill processes still accessing the mount path Kill processes with "unmount_image force". Just "unmount_image " does the same thing as before. --- src/common.sh | 16 +++++++++++++++- src/octopi | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/common.sh b/src/common.sh index 766cd3db..b9f86785 100755 --- a/src/common.sh +++ b/src/common.sh @@ -131,6 +131,20 @@ function mount_image() { function unmount_image() { mount_path=$1 + force= + if [ "$#" -gt 1 ] + then + force=$2 + fi + + if [ -n "$force" ] + then + for process in $(sudo lsof $mount_path | awk '{print $2}') + do + echo "Killing process id $process..." + sudo kill -9 $process + done + fi # unmount first boot, then root partition for m in $(sudo mount | grep $mount_path | awk '{print $3}' | sort -r) @@ -150,7 +164,7 @@ function cleanup() { function install_fail_on_error_trap() { set -e trap 'previous_command=$this_command; this_command=$BASH_COMMAND' DEBUG - trap 'if [ $? -ne 0 ]; then echo -e "\nexit $? due to $previous_command \nBUILD FAILED!" && echo "unmounting image..." && ( unmount_image $OCTOPI_MOUNT_PATH || true ); fi;' EXIT + trap 'if [ $? -ne 0 ]; then echo -e "\nexit $? due to $previous_command \nBUILD FAILED!" && echo "unmounting image..." && ( unmount_image $OCTOPI_MOUNT_PATH force || true ); fi;' EXIT } function install_chroot_fail_on_error_trap() { diff --git a/src/octopi b/src/octopi index 70a357d1..7d63159e 100755 --- a/src/octopi +++ b/src/octopi @@ -30,7 +30,7 @@ mkdir -p $OCTOPI_MOUNT_PATH install_cleanup_trap install_fail_on_error_trap $OCTOPI_MOUNT_PATH -unmount_image $OCTOPI_MOUNT_PATH || true +unmount_image $OCTOPI_MOUNT_PATH force || true pushd $OCTOPI_WORKSPACE if [ -e *.img ]; then From 0b7d5d76406b5c67c813aceb3abb7c5e6933b922 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Fri, 11 Dec 2015 14:24:45 +0100 Subject: [PATCH 092/352] Allows defining an alternative pypi index to use during build That allows using something like a caching proxy such as devpi, speeding up the build. --- src/chroot_script | 26 ++++++++++++++++++++++++++ src/config | 3 +++ 2 files changed, 29 insertions(+) diff --git a/src/chroot_script b/src/chroot_script index f2fc999e..3434a1d3 100755 --- a/src/chroot_script +++ b/src/chroot_script @@ -13,6 +13,24 @@ then echo "Acquire::http { Proxy \"http://$OCTOPI_APT_PROXY\"; };" > /etc/apt/apt.conf.d/02octopi_build_proxy fi +if [ -n "$OCTOPI_PYPI_INDEX" ] +then + pip_index_config="[global]\nindex-url = $OCTOPI_PYPI_INDEX" + easyinstall_index_config="[easy_install]\nindex-url = $OCTOPI_PYPI_INDEX" + + mkdir -p /root/.pip + echo -e "$pip_index_config" > /root/.pip/pip.conf + echo -e "$easyinstall_index_config" > /root/.pydistutils.cfg + + mkdir -p /home/pi/.pip + sudo -u pi echo -e "$pip_index_config" > /home/pi/.pip/pip.conf + sudo -u pi echo -e "$easyinstall_index_config" > /home/pi/.pydistutils.cfg + + echo "Configured pypi index url $OCTOPI_PYPI_INDEX" + cat /home/pi/.pip/pip.conf + cat /home/pi/.pydistutils.cfg +fi + # prevent any installed services from automatically starting (I'm looking at you haproxy) echo exit 101 > /usr/sbin/policy-rc.d chmod +x /usr/sbin/policy-rc.d @@ -250,3 +268,11 @@ if [ -n "$OCTOPI_APT_PROXY" ] then rm -r /etc/apt/apt.conf.d/02octopi_build_proxy fi + +if [ -n "$OCTOPI_PYPI_INDEX" ] +then + rm -r /root/.pip + rm -r /root/.pydistutils.cfg + rm -r /home/pi/.pip/pip.conf + rm -r /home/pi/.pydistutils.cfg +fi diff --git a/src/config b/src/config index b423991d..61ac0049 100755 --- a/src/config +++ b/src/config @@ -52,6 +52,9 @@ fi # a host:port combo for a apt-proxy (such as apt-cacher-ng) to use [ -n "$OCTOPI_APT_PROXY" ] || OCTOPI_APT_PROXY= +# an alternative pypi index url to use, e.g. a proxy such as devpi +[ -n "$OCTOPI_PYPI_INDEX" ] || OCTOPI_PYPI_INDEX= + [ -n "$OCTOPI_OVERRIDE_HOSTNAME" ] || OCTOPI_OVERRIDE_HOSTNAME=octopi # a git mirror to use for git clones instead of original remotes From 6182cfb689cdaf6756c59ef8e552f2d975e14886 Mon Sep 17 00:00:00 2001 From: Salandora Date: Fri, 11 Dec 2015 21:44:03 +0100 Subject: [PATCH 093/352] Fix ping for user pi --- src/chroot_script | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/chroot_script b/src/chroot_script index f2fc999e..6e8ed90c 100755 --- a/src/chroot_script +++ b/src/chroot_script @@ -28,6 +28,10 @@ apt-get autoremove -y apt-get -y --force-yes install python2.7 python-virtualenv python-dev git screen libts-bin subversion cmake checkinstall avahi-daemon libavahi-compat-libdnssd1 libffi-dev libssl-dev +echo " - Reinstall iputils-ping" +apt-get install --reinstall iputils-ping + + pushd /home/pi #build virtualenv From 81ba2155c742e8dfe5e16f22b70edd7ed2992dd4 Mon Sep 17 00:00:00 2001 From: Salandora Date: Sat, 12 Dec 2015 02:29:42 +0100 Subject: [PATCH 094/352] Auto reconnect WLAN after a lost connection --- src/chroot_script | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/chroot_script b/src/chroot_script index 6e8ed90c..797401db 100755 --- a/src/chroot_script +++ b/src/chroot_script @@ -174,6 +174,10 @@ echo "mapping wlan1" >> /etc/network/interfaces echo " script /root/bin/map_iface" >> /etc/network/interfaces echo "source /boot/octopi-network.txt" >> /etc/network/interfaces +# copy /etc/wpa_supplicant/ifupdown.sh to /etc/ifplugd/action.d/ifupdown - for wlan auto reconnect +[ -f /etc/ifplugd/action.d/ifupdown ] && mv /etc/ifplugd/action.d/ifupdown /etc/ifplugd/action.d/ifupdown.original +[ -f /etc/wpa_supplicant/ifupdown.sh ] && ln -s /etc/wpa_supplicant/ifupdown.sh /etc/ifplugd/action.d/ifupdown + #unpack root in the end, so etc file are not overwritten, might need to add two roots int he future unpack /filesystem/root / From 874a927b80d0fed5e126799de165eae38c3fcfbc Mon Sep 17 00:00:00 2001 From: Salandora Date: Tue, 15 Dec 2015 04:46:44 +0100 Subject: [PATCH 095/352] Fix minimize_ext bug for 'img size < desired size' --- src/common.sh | 75 ++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 57 insertions(+), 18 deletions(-) diff --git a/src/common.sh b/src/common.sh index 00020ba6..1561121c 100755 --- a/src/common.sh +++ b/src/common.sh @@ -188,40 +188,34 @@ FDISK echo "Resized parition $partition of $image to +$size MB" } -function minimize_ext() { +function shrink_ext() { + # call like this: shrink_ext /path/to/image partition size + # + # will shrink partition number on /path/to/image to MB image=$1 partition=$2 - buffer=$3 - - echo "Resizing partition $partition on $image to minimal size + $buffer MB" + size=$3 + + echo "Resizing file system to $size MB..." start=$(sfdisk -d $image | grep "$image$partition" | awk '{print $4-0}') offset=$(($start*512)) - + LODEV=$(losetup -f --show -o $offset $image) trap 'losetup -d $LODEV' EXIT e2fsck -fy $LODEV - e2fblocksize=$(tune2fs -l $LODEV | grep -i "block size" | awk -F: '{print $2-0}') - e2fminsize=$(resize2fs -P $LODEV 2>/dev/null | grep -i "minimum size" | awk -F: '{print $2-0}') - - e2fminsize_bytes=$(($e2fminsize * $e2fblocksize)) - e2ftarget_bytes=$(($buffer * 1024 * 1024 + $e2fminsize_bytes)) - - e2fminsize_mb=$(($e2fminsize_bytes / 1024 / 1024)) - e2fminsize_blocks=$(($e2fminsize_bytes / 512 + 1)) - e2ftarget_mb=$(($e2ftarget_bytes / 1024 / 1024)) + + e2ftarget_bytes=$(($size * 1024 * 1024)) e2ftarget_blocks=$(($e2ftarget_bytes / 512 + 1)) - echo "Minimum size is $e2fminsize_mb MB ($e2fminsize file system blocks, $e2fminsize_blocks blocks), resizing to $e2ftarget_mb MB ($e2ftarget_blocks blocks)" - - echo "Resizing file system to $e2target_blocks blocks..." + echo "Resizing file system to $e2ftarget_blocks blocks..." resize2fs $LODEV ${e2ftarget_blocks}s losetup -d $LODEV trap - EXIT new_end=$(($start + $e2ftarget_blocks)) - echo "Resizing partition to end at $start + $e2ftarget_blocsk = $new_end blocks..." + echo "Resizing partition to end at $start + $e2ftarget_blocks = $new_end blocks..." fdisk $image </dev/null | grep -i "minimum size" | awk -F: '{print $2-0}') + + e2fminsize_bytes=$(($e2fminsize * $e2fblocksize)) + e2ftarget_bytes=$(($buffer * 1024 * 1024 + $e2fminsize_bytes)) + e2fsize_bytes=$((($e2fsize_blocks - 1) * 512)) + + e2fminsize_mb=$(($e2fminsize_bytes / 1024 / 1024)) + e2fminsize_blocks=$(($e2fminsize_bytes / 512 + 1)) + e2ftarget_mb=$(($e2ftarget_bytes / 1024 / 1024)) + e2ftarget_blocks=$(($e2ftarget_bytes / 512 + 1)) + e2fsize_mb=$(($e2fsize_bytes / 1024 / 1024)) + + size_offset_mb=$(($e2fsize_mb - $e2ftarget_mb)) + + losetup -d $LODEV + + echo "Actual size is $e2fsize_mb MB ($e2fsize_blocks blocks), Minimum size is $e2fminsize_mb MB ($e2fminsize file system blocks, $e2fminsize_blocks blocks)" + echo "Resizing to $e2ftarget_mb MB ($e2ftarget_blocks blocks)" + + if [ $size_offset_mb -gt 0 ]; then + echo "Partition size is bigger then the desired size, shrinking" + shrink_ext $image 2 $(($e2ftarget_mb - 1)) # -1 to compensat rounding mistakes + elif [ $size_offset_mb -lt 0 ]; then + echo "Partition size is lower then the desired size, enlarging" + enlarge_ext $image 2 $((-$size_offset_mb + 1)) # +1 to compensat rounding mistakes + fi +} From cf3af7aa878107fbdeafda24a5e39505851d823c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 15 Dec 2015 15:39:27 +0100 Subject: [PATCH 096/352] Added pypi timeout message to error parsing --- src/jenkins-ci/console_parsing | 1 + 1 file changed, 1 insertion(+) diff --git a/src/jenkins-ci/console_parsing b/src/jenkins-ci/console_parsing index b24cd12e..6983e173 100644 --- a/src/jenkins-ci/console_parsing +++ b/src/jenkins-ci/console_parsing @@ -3,3 +3,4 @@ error /mv: cannot stat/ error /md5sum: * No such file or directory/ error /Error is not recoverable: exiting now/ error /Network is unreachable/ +error /error: timed out/ From 05419272a074eefdfd71fa77d7087e7a2ebc191d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 15 Dec 2015 16:07:13 +0100 Subject: [PATCH 097/352] More resilient unmount --- src/common.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/common.sh b/src/common.sh index 1561121c..6fc09571 100755 --- a/src/common.sh +++ b/src/common.sh @@ -132,8 +132,18 @@ function mount_image() { function unmount_image() { mount_path=$1 - # unmount first boot, then root partition - for m in $(sudo mount | grep $mount_path | awk '{print $3}' | sort -r) + # Unmount everything that is mounted + # + # We might have "broken" mounts in the mix that point at a deleted image (in case of some odd + # build errors). So our "sudo mount" output can look like this: + # + # /path/to/our/image.img (deleted) on /path/to/our/mount type ext4 (rw) + # /path/to/our/image.img on /path/to/our/mount type ext4 (rw) + # /path/to/our/image.img on /path/to/our/mount/boot type vfat (rw) + # + # so we split on "on" first, then do a whitespace split to get the actual mounted directory. + # Also we sort in reverse to get the deepest mounts first. + for m in $(sudo mount | grep $mount_path | awk -F "on" '{print $2}' | awk '{print $1}' | sort -r) do echo "Unmounting $m..." sudo umount $m From 8af6ab9f3ab2f0808dbb421c7c98a55443e6bac8 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Thu, 17 Dec 2015 16:39:13 +0200 Subject: [PATCH 098/352] Update path building of bananapi variant --- src/variants/bananapi-m1/config | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/variants/bananapi-m1/config b/src/variants/bananapi-m1/config index 4f560c37..d5d67d6e 100755 --- a/src/variants/bananapi-m1/config +++ b/src/variants/bananapi-m1/config @@ -1 +1,2 @@ -OCTOPI_ZIP_IMG=`ls -t $IMAGE_PATH/*-raspbian-bpi-R1-M1*.zip | head -n 1` +VARIANT_CONFIG_DIR=$(realpath -s $(dirname $(realpath -s $BASH_SOURCE))/../..) +OCTOPI_ZIP_IMG=`ls -t $VARIANT_CONFIG_DIR/image-varients/*-raspbian-bpi-R1-M1*.zip | head -n 1` From b76b280d795c16b4b8a470a203b53b0f10d0aaea Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Sat, 2 Jan 2016 16:31:29 +0200 Subject: [PATCH 099/352] Move git clone outside chroot, because qemu-arm-static tends to hang on smart-http clones (using --depth) --- src/chroot_script | 10 +++++----- src/common.sh | 4 ++-- src/octopi | 9 +++++++++ 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/chroot_script b/src/chroot_script index 8195a58e..d3e06281 100755 --- a/src/chroot_script +++ b/src/chroot_script @@ -71,7 +71,7 @@ pushd /home/pi done apt-get remove -y --purge python-openssl python-cryptography apt-get autoremove -y - chown -R pi.pi /home/pi/oprint + chown -R pi:pi /home/pi/oprint sudo -u pi /home/pi/oprint/bin/pip install ndg-httpsclient pyasn1 # OctoPrint & pyserial @@ -83,7 +83,7 @@ pushd /home/pi sudo -u pi /home/pi/oprint/bin/pip install https://pybonjour.googlecode.com/files/pybonjour-1.1.1.tar.gz #OctoPrint - gitclone OCTOPI_OCTOPRINT_REPO OctoPrint + chown -R pi:pi OctoPrint pushd OctoPrint PIP_DEFAULT_TIMEOUT=60 sudo -u pi /home/pi/oprint/bin/python setup.py install popd @@ -93,13 +93,13 @@ pushd /home/pi if [ "$OCTOPI_INCLUDE_OCTOPIPANEL" == "yes" ] then echo "--- Installing OctoPiPanel" - gitclone OCTOPI_OCTOPIPANEL_REPO OctoPiPanel + chown -R pi:pi OctoPiPanel pushd OctoPiPanel sudo -u pi /home/pi/oprint/bin/pip install -r requirements.txt popd #Add fbcp for TFT screens - gitclone OCTOPI_FBCP_REPO rpi-fbcp + chown -R pi:pi rpi-fbcp pushd rpi-fbcp sudo -u pi mkdir build pushd build @@ -116,7 +116,7 @@ pushd /home/pi then echo "--- Installing mjpg-streamer" apt-get -y --force-yes --no-install-recommends install libjpeg8-dev imagemagick libav-tools libv4l-dev - gitclone OCTOPI_MJPGSTREAMER_REPO mjpg-streamer + chown -R pi:pi mjpg-streamer pushd mjpg-streamer mv mjpg-streamer-experimental/* . sudo -u pi make diff --git a/src/common.sh b/src/common.sh index 6fc09571..6a41cdc3 100755 --- a/src/common.sh +++ b/src/common.sh @@ -77,12 +77,12 @@ function gitclone(){ clone_params="$clone_params --depth $depth" fi - sudo -u pi git clone $clone_params "$build_repo" "$repo_dir" + git clone $clone_params "$build_repo" "$repo_dir" if [ "$build_repo" != "$ship_repo" ] then pushd "$repo_dir" - sudo -u pi git remote set-url origin "$ship_repo" + git remote set-url origin "$ship_repo" popd fi } diff --git a/src/octopi b/src/octopi index 72876812..3de91f75 100755 --- a/src/octopi +++ b/src/octopi @@ -32,6 +32,7 @@ install_fail_on_error_trap $OCTOPI_MOUNT_PATH unmount_image $OCTOPI_MOUNT_PATH || true pushd $OCTOPI_WORKSPACE + if [ -e *.img ]; then rm *.img fi @@ -55,6 +56,14 @@ pushd $OCTOPI_WORKSPACE #Edit pi filesystem pushd $OCTOPI_MOUNT_PATH + #Put git clones in place + + pushd home/pi + gitclone OCTOPI_OCTOPRINT_REPO OctoPrint + gitclone OCTOPI_OCTOPIPANEL_REPO OctoPiPanel + gitclone OCTOPI_FBCP_REPO rpi-fbcp + gitclone OCTOPI_MJPGSTREAMER_REPO mjpg-streamer + popd #make QEMU boot (remember to return) fixLd From 8a8307fb56230712970d94a91b78f63c63a6060c Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Sat, 2 Jan 2016 17:07:39 +0200 Subject: [PATCH 100/352] Fix bananapi build #183 #156 --- src/chroot_script | 29 +++++++++++++++------- src/common.sh | 16 ++++++++++++ src/variants/bananapi-m1/pre_chroot_script | 1 + 3 files changed, 37 insertions(+), 9 deletions(-) diff --git a/src/chroot_script b/src/chroot_script index 8195a58e..c0d2ffe4 100755 --- a/src/chroot_script +++ b/src/chroot_script @@ -41,7 +41,12 @@ unpack /filesystem/boot /boot apt-get update # in case we are building from a regular raspbian image instead of the lite one... -apt-get remove -y --purge scratch squeak-plugins-scratch squeak-vm wolfram-engine python-minecraftpi minecraft-pi sonic-pi oracle-java8-jdk bluej greenfoot libreoffice-common libreoffice-core freepats nodered +remove_extra="" +if [ $( is_installed greenfoot ) -eq 1 ]; +then + remove_extra="$remove_extra greenfoot nodered" +fi +apt-get remove -y --purge scratch squeak-plugins-scratch squeak-vm wolfram-engine python-minecraftpi minecraft-pi sonic-pi oracle-java8-jdk bluej libreoffice-common libreoffice-core freepats $remove_extra apt-get autoremove -y apt-get -y --force-yes install python2.7 python-virtualenv python-dev git screen libts-bin subversion cmake checkinstall avahi-daemon libavahi-compat-libdnssd1 libffi-dev libssl-dev @@ -62,14 +67,20 @@ pushd /home/pi # since that stuff takes ages to compile during build, we do a somewhat dirty # trick here by installing the raspbian versions, copying the libs over # to our virtualenv and then purging the raspbian versions again - apt-get -y --force-yes install python-openssl python-cryptography - from=/usr/lib/python2.7/dist-packages - to=/home/pi/oprint/lib/python2.7/site-packages - for pattern in "cffi*" "cryptography*" "OpenSSL*" "ply*" "pycparser*" "pyOpenSSL*" "six*" - do - cp -v -r --preserve=mode,timestamps $from/$pattern $to/ - done - apt-get remove -y --purge python-openssl python-cryptography + apt-get -y --force-yes install python-openssl + if [ $( is_in_apt python-cryptography ) -eq 1 ]; then + apt-get -y --force-yes install python-cryptography + from=/usr/lib/python2.7/dist-packages + to=/home/pi/oprint/lib/python2.7/site-packages + for pattern in "cffi*" "cryptography*" "OpenSSL*" "ply*" "pycparser*" "pyOpenSSL*" "six*" + do + cp -v -r --preserve=mode,timestamps $from/$pattern $to/ + done + apt-get remove -y --purge python-openssl python-cryptography + else + sudo -u pi /home/pi/oprint/bin/pip install cryptography + apt-get remove -y --purge python-openssl + fi apt-get autoremove -y chown -R pi.pi /home/pi/oprint sudo -u pi /home/pi/oprint/bin/pip install ndg-httpsclient pyasn1 diff --git a/src/common.sh b/src/common.sh index 6fc09571..60b52d6c 100755 --- a/src/common.sh +++ b/src/common.sh @@ -298,3 +298,19 @@ function minimize_ext() { enlarge_ext $image 2 $((-$size_offset_mb + 1)) # +1 to compensat rounding mistakes fi } + +function is_installed(){ + # checks if a package is installed, returns 1 if installed and 0 if not. + # usage: is_installed + dpkg-query -W -f='${Status}' $1 2>/dev/null | grep -c "ok installed" +} + +function is_in_apt(){ + #checks if a package is in the apt repo, returns 1 if exists and 0 if not + #usage is_in_apt + if [ $(apt-cache policy $1 | wc | awk '{print $1}') -gt 0 ]; then + echo 1 + else + echo 0 + fi +} diff --git a/src/variants/bananapi-m1/pre_chroot_script b/src/variants/bananapi-m1/pre_chroot_script index da988bb9..f24455be 100755 --- a/src/variants/bananapi-m1/pre_chroot_script +++ b/src/variants/bananapi-m1/pre_chroot_script @@ -8,4 +8,5 @@ install_chroot_fail_on_error_trap unpack /filesystem/root / #cleanup +mkdir -p /var/cache/apt/archives apt-get clean From 133d88b8f11b88776499a129929d658fdfb0e37c Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Sat, 2 Jan 2016 19:47:48 +0200 Subject: [PATCH 101/352] Add git dependency which moved outside of chroot --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index dc758099..e0544c70 100644 --- a/README.rst +++ b/README.rst @@ -64,7 +64,7 @@ OctoPi can be built from Debian, Ubuntu, Raspbian, or even OctoPi. Build requires about 2.5 GB of free space available. You can build it by issuing the following commands:: - sudo apt-get install gawk util-linux realpath qemu-user-static + sudo apt-get install gawk util-linux realpath git qemu-user-static git clone https://github.com/guysoft/OctoPi.git cd OctoPi/src/image From 3aac0c8783b3fd90455cb9511178f3cb93fe248d Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Tue, 5 Jan 2016 19:20:59 +0200 Subject: [PATCH 102/352] Use sfdisk instead of fdisk, grow partition insterad of delete and create --- src/common.sh | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/src/common.sh b/src/common.sh index efe59075..46c7cd91 100755 --- a/src/common.sh +++ b/src/common.sh @@ -174,19 +174,7 @@ function enlarge_ext() { start=$(sfdisk -d $image | grep "$image$partition" | awk '{print $4-0}') offset=$(($start*512)) dd if=/dev/zero bs=1M count=$size >> $image - fdisk $image < Date: Wed, 6 Jan 2016 01:12:25 +0200 Subject: [PATCH 103/352] Run systemctl only if exists, added for legacy builds of bananapi #183 --- src/chroot_script | 2 +- src/common.sh | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/chroot_script b/src/chroot_script index b513ae14..cc06a9e4 100755 --- a/src/chroot_script +++ b/src/chroot_script @@ -214,7 +214,7 @@ unpack /filesystem/root / ### setup services ### Disable GUI at start -systemctl disable lightdm.service +systemctl_if_exists disable lightdm.service update-rc.d prepare_resize defaults diff --git a/src/common.sh b/src/common.sh index 46c7cd91..4ca0d8d1 100755 --- a/src/common.sh +++ b/src/common.sh @@ -302,3 +302,11 @@ function is_in_apt(){ echo 0 fi } + +systemctl_if_exists() { + if hash systemctl 2>/dev/null; then + systemctl "$@" + else + echo "no systemctl, not running" + fi +} From 1fdff7b6cbac74459005e4b5b6b3f0a3b1aa7a3c Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Wed, 6 Jan 2016 11:38:33 +0200 Subject: [PATCH 104/352] Change fdisk to sdisk --- src/common.sh | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/common.sh b/src/common.sh index 4ca0d8d1..ac63b299 100755 --- a/src/common.sh +++ b/src/common.sh @@ -214,19 +214,8 @@ function shrink_ext() { new_end=$(($start + $e2ftarget_blocks)) echo "Resizing partition to end at $start + $e2ftarget_blocks = $new_end blocks..." - fdisk $image < Date: Wed, 6 Jan 2016 11:39:59 +0200 Subject: [PATCH 105/352] Add jenk8ins rule when download not found --- src/jenkins-ci/console_parsing | 1 + 1 file changed, 1 insertion(+) diff --git a/src/jenkins-ci/console_parsing b/src/jenkins-ci/console_parsing index b24cd12e..0c8561e6 100644 --- a/src/jenkins-ci/console_parsing +++ b/src/jenkins-ci/console_parsing @@ -3,3 +3,4 @@ error /mv: cannot stat/ error /md5sum: * No such file or directory/ error /Error is not recoverable: exiting now/ error /Network is unreachable/ +error /404 Not Found/ From c0b689971e4df42ce1957b6e675abdeca671be20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 12 Jan 2016 15:16:40 +0100 Subject: [PATCH 106/352] Custom error page in haproxy for 503 error Should help users to understand why they are not seeing their OctoPrint interface but instead an error from haproxy if the server is not (yet) running. --- .../etc/haproxy/errors/503-no-octoprint.http | 111 ++++++++++++++++++ src/filesystem/root/etc/haproxy/haproxy.cfg | 1 + 2 files changed, 112 insertions(+) create mode 100644 src/filesystem/root/etc/haproxy/errors/503-no-octoprint.http diff --git a/src/filesystem/root/etc/haproxy/errors/503-no-octoprint.http b/src/filesystem/root/etc/haproxy/errors/503-no-octoprint.http new file mode 100644 index 00000000..b07b4cb1 --- /dev/null +++ b/src/filesystem/root/etc/haproxy/errors/503-no-octoprint.http @@ -0,0 +1,111 @@ +HTTP/1.0 503 Service Unavailable +Cache-Control: no-cache +Connection: close +Content-Type: text/html + + + + OctoPrint is still starting + + + +
+

The OctoPrint server is currently not running

+ +

+ If you just started up your Raspberry Pi, please wait a couple of seconds, then + try to refresh this page. +

+ +

+ If the issue persists, please log into your Raspberry Pi via SSH and check the following: +

+ +
    +
  • + Verify that the process is running: + ps -ef | grep -i octoprint should show a + python process. +
  • +
  • + If it isn't, the question is why. Take a look into + ~/.octoprint/logs/octoprint.log, there might + be an error logged in there that helps to determine + what's wrong. +
  • +
  • + You might also want to try if you can restart the server + (if no obvious error is visible): + sudo service octoprint restart. +
  • +
+ +

+ If all that doesn't help to trouble shoot the issue, you can seek + support on the + OctoPrint Mailinglist + or in the OctoPrint G+ Community. +

+
+ + + diff --git a/src/filesystem/root/etc/haproxy/haproxy.cfg b/src/filesystem/root/etc/haproxy/haproxy.cfg index 2acfa3c0..93c13d47 100644 --- a/src/filesystem/root/etc/haproxy/haproxy.cfg +++ b/src/filesystem/root/etc/haproxy/haproxy.cfg @@ -24,6 +24,7 @@ frontend public option forwardfor except 127.0.0.1 use_backend webcam if { path_beg /webcam/ } default_backend octoprint + errorfile 503 /etc/haproxy/errors/503-no-octoprint.http backend octoprint reqrep ^([^\ :]*)\ /(.*) \1\ /\2 From aa464226cbab03f46fb7b484e37749e78008ce93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 12 Jan 2016 15:20:25 +0100 Subject: [PATCH 107/352] Reworded the title, was misleading --- src/filesystem/root/etc/haproxy/errors/503-no-octoprint.http | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/filesystem/root/etc/haproxy/errors/503-no-octoprint.http b/src/filesystem/root/etc/haproxy/errors/503-no-octoprint.http index b07b4cb1..740f815a 100644 --- a/src/filesystem/root/etc/haproxy/errors/503-no-octoprint.http +++ b/src/filesystem/root/etc/haproxy/errors/503-no-octoprint.http @@ -5,7 +5,7 @@ Content-Type: text/html - OctoPrint is still starting + OctoPrint is currently not running + + +
+

The webcam server is currently not running

+ +

+ If you do not have a camera attached, this is normal and can be safely ignored. +

+ +

+ Otherwise, if you just started up your Raspberry Pi or just plugged in your camera, + please wait a couple of seconds. +

+ +

+ If the issue persists, please check the following: +

+ +
    +
  • + If you have a Raspberry Pi camera, verify that it is properly attached. The ribbon + cable can be plugged in the wrong way. Power off your Pi first, do not attempt + to attach or detach the Raspberry Pi camera while the Pi is powered! +
  • +
  • + If you have a USB camera, it might be that it does not support MJPG (Motion JPEG) natively and needs the + -y parameter to work. Try editing octopi.txt, + add -y to camera_usb_options and make sure to remove the leading #, e.g.: +
    camera_usb_options="-r 640x480 -f 10 -y"
    + Reboot your Raspberry Pi with the camera attached and see if that makes it work.
    + Note: If your camera doesn't support MJPG natively, the webcam server will have to use valuable + system resources to transcode the camera stream which could be better used for printing. Consider + getting a camera that does support MJPG natively. +
  • +
  • + Log into your Raspberry Pi via SSH. Check if your camera is detected by the system via lsusb. + If it is check what the webcam server is reporting in /var/log/webcamd.log, there might be an + error logged in there that helps to determine what's wrong. +
  • +
+ +

+ If all that doesn't help to trouble shoot the issue, you can seek + support on the + OctoPrint Mailinglist + or in the OctoPrint G+ Community. + Please provide your camera model, lsusb output and /var/log/webcamd.log (as a + pastebin link) and explain what you + already tried and observed as detailed as possible. +

+
+ + + diff --git a/src/filesystem/root/etc/haproxy/haproxy.cfg b/src/filesystem/root/etc/haproxy/haproxy.cfg index 93c13d47..d137502f 100644 --- a/src/filesystem/root/etc/haproxy/haproxy.cfg +++ b/src/filesystem/root/etc/haproxy/haproxy.cfg @@ -24,14 +24,16 @@ frontend public option forwardfor except 127.0.0.1 use_backend webcam if { path_beg /webcam/ } default_backend octoprint - errorfile 503 /etc/haproxy/errors/503-no-octoprint.http backend octoprint reqrep ^([^\ :]*)\ /(.*) \1\ /\2 reqadd X-Scheme:\ https if { ssl_fc } option forwardfor server octoprint1 127.0.0.1:5000 + errorfile 503 /etc/haproxy/errors/503-no-octoprint.http backend webcam reqrep ^([^\ :]*)\ /webcam/(.*) \1\ /\2 server webcam1 127.0.0.1:8080 + errorfile 503 /etc/haproxy/errors/503-no-webcam.http + From 9686bc6110557a7a81748b213f26ec7ad152d0e9 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Sat, 23 Jul 2016 21:18:44 +0300 Subject: [PATCH 137/352] Adding instruction how to build a variant from vagrant --- README.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.rst b/README.rst index 12f59186..d13ca3f3 100644 --- a/README.rst +++ b/README.rst @@ -99,6 +99,12 @@ After provisioning the machine, its also possible to run a nightly build which u cd OctoPi/src/vagrant run_vagrant_build.sh + +To build a variant on the machine simply run: + + cd FullPageOS/src/vagrant + run_vagrant_build.sh [Variant] + Usage ~~~~~ From 1954b8de534fbd712bb65a0033ca902e9de77d83 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Sat, 23 Jul 2016 21:19:29 +0300 Subject: [PATCH 138/352] Fix syntax typo in last commit --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index d13ca3f3..bcfa1434 100644 --- a/README.rst +++ b/README.rst @@ -100,7 +100,7 @@ After provisioning the machine, its also possible to run a nightly build which u cd OctoPi/src/vagrant run_vagrant_build.sh -To build a variant on the machine simply run: +To build a variant on the machine simply run:: cd FullPageOS/src/vagrant run_vagrant_build.sh [Variant] From 326bbdfa73093bc9afe82737e733386c457a4fd6 Mon Sep 17 00:00:00 2001 From: Kenneth Jiang Date: Mon, 15 Aug 2016 07:17:58 -0700 Subject: [PATCH 139/352] Allow configuring multiple wifi networks using wpa_supplicant (#250) * use wpa_supplicant to configure wifi * filename change octopi-network.txt -> octopi-ethernet.txt since it only configures ethernet now * better format * revert 22ec5acf530789e3d23336ba7df7a06f8ec202ce 13e3fc11556bf7a7c1af0b3e7787fc0b341c57a1 ff3f3517832c746874624c1562a3b6c2687f53e0 * Only add /boot/octopi-wifi.txt, symlinked to /etc/wpa_supplicant/wpa_supplicant.conf, without breaking existing /boot/octopi-network.txt mechanism * clear documentation for distinctions between octopi-network.txt and octopi-wifi.txt * Change name /boot/octopi-wifi.txt -> /boot/octopi-wpa-supplicant.txt to avoid confusion --- src/chroot_script | 20 ++++++++++++++++++++ src/filesystem/boot/octopi-network.txt | 2 ++ 2 files changed, 22 insertions(+) diff --git a/src/chroot_script b/src/chroot_script index 99f7890b..491fadb6 100755 --- a/src/chroot_script +++ b/src/chroot_script @@ -212,6 +212,26 @@ echo "mapping wlan1" >> /etc/network/interfaces echo " script /root/bin/map_iface" >> /etc/network/interfaces echo "source /boot/octopi-network.txt" >> /etc/network/interfaces +# allow configuring multiple wifi networks via /boot/octopi-wpa-supplicant.txt +mv /etc/wpa_supplicant/wpa_supplicant.conf /boot/octopi-wpa-supplicant.txt +ln -s /boot/octopi-wpa-supplicant.txt /etc/wpa_supplicant/wpa_supplicant.conf +cat <> /etc/wpa_supplicant/wpa_supplicant.conf + +# This is only used to configure multiple wifi networks or other advanced wifi features. +# take a look into octopi-network.txt instead if you only need basic wifi configuration +# 'man -s 5 wpa_supplicant.conf' for advanced options +#network={ +# ssid="Your Wifi SSID" +# psk="supersecretwifipassword" +#} + +## You can configure more than 1 wifi networks by adding more 'network' blocks +#network={ +# ssid="Another Wifi" +# psk="password" +#} +EOT + # copy /etc/wpa_supplicant/ifupdown.sh to /etc/ifplugd/action.d/ifupdown - for wlan auto reconnect [ -f /etc/ifplugd/action.d/ifupdown ] && mv /etc/ifplugd/action.d/ifupdown /etc/ifplugd/action.d/ifupdown.original [ -f /etc/wpa_supplicant/ifupdown.sh ] && ln -s /etc/wpa_supplicant/ifupdown.sh /etc/ifplugd/action.d/ifupdown diff --git a/src/filesystem/boot/octopi-network.txt b/src/filesystem/boot/octopi-network.txt index 17343a35..2cb22c67 100644 --- a/src/filesystem/boot/octopi-network.txt +++ b/src/filesystem/boot/octopi-network.txt @@ -9,6 +9,8 @@ # # Just uncomment the lines prefixed with a single # of the configuration # that matches your wifi setup and fill in SSID and passphrase. +# +# If you need to configure more than 1 wifi networks, please use /boot/octopi-wpa-supplicant.txt instead ## WPA/WPA2 secured #iface wlan0-octopi inet manual From 47c94a164d0e8715a94d1fd0b3f8ab0424441ba4 Mon Sep 17 00:00:00 2001 From: Karl Kangur Date: Tue, 16 Aug 2016 09:31:25 +0200 Subject: [PATCH 140/352] Corrected the IP address It might lend to confusion when the static IP address is set to 192.168.250.10 and then suggested that the system can be reached from 192.168.250.1, this is obviously a typo. --- src/filesystem/boot/octopi-network.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/filesystem/boot/octopi-network.txt b/src/filesystem/boot/octopi-network.txt index 2cb22c67..5c07931b 100644 --- a/src/filesystem/boot/octopi-network.txt +++ b/src/filesystem/boot/octopi-network.txt @@ -41,7 +41,7 @@ # # You can then reach the Pi from the system's browser by going to # -# http://192.168.250.1 +# http://192.168.250.10 # # or # From 944714e927bae41862b280bd212f09c06a77f182 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Thu, 18 Aug 2016 11:45:05 +0300 Subject: [PATCH 141/352] Shift gnet.homelinux.com to gnethomelinux.com, bye bye DynDNS and their crazy pricing --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index bcfa1434..112a14ff 100644 --- a/README.rst +++ b/README.rst @@ -18,7 +18,7 @@ Download the latest stable build via this button: Official mirror is `here `_ -Nightly builds are available `here `_ +Nightly builds are available `here `_ How to use it? -------------- From 15a867b5e7f926a43f0f4032ec1b0c34a5c1e310 Mon Sep 17 00:00:00 2001 From: make-ing Date: Fri, 30 Sep 2016 15:56:41 +0200 Subject: [PATCH 142/352] fixed pybonjour download link --- src/chroot_script | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/chroot_script b/src/chroot_script index 491fadb6..1ce38dc9 100755 --- a/src/chroot_script +++ b/src/chroot_script @@ -96,7 +96,7 @@ pushd /home/pi echo "--- Installing OctoPrint" #pybonjour (for mdns discovery) - sudo -u pi /home/pi/oprint/bin/pip install https://pybonjour.googlecode.com/files/pybonjour-1.1.1.tar.gz + sudo -u pi /home/pi/oprint/bin/pip install https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/pybonjour/pybonjour-1.1.1.tar.gz #OctoPrint gitclone OCTOPI_OCTOPRINT_REPO OctoPrint From 4facdad841c3316abf897aec1634564f0260296e Mon Sep 17 00:00:00 2001 From: make-ing Date: Wed, 5 Oct 2016 12:03:51 +0200 Subject: [PATCH 143/352] changed vagrant box to "wzurowski/vivid64" which has the guest additions installed. --- src/vagrant/Vagrantfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vagrant/Vagrantfile b/src/vagrant/Vagrantfile index d62f67a9..76d14f72 100644 --- a/src/vagrant/Vagrantfile +++ b/src/vagrant/Vagrantfile @@ -1,6 +1,6 @@ Vagrant.configure("2") do |o| # o.vm.box = "octopi-build" - o.vm.box= "https://github.com/kraksoft/vagrant-box-ubuntu/releases/download/15.04/ubuntu-15.04-amd64.box" + o.vm.box= "wzurowski/vivid64" o.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'" o.vm.synced_folder "../../", "/OctoPi", create:true, type: "nfs" o.vm.network :private_network, ip: "192.168.55.55" From dc66324db09275aa555e08bd2ce148bfc1dc0f34 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Mon, 21 Nov 2016 17:23:29 +0200 Subject: [PATCH 144/352] Workaround pip 9.0.0 that breaks install of pyasn1 fixes #276 --- src/chroot_script | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/chroot_script b/src/chroot_script index 1ce38dc9..f7d373a5 100755 --- a/src/chroot_script +++ b/src/chroot_script @@ -66,7 +66,7 @@ pushd /home/pi sudo -u pi virtualenv oprint # first lets upgrade pip (the shipped version is way too old...) - sudo -u pi /home/pi/oprint/bin/pip install --upgrade pip + sudo -u pi /home/pi/oprint/bin/pip install --upgrade "pip>=8,<9" # we also want pyopenssl so we have a secure SSL context available # since that stuff takes ages to compile during build, we do a somewhat dirty From 02341c07f3cf1f87915b39e05931496c3b4098a9 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Mon, 28 Nov 2016 14:25:17 +0200 Subject: [PATCH 145/352] Track python errors --- src/jenkins-ci/console_parsing | 1 + 1 file changed, 1 insertion(+) diff --git a/src/jenkins-ci/console_parsing b/src/jenkins-ci/console_parsing index f26354e9..f3a971d8 100644 --- a/src/jenkins-ci/console_parsing +++ b/src/jenkins-ci/console_parsing @@ -6,3 +6,4 @@ error /Network is unreachable/ error /error: timed out/ error /404 Not Found/ error /Failed to fetch/ +error /Traceback/ From 3125bcc67e153e979bd2e1f9c8d8f9fccee80ed4 Mon Sep 17 00:00:00 2001 From: Guillaume Molter Date: Wed, 30 Nov 2016 10:52:49 -0500 Subject: [PATCH 146/352] Adding note for MacOS users using Textedit Related to https://github.com/guysoft/OctoPi/issues/222 --- src/filesystem/boot/octopi-network.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/filesystem/boot/octopi-network.txt b/src/filesystem/boot/octopi-network.txt index 5c07931b..60e70d13 100644 --- a/src/filesystem/boot/octopi-network.txt +++ b/src/filesystem/boot/octopi-network.txt @@ -11,6 +11,11 @@ # that matches your wifi setup and fill in SSID and passphrase. # # If you need to configure more than 1 wifi networks, please use /boot/octopi-wpa-supplicant.txt instead +# +# !! MacOS users !! +# If you use Textedit to edit this file make sure to use "plain text format" +# and "disable smart quotes" in "Textedit > Preferences", otherwise Textedit +# will use none-compatible characters. ## WPA/WPA2 secured #iface wlan0-octopi inet manual From e3aa517b973532e2e90edd5d0cae90912ed3d66d Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Sat, 18 Feb 2017 03:31:20 +0200 Subject: [PATCH 147/352] Fixes #294 --- src/chroot_script | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/chroot_script b/src/chroot_script index f7d373a5..b2037ffc 100755 --- a/src/chroot_script +++ b/src/chroot_script @@ -249,6 +249,9 @@ update-rc.d prepare_resize defaults update-rc.d change_password defaults update-rc.d change_hostname defaults +### Fix SSH +echo "IPQoS 0x00" >> /etc/ssh/sshd_config + ### OctoPrint if [ "$OCTOPI_INCLUDE_OCTOPRINT" == "yes" ] From 838d5be019faa56e2473db3803743fc292376fee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 28 Feb 2017 10:23:04 +0000 Subject: [PATCH 148/352] Adjusted config.yaml to match layout of OctoPrint 1.3.x --- src/filesystem/home/pi/.octoprint/config.yaml | 27 ++++--------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/src/filesystem/home/pi/.octoprint/config.yaml b/src/filesystem/home/pi/.octoprint/config.yaml index 51daab56..1089900c 100644 --- a/src/filesystem/home/pi/.octoprint/config.yaml +++ b/src/filesystem/home/pi/.octoprint/config.yaml @@ -11,25 +11,8 @@ plugins: checks: octoprint: update_folder: /home/pi/OctoPrint - octoprint_restart_command: sudo service octoprint restart - environment_restart_command: sudo shutdown -r now -system: - actions: - - name: Shutdown - command: sudo shutdown -h now - action: shutdown - confirm: You are about to shutdown the system. - async: true - ignore: true - - name: Reboot - command: sudo shutdown -r now - action: reboot - confirm: You are about to reboot the system - async: true - ignore: true - - name: Restart OctoPrint - command: sudo service octoprint restart - action: restart - confirm: You are about to restart OctoPrint - async: true - ignore: true +server: + commands: + systemShutdownCommand: sudo shutdown -h now + systemRestartCommand: sudo shutdown -r now + serverRestartCommand: sudo service octoprint restart From e274b54be4330bbb20af3327da9308c7af55cd1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 28 Feb 2017 10:24:03 +0000 Subject: [PATCH 149/352] We run headless, we want SSH on by default --- src/filesystem/boot/ssh | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/filesystem/boot/ssh diff --git a/src/filesystem/boot/ssh b/src/filesystem/boot/ssh new file mode 100644 index 00000000..e69de29b From af02470111a62a875c581388d5301ec44c88b307 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 28 Feb 2017 10:50:46 +0000 Subject: [PATCH 150/352] Clarified some things in octopi-network.txt --- src/filesystem/boot/octopi-network.txt | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/filesystem/boot/octopi-network.txt b/src/filesystem/boot/octopi-network.txt index 60e70d13..df3d60d6 100644 --- a/src/filesystem/boot/octopi-network.txt +++ b/src/filesystem/boot/octopi-network.txt @@ -3,6 +3,15 @@ # This file is included into /etc/network/interfaces, so anything that # works by editing that file is also possible here. +# !!!!! HEADS-UP MACOSX USERS !!!!! +# +# If you use Textedit to edit this file make sure to use "plain text format" +# and "disable smart quotes" in "Textedit > Preferences", otherwise Textedit +# will use none-compatible characters and your network configuration won't +# work! +# +# !!!!! HEADS-UP MACOSX USERS !!!!! + ### WIFI CONFIGURATION ###################################################### # The three segments below should cover you in most cases if you run # a wifi network that uses either WPA/WPA2 or WEP encryption. @@ -10,12 +19,7 @@ # Just uncomment the lines prefixed with a single # of the configuration # that matches your wifi setup and fill in SSID and passphrase. # -# If you need to configure more than 1 wifi networks, please use /boot/octopi-wpa-supplicant.txt instead -# -# !! MacOS users !! -# If you use Textedit to edit this file make sure to use "plain text format" -# and "disable smart quotes" in "Textedit > Preferences", otherwise Textedit -# will use none-compatible characters. +# If you need to configure more than 1 wifi network, please use /boot/octopi-wpa-supplicant.txt instead ## WPA/WPA2 secured #iface wlan0-octopi inet manual @@ -32,7 +36,12 @@ # wireless-essid "put SSID here" # wireless-mode managed -### WIRED CONFIGURATION ##################################################### +### WIRED CONFIGURATION WITH DHCP ########################################### +# Nothing to do, OctoPi is already preconfigured that way. Just plug in your +# cable, wait for an IP to be assigned and stuff should work out of the box +# just fine. + +### WIRED CONFIGURATION WITH STATIC IP ###################################### # The following segment allows you to configure your wired connection # with a static IP. # @@ -46,7 +55,7 @@ # # You can then reach the Pi from the system's browser by going to # -# http://192.168.250.10 +# http://192.168.250.1 # # or # From 7b17940ab2f255f6efd1a6bfcdebcb2b05852768 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 28 Feb 2017 11:00:21 +0000 Subject: [PATCH 151/352] Removed duplicated SD resize on boot Raspbian now apparently does that on its own --- src/chroot_script | 1 - src/filesystem/boot/octopi.txt | 7 --- src/filesystem/root/etc/init.d/prepare_resize | 46 ------------------- 3 files changed, 54 deletions(-) delete mode 100755 src/filesystem/root/etc/init.d/prepare_resize diff --git a/src/chroot_script b/src/chroot_script index b2037ffc..9f42fa77 100755 --- a/src/chroot_script +++ b/src/chroot_script @@ -245,7 +245,6 @@ unpack /filesystem/root / ### Disable GUI at start systemctl_if_exists disable lightdm.service -update-rc.d prepare_resize defaults update-rc.d change_password defaults update-rc.d change_hostname defaults diff --git a/src/filesystem/boot/octopi.txt b/src/filesystem/boot/octopi.txt index 258cb1c2..56b1c0fb 100644 --- a/src/filesystem/boot/octopi.txt +++ b/src/filesystem/boot/octopi.txt @@ -1,10 +1,3 @@ -### Configure whether to automatically resize the SD on first boot -# -# Available options are: -# - yes: perform resize -# - no: don't perform resize -perform_resize="yes" - ### Configure which camera to use # # Available options are: diff --git a/src/filesystem/root/etc/init.d/prepare_resize b/src/filesystem/root/etc/init.d/prepare_resize deleted file mode 100755 index 67d8071b..00000000 --- a/src/filesystem/root/etc/init.d/prepare_resize +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/sh -### BEGIN INIT INFO -# Provides: prepare_resize -# Required-Start: $local_fs -# Required-Stop: -# Default-Start: 3 -# Default-Stop: -# Short-Description: Prepare resize on first boot... -# Description: -### END INIT INFO - -. /lib/lsb/init-functions - -do_start () { - . /boot/octopi.txt - - if [ "$perform_resize" != "yes" ] - then - log_failure_msg "Resize on boot is disabled" - exit 1 - fi - - /usr/bin/raspi-config --expand-rootfs >> /var/log/prepare_resize - /usr/sbin/update-rc.d prepare_resize remove >> /var/log/prepare_resize - - log_success_msg "Resize prepared, rebooting to apply..." - /sbin/reboot -} - -echo "First parameter is $1" >> /var/log/prepare_resize -case "$1" in - start|"") - do_start - ;; - restart|reload|force-reload) - echo "Error: argument '$1' not supported" >&2 - exit 3 - ;; - stop) - # No-op - ;; - *) - echo "Usage: prepare_resize [start|stop]" >&2 - exit 3 - ;; -esac From a841274ac4b4bbd48050bc1bb44369e660125b02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 28 Feb 2017 13:46:11 +0000 Subject: [PATCH 152/352] Prevent duplicated X-Scheme headers in haproxy See #239 --- src/filesystem/root/etc/haproxy/haproxy.cfg | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/filesystem/root/etc/haproxy/haproxy.cfg b/src/filesystem/root/etc/haproxy/haproxy.cfg index d137502f..f19cbb8e 100644 --- a/src/filesystem/root/etc/haproxy/haproxy.cfg +++ b/src/filesystem/root/etc/haproxy/haproxy.cfg @@ -26,8 +26,11 @@ frontend public default_backend octoprint backend octoprint + acl needs_scheme req.hdr_cnt(X-Scheme) eq 0 + reqrep ^([^\ :]*)\ /(.*) \1\ /\2 - reqadd X-Scheme:\ https if { ssl_fc } + reqadd X-Scheme:\ https if needs_scheme { ssl_fc } + reqadd X-Scheme:\ http if needs_scheme !{ ssl_fc } option forwardfor server octoprint1 127.0.0.1:5000 errorfile 503 /etc/haproxy/errors/503-no-octoprint.http From 39562afc4e99386e983b5ee96136efec1aa326d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 28 Feb 2017 10:25:26 +0000 Subject: [PATCH 153/352] Remove pip version pin We no longer need to manually setup a solid SSL environment since that's already done for use with Python 2.7.9. The whole issue that we ran into with setting this up under Pip 9+ therefore can be circumvented without having to pin the pip version. Refer to #276 --- src/chroot_script | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/src/chroot_script b/src/chroot_script index 9f42fa77..8da045cc 100755 --- a/src/chroot_script +++ b/src/chroot_script @@ -66,29 +66,7 @@ pushd /home/pi sudo -u pi virtualenv oprint # first lets upgrade pip (the shipped version is way too old...) - sudo -u pi /home/pi/oprint/bin/pip install --upgrade "pip>=8,<9" - - # we also want pyopenssl so we have a secure SSL context available - # since that stuff takes ages to compile during build, we do a somewhat dirty - # trick here by installing the raspbian versions, copying the libs over - # to our virtualenv and then purging the raspbian versions again - apt-get -y --force-yes install python-openssl - if [ $( is_in_apt python-cryptography ) -eq 1 ]; then - apt-get -y --force-yes install python-cryptography - from=/usr/lib/python2.7/dist-packages - to=/home/pi/oprint/lib/python2.7/site-packages - for pattern in "cffi*" "cryptography*" "OpenSSL*" "ply*" "pycparser*" "pyOpenSSL*" "six*" - do - cp -v -r --preserve=mode,timestamps $from/$pattern $to/ - done - apt-get remove -y --purge python-openssl python-cryptography - else - sudo -u pi /home/pi/oprint/bin/pip install cryptography - apt-get remove -y --purge python-openssl - fi - apt-get autoremove -y - chown -R pi.pi /home/pi/oprint - sudo -u pi /home/pi/oprint/bin/pip install ndg-httpsclient pyasn1 + sudo -u pi /home/pi/oprint/bin/pip install --upgrade pip # OctoPrint & pyserial if [ "$OCTOPI_INCLUDE_OCTOPRINT" == "yes" ] From e3e82be2e21084972d490e572e8003d89aded4d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 6 Mar 2017 15:01:51 +0000 Subject: [PATCH 154/352] Adjusted init script to new OctoPrint CLI Running in foreground mode requires "serve" keyword since 1.3.0. Still works without, but logs a warning to console. Also fixed a couple of misspellings of OctoPrint in the init file while at it (capital P in the middle!) ;) --- src/filesystem/root/etc/init.d/octoprint | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/filesystem/root/etc/init.d/octoprint b/src/filesystem/root/etc/init.d/octoprint index 87bf9875..3cbecce8 100755 --- a/src/filesystem/root/etc/init.d/octoprint +++ b/src/filesystem/root/etc/init.d/octoprint @@ -16,8 +16,8 @@ # Author: Sami Olmari PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin -DESC="Octoprint Daemon" -NAME="Octoprint" +DESC="OctoPrint Daemon" +NAME="OctoPrint" DAEMON=/usr/bin/octoprint PIDFILE=/var/run/$NAME.pid PKGNAME=octoprint @@ -73,7 +73,7 @@ do_start() if [ $RETVAL != 0 ]; then start-stop-daemon --start --background --quiet --pidfile $PIDFILE --make-pidfile \ - --exec $DAEMON --chuid $OCTOPRINT_USER --user $OCTOPRINT_USER --umask $UMASK -- $DAEMON_ARGS + --exec $DAEMON --chuid $OCTOPRINT_USER --user $OCTOPRINT_USER --umask $UMASK -- serve $DAEMON_ARGS RETVAL="$?" fi } From 0d553cc3572b2cb70db31ab2e240a51927cd1577 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 6 Mar 2017 16:00:27 +0000 Subject: [PATCH 155/352] Updated install-desktop script Based on current instructions found here: https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=166806&p=1074099 --- .../home/pi/scripts/install-desktop | 30 ++++--------------- 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/src/filesystem/home/pi/scripts/install-desktop b/src/filesystem/home/pi/scripts/install-desktop index 4400122d..a00004ae 100755 --- a/src/filesystem/home/pi/scripts/install-desktop +++ b/src/filesystem/home/pi/scripts/install-desktop @@ -18,8 +18,9 @@ echo "Please keep in mind that the desktop environment needs" echo "system resources that then might not be available for" echo "printing, possible leading to print artifacts." echo "It is not recommended to run the desktop environment" -echo "alongside OctoPrint if you do not have a Pi2 with" -echo "multiple cores. Even then, use at your own risk." +echo "alongside OctoPrint if you do not have a Pi with" +echo "multiple cores (e.g. Pi1 or PiZero). Even then, use" +echo "at your own risk." echo echo "If you do not want to install the desktop environment" echo "after all, please hit Ctrl+C now." @@ -53,7 +54,7 @@ echo echo "--- Installing desktop packages" echo -apt-get install --yes raspberrypi-ui-mods lightdm xinit lxterminal +apt-get install --yes raspberrypi-ui-mods if [ "$x_on_boot" == "yes" ] then @@ -69,27 +70,8 @@ else fi echo -echo "--- Removing uninstalled applications from desktop" +echo "--- Done!" echo -# we make sure that non of the non-installed packages show up in either -# the default lxde panel or menu -basefolder="/usr/share/raspi-ui-overrides/applications/" -lxde_panel_file="/etc/xdg/lxpanel/profile/LXDE-pi/panels/panel" -files="libreoffice-draw libreoffice-math libreoffice-startcenter bluej greenfoot wolfram-mathematica wolfram-language" - -for entry in $files -do - desktop_file="$basefolder$entry.desktop" - - # hide .desktop file from menu - grep "Hidden: true" $desktop_file || echo "Hidden: true" >> $desktop_file - - # remove any links to it from panel - perl -i -p0e 's!\s*Button {\n\s*id='"$desktop_file"'\n\s*}!!igs' "$lxde_panel_file" -done - - -echo -echo "--- Done!" +echo "You might want to reboot now: sudo reboot" echo From b7ca64c42d1eea5b719d87cd164c253d2f5d5c82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 6 Mar 2017 16:34:06 +0000 Subject: [PATCH 156/352] Add "how to use" instructions to boot screen A lot of people appear to get confused when they boot up OctoPi with a screen attached and are then greeted by a command line login instead of OctoPrint. Therefore added instructions to please use a browser to connect to a list of potential addresses to access OctoPrint - that might help. --- src/chroot_script | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/chroot_script b/src/chroot_script index 8da045cc..e0d8039c 100755 --- a/src/chroot_script +++ b/src/chroot_script @@ -214,6 +214,32 @@ EOT [ -f /etc/ifplugd/action.d/ifupdown ] && mv /etc/ifplugd/action.d/ifupdown /etc/ifplugd/action.d/ifupdown.original [ -f /etc/wpa_supplicant/ifupdown.sh ] && ln -s /etc/wpa_supplicant/ifupdown.sh /etc/ifplugd/action.d/ifupdown +# add some "How To" info to boot output +sed -i 's@exit 0@@' /etc/rc.local +cat <<'EOT' >> /etc/rc.local + +echo +echo "------------------------------------------------------------" +echo +echo "You may now open a web browser on your local network and " +echo "navigate to any of the following addresses to access " +echo "OctoPrint:" +echo +echo " http://octopi.local" + +for ip in $(hostname -I); +do + echo " http://$ip" +done + +echo +echo "https is also available, with a self-signed certificate." +echo +echo "------------------------------------------------------------" +echo +EOT +echo 'exit 0' >> /etc/rc.local + #unpack root in the end, so etc file are not overwritten, might need to add two roots int he future unpack /filesystem/root / From 4dcd1839c859098639b7c8cf74445458e887d61a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 6 Mar 2017 18:21:39 +0000 Subject: [PATCH 157/352] Added welcome text to login/bashrc Upon logging in via command line, the user will now get the following information: * IPs/URLs to access OctoPrint * Hint how to install desktop environment if not already installed * Versions of OctoPrint and OctoPi --- src/chroot_script | 3 +++ src/filesystem/home/pi/scripts/welcome | 35 ++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100755 src/filesystem/home/pi/scripts/welcome diff --git a/src/chroot_script b/src/chroot_script index 8da045cc..32ac8bfe 100755 --- a/src/chroot_script +++ b/src/chroot_script @@ -214,6 +214,9 @@ EOT [ -f /etc/ifplugd/action.d/ifupdown ] && mv /etc/ifplugd/action.d/ifupdown /etc/ifplugd/action.d/ifupdown.original [ -f /etc/wpa_supplicant/ifupdown.sh ] && ln -s /etc/wpa_supplicant/ifupdown.sh /etc/ifplugd/action.d/ifupdown +# add a longer welcome text to ~pi/.bashrc +echo "source /home/pi/scripts/welcome" >> /home/pi/.bashrc + #unpack root in the end, so etc file are not overwritten, might need to add two roots int he future unpack /filesystem/root / diff --git a/src/filesystem/home/pi/scripts/welcome b/src/filesystem/home/pi/scripts/welcome new file mode 100755 index 00000000..4b674ec9 --- /dev/null +++ b/src/filesystem/home/pi/scripts/welcome @@ -0,0 +1,35 @@ +#!/bin/bash + +_IP=$(hostname -I) +_OCTOPRINT_VERSION=$(/home/pi/oprint/bin/python -c "from octoprint._version import get_versions; print(get_versions()['version'])" || echo "unknown") +_OCTOPI_VERSION=$(cat /etc/octopi_version || echo "unknown") + +echo +echo "------------------------------------------------------------------------------" +echo "Access OctoPrint from a web browser on your network by navigating to any of:" +echo +echo " http://octopi.local" + +for ip in $_IP; +do + echo " http://$ip" +done + +echo +echo "https is also available, with a self-signed certificate." + +if ! which lightdm 2>&1 >/dev/null; +then + echo "------------------------------------------------------------------------------" + echo "This image comes without a desktop environment installed because it's not " + echo "required for running OctoPrint. If you want a desktop environment you can " + echo "install it via" + echo + echo " sudo /home/pi/scripts/install-desktop" +fi + +echo "------------------------------------------------------------------------------" +echo "OctoPrint version : $_OCTOPRINT_VERSION" +echo "OctoPi version : $_OCTOPI_VERSION" +echo "------------------------------------------------------------------------------" +echo From 6b801071ab5e5ed85cfa114d91442f382986865f Mon Sep 17 00:00:00 2001 From: Martin Hauck Date: Tue, 7 Mar 2017 20:25:18 +0100 Subject: [PATCH 158/352] Update octopi-network.txt Added a hint that the rasperry pi 3 internal wifi does not support channels 12 and 13 atm. Could have saved me some hours of frustration ;) --- src/filesystem/boot/octopi-network.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/filesystem/boot/octopi-network.txt b/src/filesystem/boot/octopi-network.txt index df3d60d6..34334783 100644 --- a/src/filesystem/boot/octopi-network.txt +++ b/src/filesystem/boot/octopi-network.txt @@ -20,6 +20,8 @@ # that matches your wifi setup and fill in SSID and passphrase. # # If you need to configure more than 1 wifi network, please use /boot/octopi-wpa-supplicant.txt instead +# +# ATTENTION: please note that the raspberry pi 3 internal wifi does currently not support the wifi channels 12 and 13 ## WPA/WPA2 secured #iface wlan0-octopi inet manual From 0720d5f6e0732350e7723948075f720c4b3e0bc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Fri, 24 Mar 2017 10:24:27 +0000 Subject: [PATCH 159/352] Prevent NTP updates from failing on RPi3 wifi While I couldn't reproduce this issue on a current build, apparently it doesn't necessarily have to happen always and the corresponding ticket on the rpi bug tracker (raspberrypi/linux#1519) is still open as well. Hence this change. As documented at https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=141454 and other locations, ntp updates on RPi3 (sometimes?) fail if the built-in WiFi interface is used. This appears to be the same issue or at least related to SSH not properly functioning as described in #294 and also documented in raspberrypi/linux#1519. A wrong system date of the underlying OS will cause issues with SSL handshakes, which in turn will produce fatal errors when attempting to install plugins (see foosel/OctoPrint#1827) or probably also when updating either OctoPrint or the system itself. Basically anything that does certificate validity checks will fall on its face. Having the Pi properly set its system date is hence crucial for operation, so we need to make sure ntp can do its job. This might also affect RPiZeroW - I haven't observed the issue with a current build there though. --- src/chroot_script | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/chroot_script b/src/chroot_script index b735b822..5d15ab61 100755 --- a/src/chroot_script +++ b/src/chroot_script @@ -238,6 +238,10 @@ echo echo "------------------------------------------------------------" echo EOT + +# prevent ntp updates from failing due to some Rpi3 weirdness, see also "Fix SSH" further below +echo '/sbin/iptables -t mangle -I POSTROUTING 1 -o wlan0 -p udp --dport 123 -j TOS --set-tos 0x00' >> /etc/rc.local + echo 'exit 0' >> /etc/rc.local # add a longer welcome text to ~pi/.bashrc From cccd42341b725f513663637639845569bac5bdb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 27 Mar 2017 16:07:33 +0000 Subject: [PATCH 160/352] Remove OctoPiPanel and display scripts OctoPiPanel is no longer actively maintained according to its page and the included display scripts are horribly outdated and probably broken beyond repair. Considering the amount of RPi displays at this point, it's probably sensible to rather instruct users to refer to vendor instructions on how to setup a specific display against a Raspbian (lite) image instead of trying to accomodate that ever changing landscape. --- README.rst | 5 +-- src/chroot_script | 42 +------------------ src/config | 11 ----- src/filesystem/boot/cmdline-pi-tft.txt | 1 - src/filesystem/home/pi/scripts/OctoPiPanel | 7 ---- .../home/pi/scripts/calibrate-rpi-display | 3 -- .../home/pi/scripts/enable-adafruit-pitft | 22 ---------- .../home/pi/scripts/enable-rpi-display | 14 ------- src/nightly_build_scripts/build_local_mirrors | 2 - .../octopi_nightly_build | 2 - src/variants/armbian/config | 1 - 11 files changed, 3 insertions(+), 107 deletions(-) delete mode 100644 src/filesystem/boot/cmdline-pi-tft.txt delete mode 100755 src/filesystem/home/pi/scripts/OctoPiPanel delete mode 100755 src/filesystem/home/pi/scripts/calibrate-rpi-display delete mode 100755 src/filesystem/home/pi/scripts/enable-adafruit-pitft delete mode 100755 src/filesystem/home/pi/scripts/enable-rpi-display diff --git a/README.rst b/README.rst index 112a14ff..bf348ed4 100644 --- a/README.rst +++ b/README.rst @@ -5,7 +5,8 @@ OctoPi .. :scale: 50 % .. :alt: OctoPi logo -A `Raspberry Pi `_ distribution for 3d printers. It includes the `OctoPrint `_ host software for 3d printers out of the box and `mjpg-streamer with RaspiCam support `_ for live viewing of prints and timelapse video creation. OctoPi also includes `OctoPiPanel `_, which is an LCD display app that works with OctoPrint, and scripts to configure supported display.s +A `Raspberry Pi `_ distribution for 3d printers. It includes the `OctoPrint `_ host software for 3d printers out of the box and `mjpg-streamer with RaspiCam support `_ for live viewing of prints and timelapse video creation. + This repository contains the source script to generate the distribution out of an existing `Raspbian `_ distro image. Where to get it? @@ -41,8 +42,6 @@ Features * `Raspbian `_ tweaked for maximum preformance for printing out of the box * `mjpg-streamer with RaspiCam support `_ for live viewing of prints and timelapse video creation. * `CuraEngine `_ pre-installed for slicing directly on the Raspberry Pi -* `OctoPiPanel `_, which is an LCD display app that works with OctoPrint -* Configuration scripts for various LCD displays Developing ---------- diff --git a/src/chroot_script b/src/chroot_script index 5d15ab61..5b70050f 100755 --- a/src/chroot_script +++ b/src/chroot_script @@ -49,12 +49,7 @@ echo "removing:" $remove_extra apt-get remove -y --purge $remove_extra apt-get autoremove -y -libts="" -if [ $( is_in_apt libts-bin ) -eq 1 ]; then - libts=libts-bin -fi - -apt-get -y --force-yes install python2.7 python-virtualenv python-dev git screen subversion cmake checkinstall avahi-daemon libavahi-compat-libdnssd1 libffi-dev libssl-dev $libts +apt-get -y --force-yes install python2.7 python-virtualenv python-dev git screen subversion cmake checkinstall avahi-daemon libavahi-compat-libdnssd1 libffi-dev libssl-dev echo " - Reinstall iputils-ping" apt-get install --reinstall iputils-ping @@ -83,28 +78,6 @@ pushd /home/pi popd fi - #OctoPiPanel - if [ "$OCTOPI_INCLUDE_OCTOPIPANEL" == "yes" ] - then - echo "--- Installing OctoPiPanel" - gitclone OCTOPI_OCTOPIPANEL_REPO OctoPiPanel - pushd OctoPiPanel - sudo -u pi /home/pi/oprint/bin/pip install -r requirements.txt - popd - - #Add fbcp for TFT screens - gitclone OCTOPI_FBCP_REPO rpi-fbcp - pushd rpi-fbcp - sudo -u pi mkdir build - pushd build - sudo -u pi cmake .. - sudo -u pi make - install fbcp /usr/local/bin/fbcp - sudo -u pi make clean - popd - popd - fi - #mjpg-streamer if [ "$OCTOPI_INCLUDE_MJPGSTREAMER" == "yes" ] then @@ -308,19 +281,6 @@ else rm /root/bin/webcamd fi -### OctoPiPanel - -if [ ! "$OCTOPI_INCLUDE_OCTOPIPANEL" == "yes" ] -then - # we don't need the tft setup stuff - rm /home/pi/scripts/OctoPiPanel - rm /home/pi/scripts/calibrate-rpi-display - rm /home/pi/scripts/enable-adafruit-pitft - rm /home/pi/scripts/enable-rpi-display - rm /boot/cmdline-pi-tft.txt - rm /etc/udev/rules.d/95-ads7846.rules -fi - #cleanup apt-get clean apt-get autoremove -y diff --git a/src/config b/src/config index a282ad0e..f984d6d1 100755 --- a/src/config +++ b/src/config @@ -70,17 +70,6 @@ fi [ -n "$OCTOPI_OCTOPRINT_REPO_BRANCH" ] || OCTOPI_OCTOPRINT_REPO_BRANCH=master [ -n "$OCTOPI_INCLUDE_OCTOPRINT" ] || OCTOPI_INCLUDE_OCTOPRINT=yes -# OctoPiPanel repo & branch -[ -n "$OCTOPI_OCTOPIPANEL_REPO_SHIP" ] || OCTOPI_OCTOPIPANEL_REPO_SHIP=https://github.com/jonaslorander/OctoPiPanel.git -[ -n "$OCTOPI_OCTOPIPANEL_REPO_BUILD" ] || OCTOPI_OCTOPIPANEL_REPO_BUILD= -[ -n "$OCTOPI_OCTOPIPANEL_REPO_BRANCH" ] || OCTOPI_OCTOPIPANEL_REPO_BRANCH=master -[ -n "$OCTOPI_OCTOPIPANEL_REPO_DEPTH" ] || OCTOPI_OCTOPIPANEL_REPO_DEPTH=1 -[ -n "$OCTOPI_FBCP_REPO_SHIP" ] || OCTOPI_FBCP_REPO_SHIP=https://github.com/tasanakorn/rpi-fbcp -[ -n "$OCTOPI_FBCP_REPO_BUILD" ] || OCTOPI_FBCP_REPO_BUILD=$OCTOPI_FBCP_REPO_SHIP -[ -n "$OCTOPI_FBCP_REPO_BRANCH" ] || OCTOPI_FBCP_REPO_BRANCH= -[ -n "$OCTOPI_FBCP_REPO_DEPTH" ] || OCTOPI_FBCP_REPO_DEPTH=1 -[ -n "$OCTOPI_INCLUDE_OCTOPIPANEL" ] || OCTOPI_INCLUDE_OCTOPIPANEL=yes - # CuraEngine archive & version [ -n "$OCTOPI_CURAENGINE_VERSION" ] || OCTOPI_CURAENGINE_VERSION=15.04.6 [ -n "$OCTOPI_CURAENGINE_ARCHIVE" ] || OCTOPI_CURAENGINE_ARCHIVE=https://github.com/Ultimaker/CuraEngine/archive/$OCTOPI_CURAENGINE_VERSION.zip diff --git a/src/filesystem/boot/cmdline-pi-tft.txt b/src/filesystem/boot/cmdline-pi-tft.txt deleted file mode 100644 index 5f7c9b28..00000000 --- a/src/filesystem/boot/cmdline-pi-tft.txt +++ /dev/null @@ -1 +0,0 @@ -dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait fbtft_device.name=rpi-display fbtft_device.speed=32000000 fbtft_device.rotate=270 fbtft_device.debug=0 fbtft_device.verbose=0 fbcon=map:10 fbcon=font:ProFont6x11 logo.nologo diff --git a/src/filesystem/home/pi/scripts/OctoPiPanel b/src/filesystem/home/pi/scripts/OctoPiPanel deleted file mode 100755 index ec58fa07..00000000 --- a/src/filesystem/home/pi/scripts/OctoPiPanel +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -#Set API key of OctoPiPanel -KEY=$(grep key /home/pi/.octoprint/config.yaml | awk -F " " '{ print $2}') -sed -i 's/API_KEY_GOES_HERE/'"${KEY}"'/g' /home/pi/OctoPiPanel/OctoPiPanel.cfg - -sudo /home/pi/oprint/bin/python /home/pi/OctoPiPanel/OctoPiPanel.py diff --git a/src/filesystem/home/pi/scripts/calibrate-rpi-display b/src/filesystem/home/pi/scripts/calibrate-rpi-display deleted file mode 100755 index 5d66d741..00000000 --- a/src/filesystem/home/pi/scripts/calibrate-rpi-display +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -sudo TSLIB_FBDEVICE=/dev/fb1 TSLIB_TSDEVICE=/dev/input/event0 ts_calibrate - diff --git a/src/filesystem/home/pi/scripts/enable-adafruit-pitft b/src/filesystem/home/pi/scripts/enable-adafruit-pitft deleted file mode 100755 index 0a196854..00000000 --- a/src/filesystem/home/pi/scripts/enable-adafruit-pitft +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -echo "" -echo "Installing Adafruit PiTFT Display on this installation of OctoPi, do not turn off your Pi during this process!" -echo "" - -cd ~ -mkdir pitft -cd pitft - -wget http://adafru.it/pitftsh -mv pitftsh pitft.sh -chmod +x pitft.sh - -sudo ./pitft.sh -t 28r -r - -cd ~ -sudo rm pitft -R - -echo "" -echo "Reboot you Pi to use the Adafruit Pi TFT Display" -echo "" diff --git a/src/filesystem/home/pi/scripts/enable-rpi-display b/src/filesystem/home/pi/scripts/enable-rpi-display deleted file mode 100755 index 8cf87bcd..00000000 --- a/src/filesystem/home/pi/scripts/enable-rpi-display +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -echo "Enabling RPi-Display on this installation of OctoPi, do not turn off your Pi during this process!" -sudo sed -i 's/^blacklist spi-bcm2708/#blacklist spi-bcm2708/g' /etc/modprobe.d/raspi-blacklist.conf -sudo REPO_URI=https://github.com/notro/rpi-firmware BRANCH=builtin rpi-update - -if [ ! -f /boot/cmdline.txt.bak ]; then - sudo cp /boot/cmdline.txt /boot/cmdline.txt.bak -fi -sudo cp /boot/cmdline-pi-tft.txt /boot/cmdline.txt - -if ! `grep --quiet ads7846_device /etc/modules`; then - echo "ads7846_device model=7846 cs=1 gpio_pendown=25 speed=2000000 keep_vref_on=1 swap_xy=1 pressure_max=255 x_plate_ohms=60 x_min=200 x_max=3900 y_min=200 y_max=3900" | sudo tee --append /etc/modules > /dev/null; -fi diff --git a/src/nightly_build_scripts/build_local_mirrors b/src/nightly_build_scripts/build_local_mirrors index d75cf2c7..1ed1fbab 100755 --- a/src/nightly_build_scripts/build_local_mirrors +++ b/src/nightly_build_scripts/build_local_mirrors @@ -1,7 +1,5 @@ pushd /var/www/git git clone --mirror https://github.com/foosel/OctoPrint -git clone --mirror https://github.com/jonaslorander/OctoPiPanel.git git clone --mirror https://github.com/jacksonliam/mjpg-streamer.git -git clone --mirror https://github.com/tasanakorn/rpi-fbcp git clone --mirror git://git.drogon.net/wiringPi popd diff --git a/src/nightly_build_scripts/octopi_nightly_build b/src/nightly_build_scripts/octopi_nightly_build index 248f2b2f..6116bdc2 100755 --- a/src/nightly_build_scripts/octopi_nightly_build +++ b/src/nightly_build_scripts/octopi_nightly_build @@ -16,8 +16,6 @@ pushd ${OCTOPIPATH} umount ${OCTOPIPATH}/src/workspace/mount git pull origin devel #export OCTOPI_OCTOPRINT_REPO_BUILD='http://localhost/git/OctoPrint.git/' - #export OCTOPI_OCTOPIPANEL_REPO_BUILD='http://localhost/git/OctoPiPanel.git/' - #export OCTOPI_FBCP_REPO_BUILD='http://localhost/git/rpi-fbcp.git/' #export OCTOPI_MJPGSTREAMER_REPO_BUILD='http://localhost/git/mjpg-streamer.git/' #export OCTOPI_WIRINGPI_REPO_BUILD='http://localhost/git/wiringPi.git/' diff --git a/src/variants/armbian/config b/src/variants/armbian/config index 08340ea8..dd47f166 100755 --- a/src/variants/armbian/config +++ b/src/variants/armbian/config @@ -1,7 +1,6 @@ VARIANT_CONFIG_DIR=$(realpath -s $(dirname $(realpath -s $BASH_SOURCE))/../..) OCTOPI_ZIP_IMG=`ls -t $VARIANT_CONFIG_DIR/image-variants/Armbian*.zip | head -n 1` #OCTOPI_APT_CACHE="" -OCTOPI_INCLUDE_OCTOPIPANEL=no OCTOPI_INCLUDE_WIRINGPI=no # The root partiton of the image filesystem, 2 for raspbian, 1 for armbian OCTOPI_ROOT_PARTITION=1 From da0ecda75ae00db89af46862fe5e2201d6cae04f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Wed, 5 Apr 2017 10:23:26 +0000 Subject: [PATCH 161/352] Service file to fix symlink for wpa_supplicant.conf Included script will make sure that if wpa_supplicant.conf is no longer a symlink but it and /boot/octopi-wpa-supplicant.txt exist, the selected wifi country will be extracted and written to /boot/octopi-wpa-supplicant.txt and then the symlink will be recreated. If wpa_supplicant.conf is completely gone, only the symlink will be recreated. Nothing will be done if /boot/octopi-wpa-supplicant.txt does not exist. The service file ensures that this check is done on every boot, after the local file system becomes available but before the networking gets initialized. This should solve #336 Note that this requires systemd (Debian Jessie) - since current Raspbian starts SysV init scripts only after networking has started to initialized, it was impossible for me to create a SysV init script that fixes the symlink prior to network initialization. --- src/chroot_script | 2 + src/filesystem/home/root/bin/check_wpa_link | 46 +++++++++++++++++++ .../etc/systemd/system/check_wpa_link.service | 17 +++++++ 3 files changed, 65 insertions(+) create mode 100755 src/filesystem/home/root/bin/check_wpa_link create mode 100644 src/filesystem/root/etc/systemd/system/check_wpa_link.service diff --git a/src/chroot_script b/src/chroot_script index 5b70050f..4bc4ed56 100755 --- a/src/chroot_script +++ b/src/chroot_script @@ -232,6 +232,8 @@ systemctl_if_exists disable lightdm.service update-rc.d change_password defaults update-rc.d change_hostname defaults +systemctl_if_exists enable check_wpa_link.service + ### Fix SSH echo "IPQoS 0x00" >> /etc/ssh/sshd_config diff --git a/src/filesystem/home/root/bin/check_wpa_link b/src/filesystem/home/root/bin/check_wpa_link new file mode 100755 index 00000000..f324a20e --- /dev/null +++ b/src/filesystem/home/root/bin/check_wpa_link @@ -0,0 +1,46 @@ +#!/bin/sh + +link_source="/etc/wpa_supplicant/wpa_supplicant.conf" +link_target="/boot/octopi-wpa-supplicant.txt" + +if ! [ -L $link_source ] && [ -f $link_target ] +then + # wpa_supplicant.conf is not a link, link target exists + echo "Symlink from $link_source to $link_target has been broken, attempting restore" + + if [ -f $link_source ] + then + # wpa_supplicant.conf exists but symlink has been removed. This can happen when + # the wifi country setting is changed through raspi-config (for versions of that + # older than early april 2017). See also guysoft/OctoPi#336 + # + # We'll now attempt to parse the current wifi country from wpa_supplicant.conf, + # apply it to our link target, remove the wpa_supplicant and then recreate the + # symlink. + + if grep -q "^country=" $link_source ; then + echo "Wifi country setting detected in $link_source, will copy" + + # parse country setting from wpa_supplicant.conf - this is adapted from raspi-config + country=`grep country= $link_source | cut -d "=" -f 2` + + # apply it to link target - this is adapted from raspi-config + if grep -q "^country=" $link_target ; then + sed -i --follow-symlinks "s/^country=.*/country=$country/g" $link_target + else + sed -i --follow-symlinks "1i country=$country" $link_target + fi + + echo "Copied wifi country setting $country to $link_target" + fi + + # remove wpa_supplicant.conf and recreate symlink + rm $link_source + ln -s $link_target $link_source + echo "Restored link from $link_source to $link_target" + else + # wpa_supplicant.conf is missing completely, recreate symlink + ln -s $link_target $link_source + echo "Restored link from $link_source to $link_target" + fi +fi diff --git a/src/filesystem/root/etc/systemd/system/check_wpa_link.service b/src/filesystem/root/etc/systemd/system/check_wpa_link.service new file mode 100644 index 00000000..b4a1adf3 --- /dev/null +++ b/src/filesystem/root/etc/systemd/system/check_wpa_link.service @@ -0,0 +1,17 @@ +[Unit] +Description=Check that wpa-supplicant.conf is a symlink + +DefaultDependencies=no + +Before=network-pre.target +Wants=network-pre.target + +After=local-fs.target +Wants=local-fs.target + +[Service] +Type=oneshot +ExecStart=/root/bin/check_wpa_link + +[Install] +WantedBy=multi-user.target From ef576525eb5bc150c288fa9da1aa01cd207757a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 23 May 2017 10:00:34 +0000 Subject: [PATCH 162/352] Custom webroot & disabled controls for webcam server Instead of ./www we now use ./www-octopi by default which only contains an index.html (generated during image build) that displays only the snapshot and stream for debugging purposes. The command action on mjpg-streamer (which control.html of the stock webroot utilizes) has also been disabled via "-n". Two new variables have been introduced in /boot/octopi.txt to allow configuring the webroot to use and the additional options for output_http.so (by default only "-n"), in case power users need to change back or otherwise customize stock behaviour. Closes #358 --- src/chroot_script | 17 +++++++++++++++++ src/filesystem/boot/octopi.txt | 17 ++++++++++++++++- src/filesystem/home/root/bin/webcamd | 7 +++++-- 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/src/chroot_script b/src/chroot_script index 4bc4ed56..2b301c04 100755 --- a/src/chroot_script +++ b/src/chroot_script @@ -93,6 +93,23 @@ pushd /home/pi pushd mjpg-streamer mv mjpg-streamer-experimental/* . sudo -u pi make + + # create our custom web folder and add a minimal index.html to it + sudo -u pi mkdir www-octopi + pushd www-octopi + cat <> index.html + +mjpg_streamer test page + +

Snapshot

+

Refresh the page to refresh the snapshot

+Snapshot +

Stream

+Stream + + +EOT + popd popd fi diff --git a/src/filesystem/boot/octopi.txt b/src/filesystem/boot/octopi.txt index 56b1c0fb..149ed2ad 100644 --- a/src/filesystem/boot/octopi.txt +++ b/src/filesystem/boot/octopi.txt @@ -38,9 +38,10 @@ # # If this fixes your problem, please report it back so we can include the device # out of the box. +# #additional_brokenfps_usb_devices=("046d:082b" "aabb:ccdd") -### additional options to supply to MJPG Streamer for the RasPi Cam +### Additional options to supply to MJPG Streamer for the RasPi Cam # # See https://github.com/foosel/OctoPrint/wiki/MJPG-Streamer-configuration # for available options @@ -48,3 +49,17 @@ # Defaults to 10fps # #camera_raspi_options="-fps 10" + +### Configuration of camera HTTP output +# +# Usually you should NOT need to change this at all! Only touch if you +# know what you are doing and what the parameters mean. +# +# Below settings are used in the mjpg-streamer call like this: +# +# -o "output_http.so -w $camera_http_webroot $camera_http_options" +# +# Current working directory is the mjpg-streamer base directory. +# +#camera_http_webroot="./www-octopi" +#camera_http_options="-n" diff --git a/src/filesystem/home/root/bin/webcamd b/src/filesystem/home/root/bin/webcamd index df13af7d..ca23d919 100755 --- a/src/filesystem/home/root/bin/webcamd +++ b/src/filesystem/home/root/bin/webcamd @@ -19,6 +19,8 @@ MJPGSTREAMER_INPUT_RASPICAM="input_raspicam.so" camera="auto" camera_usb_options="-r 640x480 -f 10" camera_raspi_options="-fps 10" +camera_http_webroot="./www-octopi" +camera_http_options="-n" additional_brokenfps_usb_devices=() if [ -e "/boot/octopi.txt" ]; then @@ -47,8 +49,8 @@ function goodbye() { function runMjpgStreamer { input=$1 pushd $MJPGSTREAMER_HOME > /dev/null 2>&1 - echo Running ./mjpg_streamer -o "output_http.so -w ./www" -i "$input" - LD_LIBRARY_PATH=. ./mjpg_streamer -o "output_http.so -w ./www" -i "$input" & + echo Running ./mjpg_streamer -o "output_http.so -w $camera_http_webroot $camera_http_options" -i "$input" + LD_LIBRARY_PATH=. ./mjpg_streamer -o "output_http.so -w $camera_http_webroot $camera_http_options" -i "$input" & wait popd > /dev/null 2>&1 } @@ -108,6 +110,7 @@ echo "--- Configuration: ----------------------------" echo "camera: $camera" echo "usb options: $camera_usb_options" echo "raspi options: $camera_raspi_options" +echo "http options: -w $camera_http_webroot $camera_http_options" echo "-----------------------------------------------" echo "" From 0a778f8fce3d185dbad419f6c3670a88f024bb25 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Wed, 21 Jun 2017 01:24:32 +0300 Subject: [PATCH 163/352] Use CustomPiOS to build OctoPi --- README.rst | 12 +- src/build | 57 --- src/build_dist | 7 + src/common.sh | 375 ------------------ src/config | 127 +----- src/jenkins-ci/console_parsing | 9 - src/modules/octopi/config | 64 +++ .../filesystem/boot/octopi-network.txt | 0 .../octopi}/filesystem/boot/octopi.txt | 0 src/{ => modules/octopi}/filesystem/boot/ssh | 0 .../filesystem/home/pi/.octoprint/config.yaml | 0 .../home/pi/scripts/install-desktop | 0 .../filesystem/home/pi/scripts/welcome | 0 .../filesystem/home/root/bin/check_wpa_link | 0 .../octopi}/filesystem/home/root/bin/git | 0 .../filesystem/home/root/bin/map_iface | 0 .../octopi}/filesystem/home/root/bin/webcamd | 0 .../filesystem/root/etc/default/octoprint | 0 .../filesystem/root/etc/default/webcamd | 0 .../etc/haproxy/errors/503-no-octoprint.http | 0 .../etc/haproxy/errors/503-no-webcam.http | 0 .../filesystem/root/etc/haproxy/haproxy.cfg | 0 .../root/etc/init.d/change_hostname | 0 .../root/etc/init.d/change_password | 0 .../filesystem/root/etc/init.d/gencert | 0 .../filesystem/root/etc/init.d/octoprint | 0 .../filesystem/root/etc/init.d/webcamd | 0 .../root/etc/logrotate.d/map_iface.log | 0 .../filesystem/root/etc/logrotate.d/webcamd | 0 .../filesystem/root/etc/octopi_version | 0 .../etc/systemd/system/check_wpa_link.service | 0 .../root/etc/udev/rules.d/95-ads7846.rules | 0 .../octopi/start_chroot_script} | 49 +-- src/nightly_build_scripts/README.rst | 11 - src/nightly_build_scripts/build_local_mirrors | 5 - src/nightly_build_scripts/cleanup_storage.js | 108 ----- .../generate_nightly_page.js | 214 ---------- .../octopi_nightly_build | 27 -- src/nightly_build_scripts/template.html | 76 ---- src/nightly_build_scripts/update_git_mirrors | 12 - src/octopi | 107 ----- src/release | 13 - src/vagrant/Vagrantfile | 12 +- src/vagrant/run_vagrant_build.sh | 2 +- src/vagrant/setup.sh | 4 +- 45 files changed, 99 insertions(+), 1192 deletions(-) delete mode 100755 src/build create mode 100755 src/build_dist delete mode 100755 src/common.sh mode change 100755 => 100644 src/config delete mode 100644 src/jenkins-ci/console_parsing create mode 100755 src/modules/octopi/config rename src/{ => modules/octopi}/filesystem/boot/octopi-network.txt (100%) rename src/{ => modules/octopi}/filesystem/boot/octopi.txt (100%) rename src/{ => modules/octopi}/filesystem/boot/ssh (100%) rename src/{ => modules/octopi}/filesystem/home/pi/.octoprint/config.yaml (100%) rename src/{ => modules/octopi}/filesystem/home/pi/scripts/install-desktop (100%) rename src/{ => modules/octopi}/filesystem/home/pi/scripts/welcome (100%) rename src/{ => modules/octopi}/filesystem/home/root/bin/check_wpa_link (100%) rename src/{ => modules/octopi}/filesystem/home/root/bin/git (100%) rename src/{ => modules/octopi}/filesystem/home/root/bin/map_iface (100%) rename src/{ => modules/octopi}/filesystem/home/root/bin/webcamd (100%) rename src/{ => modules/octopi}/filesystem/root/etc/default/octoprint (100%) rename src/{ => modules/octopi}/filesystem/root/etc/default/webcamd (100%) rename src/{ => modules/octopi}/filesystem/root/etc/haproxy/errors/503-no-octoprint.http (100%) rename src/{ => modules/octopi}/filesystem/root/etc/haproxy/errors/503-no-webcam.http (100%) rename src/{ => modules/octopi}/filesystem/root/etc/haproxy/haproxy.cfg (100%) rename src/{ => modules/octopi}/filesystem/root/etc/init.d/change_hostname (100%) rename src/{ => modules/octopi}/filesystem/root/etc/init.d/change_password (100%) rename src/{ => modules/octopi}/filesystem/root/etc/init.d/gencert (100%) rename src/{ => modules/octopi}/filesystem/root/etc/init.d/octoprint (100%) rename src/{ => modules/octopi}/filesystem/root/etc/init.d/webcamd (100%) rename src/{ => modules/octopi}/filesystem/root/etc/logrotate.d/map_iface.log (100%) rename src/{ => modules/octopi}/filesystem/root/etc/logrotate.d/webcamd (100%) rename src/{ => modules/octopi}/filesystem/root/etc/octopi_version (100%) rename src/{ => modules/octopi}/filesystem/root/etc/systemd/system/check_wpa_link.service (100%) rename src/{ => modules/octopi}/filesystem/root/etc/udev/rules.d/95-ads7846.rules (100%) rename src/{chroot_script => modules/octopi/start_chroot_script} (86%) delete mode 100644 src/nightly_build_scripts/README.rst delete mode 100755 src/nightly_build_scripts/build_local_mirrors delete mode 100644 src/nightly_build_scripts/cleanup_storage.js delete mode 100644 src/nightly_build_scripts/generate_nightly_page.js delete mode 100755 src/nightly_build_scripts/octopi_nightly_build delete mode 100644 src/nightly_build_scripts/template.html delete mode 100755 src/nightly_build_scripts/update_git_mirrors delete mode 100755 src/octopi delete mode 100755 src/release diff --git a/README.rst b/README.rst index bf348ed4..fb986911 100644 --- a/README.rst +++ b/README.rst @@ -50,6 +50,7 @@ Requirements ~~~~~~~~~~~~ #. `qemu-arm-static `_ +#. `CustomPiOS `_ #. Downloaded `Raspbian `_ image. #. root privileges for chroot #. Bash @@ -66,10 +67,12 @@ You can build it by issuing the following commands:: sudo apt-get install gawk util-linux realpath qemu-user-static git + https://github.com/guysoft/CustomPiOS.git git clone https://github.com/guysoft/OctoPi.git cd OctoPi/src/image curl -J -O -L http://downloads.raspberrypi.org/raspbian_latest cd .. + ../CustomPiOS/src/update-custompios-paths sudo modprobe loop sudo bash -x ./build @@ -80,7 +83,7 @@ OctoPi supports building variants, which are builds with changes from the main r To build a variant use:: - sudo bash -x ./build [Variant] + sudo bash -x ./build_dist [Variant] Building Using Vagrant ~~~~~~~~~~~~~~~~~~~~~~ @@ -93,6 +96,7 @@ To use it:: sudo modprobe nfs cd OctoPi/src/vagrant sudo vagrant up + run_vagrant_build.sh After provisioning the machine, its also possible to run a nightly build which updates from devel using:: @@ -101,15 +105,15 @@ After provisioning the machine, its also possible to run a nightly build which u To build a variant on the machine simply run:: - cd FullPageOS/src/vagrant + cd src/vagrant run_vagrant_build.sh [Variant] Usage ~~~~~ -#. If needed, override existing config settings by creating a new file ``src/config.local``. You can override all settings found in ``src/config``. If you need to override the path to the Raspbian image to use for building OctoPi, override the path to be used in ``ZIP_IMG``. By default the most recent file matching ``*-raspbian.zip`` found in ``src/image`` will be used. -#. Run ``src/build`` as root. +#. If needed, override existing config settings by creating a new file ``src/config.local``. You can override all settings found in ``src/modules/octopi/config``. If you need to override the path to the Raspbian image to use for building OctoPi, override the path to be used in ``ZIP_IMG``. By default the most recent file matching ``*-raspbian.zip`` found in ``src/image`` will be used. +#. Run ``src/build_dist`` as root. #. The final image will be created at the ``src/workspace`` Code contribution would be appreciated! diff --git a/src/build b/src/build deleted file mode 100755 index 7616a116..00000000 --- a/src/build +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/env bash - -set -e - -[ -n "$LOG" ] || LOG="build.log" - -define(){ IFS='\n' read -r -d '' ${1} || true; } - -define SCRIPT <<'EOF' -BUILD_SCRIPT__PATH=$(dirname $(realpath -s $BASH_SOURCE)) -source ${BUILD_SCRIPT__PATH}/common.sh -install_cleanup_trap - -OCTOPI_PATH=$(dirname $(realpath -s $0)) -pushd $OCTOPI_PATH - export OCTOPI_COMMIT=`git rev-parse HEAD` -popd - -BUILD_VARIANT=default -BUILD_FLAVOR=default -WORKSPACE_POSTFIX= - -if [ "$#" -gt 0 ]; then - BUILD_VARIANT=$1 -fi -if [ "$#" -gt 1 ]; then - BUILD_FLAVOR=$2 -fi - -if [ $BUILD_VARIANT != 'default' ]; then - WORKSPACE_POSTFIX=-$BUILD_VARIANT - - export VARIANT_BASE="$OCTOPI_PATH/variants/$BUILD_VARIANT" - [ -d $VARIANT_BASE ] || die "Could not find Variant $BUILD_VARIANT" - - if [ $BUILD_FLAVOR == '' ] || [ $BUILD_FLAVOR == 'default' ] - then - VARIANT_CONFIG=$VARIANT_BASE/config - FLAVOR_CONFIG= - else - VARIANT_CONFIG=$VARIANT_BASE/config - FLAVOR_CONFIG=$VARIANT_BASE/config.$BUILD_FLAVOR - fi - - if [ -n "$FLAVOR_CONFIG" ] && [ ! -f $FLAVOR_CONFIG ] - then - die "Could not find config file $FLAVOR_CONFIG" - fi -fi - -echo -e "--> Building VARIANT $BUILD_VARIANT, FLAVOR $BUILD_FLAVOR" - -source $OCTOPI_PATH/config -[ "$CONFIG_ONLY" == "yes" ] || source $OCTOPI_PATH/octopi -EOF - -[ "$LOG" != "no" ] && (eval "$SCRIPT" 2>&1 | tee "$LOG") || eval "$SCRIPT" diff --git a/src/build_dist b/src/build_dist new file mode 100755 index 00000000..6df7a647 --- /dev/null +++ b/src/build_dist @@ -0,0 +1,7 @@ +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +export DIST_PATH=${DIR} +export CUSTOM_PI_OS_PATH=/path/to/CustomPiOS +export PATH=$PATH:$CUSTOM_PI_OS_PATH + +${CUSTOM_PI_OS_PATH}/build_custom_os ${DIST_PATH} diff --git a/src/common.sh b/src/common.sh deleted file mode 100755 index f908ba75..00000000 --- a/src/common.sh +++ /dev/null @@ -1,375 +0,0 @@ -#!/usr/bin/env bash - -function die () { - echo >&2 "$@" - exit 1 -} - -function fixLd(){ - sed -i 's@/usr/lib/arm-linux-gnueabihf/libcofi_rpi.so@\#/usr/lib/arm-linux-gnueabihf/libcofi_rpi.so@' etc/ld.so.preload - sed -i 's@/usr/lib/arm-linux-gnueabihf/libarmmem.so@\#/usr/lib/arm-linux-gnueabihf/libarmmem.so@' etc/ld.so.preload -} - -function restoreLd(){ - sed -i 's@\#/usr/lib/arm-linux-gnueabihf/libcofi_rpi.so@/usr/lib/arm-linux-gnueabihf/libcofi_rpi.so@' etc/ld.so.preload - sed -i 's@\#/usr/lib/arm-linux-gnueabihf/libarmmem.so@/usr/lib/arm-linux-gnueabihf/libarmmem.so@' etc/ld.so.preload -} - -function pause() { - # little debug helper, will pause until enter is pressed and display provided - # message - read -p "$*" -} - -function gitclone(){ - # call like this: gitclone OCTOPI_OCTOPRINT_REPO someDirectory -- this will do: - # - # sudo -u pi git clone -b $OCTOPI_OCTOPRINT_REPO_BRANCH --depth $OCTOPI_OCTOPRINT_REPO_DEPTH $OCTOPI_OCTOPRINT_REPO_BUILD someDirectory - # - # and if $OCTOPI_OCTOPRINT_REPO_BUILD != $OCTOPI_OCTOPRINT_REPO_SHIP also: - # - # pushd someDirectory - # sudo -u pi git remote set-url origin $OCTOPI_OCTOPRINT_REPO_SHIP - # popd - # - # if second parameter is not provided last URL segment of the BUILD repo URL - # minus the optional .git postfix will be used - - repo_build_var=$1_BUILD - repo_ship_var=$1_SHIP - repo_branch_var=$1_BRANCH - repo_depth_var=$1_DEPTH - - repo_dir=$2 - if [ ! -n "$repo_dir" ] - then - repo_dir=$(echo ${REPO} | sed 's%^.*/\([^/]*\)\(\.git\)?$%\1%g') - fi - - repo_depth=${!repo_depth_var} - if [ -n "$repo_depth" ] - then - depth=$repo_depth - else - if [ "$#" -gt 2 ] - then - depth=$3 - fi - fi - - build_repo=${!repo_build_var} - ship_repo=${!repo_ship_var} - branch=${!repo_branch_var} - - if [ ! -n "$build_repo" ] - then - build_repo=$ship_repo - fi - - clone_params= - if [ -n "$branch" ] - then - clone_params="-b $branch" - fi - - if [ -n "$depth" ] - then - clone_params="$clone_params --depth $depth" - fi - - sudo -u pi git clone $clone_params "$build_repo" "$repo_dir" - - if [ "$build_repo" != "$ship_repo" ] - then - pushd "$repo_dir" - sudo -u pi git remote set-url origin "$ship_repo" - popd - fi -} - -function unpack() { - # call like this: unpack /path/to/source /target user -- this will copy - # all files & folders from source to target, preserving mode and timestamps - # and chown to user. If user is not provided, no chown will be performed - - from=$1 - to=$2 - owner= - if [ "$#" -gt 2 ] - then - owner=$3 - fi - - # $from/. may look funny, but does exactly what we want, copy _contents_ - # from $from to $to, but not $from itself, without the need to glob -- see - # http://stackoverflow.com/a/4645159/2028598 - cp -v -r --preserve=mode,timestamps $from/. $to - if [ -n "$owner" ] - then - chown -hR $owner:$owner $to - fi -} - -function mount_image() { - image_path=$1 - root_partition=$2 - mount_path=$3 - echo "burr" - echo $2 - - # dump the partition table, locate boot partition and root partition - boot_partition=1 - fdisk_output=$(sfdisk -d $image_path) - boot_offset=$(($(echo "$fdisk_output" | grep "$image_path$boot_partition" | awk '{print $4-0}') * 512)) - root_offset=$(($(echo "$fdisk_output" | grep "$image_path$root_partition" | awk '{print $4-0}') * 512)) - - echo "Mounting image $image_path on $mount_path, offset for boot partition is $boot_offset, offset for root partition is $root_offset" - - # mount root and boot partition - sudo mount -o loop,offset=$root_offset $image_path $mount_path/ - if [[ "$boot_partition" != "$root_partition" ]]; then - sudo mount -o loop,offset=$boot_offset $image_path $mount_path/boot - fi - sudo mkdir -p $mount_path/dev/pts - sudo mount -o bind /dev $mount_path/dev - sudo mount -o bind /dev/pts $mount_path/dev/pts -} - -function unmount_image() { - mount_path=$1 - force= - if [ "$#" -gt 1 ] - then - force=$2 - fi - - if [ -n "$force" ] - then - for process in $(sudo lsof $mount_path | awk '{print $2}') - do - echo "Killing process id $process..." - sudo kill -9 $process - done - fi - - # Unmount everything that is mounted - # - # We might have "broken" mounts in the mix that point at a deleted image (in case of some odd - # build errors). So our "sudo mount" output can look like this: - # - # /path/to/our/image.img (deleted) on /path/to/our/mount type ext4 (rw) - # /path/to/our/image.img on /path/to/our/mount type ext4 (rw) - # /path/to/our/image.img on /path/to/our/mount/boot type vfat (rw) - # - # so we split on "on" first, then do a whitespace split to get the actual mounted directory. - # Also we sort in reverse to get the deepest mounts first. - for m in $(sudo mount | grep $mount_path | awk -F "on" '{print $2}' | awk '{print $1}' | sort -r) - do - echo "Unmounting $m..." - sudo umount $m - done -} - -function cleanup() { - # make sure that all child processed die when we die - local pids=$(jobs -pr) - [ -n "$pids" ] && kill $pids && sleep 5 && kill -9 $pids - exit 0 -} - -function cleanup() { - # make sure that all child processed die when we die - local pids=$(jobs -pr) - [ -n "$pids" ] && kill $pids - exit 0 -} - -function install_fail_on_error_trap() { - set -e - trap 'previous_command=$this_command; this_command=$BASH_COMMAND' DEBUG - trap 'if [ $? -ne 0 ]; then echo -e "\nexit $? due to $previous_command \nBUILD FAILED!" && echo "unmounting image..." && ( unmount_image $OCTOPI_MOUNT_PATH force || true ); fi;' EXIT -} - -function install_chroot_fail_on_error_trap() { - set -e - trap 'previous_command=$this_command; this_command=$BASH_COMMAND' DEBUG - trap 'if [ $? -ne 0 ]; then echo -e "\nexit $? due to $previous_command \nBUILD FAILED!"; fi;' EXIT -} - -function install_cleanup_trap() { - set -e - trap "cleanup" SIGINT SIGTERM - } - -function enlarge_ext() { - # call like this: enlarge_ext /path/to/image partition size - # - # will enlarge partition number on /path/to/image by MB - image=$1 - partition=$2 - size=$3 - - echo "Adding $size MB to partition $partition of $image" - start=$(sfdisk -d $image | grep "$image$partition" | awk '{print $4-0}') - offset=$(($start*512)) - dd if=/dev/zero bs=1M count=$size >> $image - fdisk $image < on /path/to/image to MB - image=$1 - partition=$2 - size=$3 - - echo "Resizing file system to $size MB..." - start=$(sfdisk -d $image | grep "$image$partition" | awk '{print $4-0}') - offset=$(($start*512)) - - LODEV=$(losetup -f --show -o $offset $image) - trap 'losetup -d $LODEV' EXIT - - e2fsck -fy $LODEV - - e2ftarget_bytes=$(($size * 1024 * 1024)) - e2ftarget_blocks=$(($e2ftarget_bytes / 512 + 1)) - - echo "Resizing file system to $e2ftarget_blocks blocks..." - resize2fs $LODEV ${e2ftarget_blocks}s - losetup -d $LODEV - trap - EXIT - - new_end=$(($start + $e2ftarget_blocks)) - - echo "Resizing partition to end at $start + $e2ftarget_blocks = $new_end blocks..." - fdisk $image </dev/null | grep -i "minimum size" | awk -F: '{print $2-0}') - - e2fminsize_bytes=$(($e2fminsize * $e2fblocksize)) - e2ftarget_bytes=$(($buffer * 1024 * 1024 + $e2fminsize_bytes)) - e2fsize_bytes=$((($e2fsize_blocks - 1) * 512)) - - e2fminsize_mb=$(($e2fminsize_bytes / 1024 / 1024)) - e2fminsize_blocks=$(($e2fminsize_bytes / 512 + 1)) - e2ftarget_mb=$(($e2ftarget_bytes / 1024 / 1024)) - e2ftarget_blocks=$(($e2ftarget_bytes / 512 + 1)) - e2fsize_mb=$(($e2fsize_bytes / 1024 / 1024)) - - size_offset_mb=$(($e2fsize_mb - $e2ftarget_mb)) - - losetup -d $LODEV - - echo "Actual size is $e2fsize_mb MB ($e2fsize_blocks blocks), Minimum size is $e2fminsize_mb MB ($e2fminsize file system blocks, $e2fminsize_blocks blocks)" - echo "Resizing to $e2ftarget_mb MB ($e2ftarget_blocks blocks)" - - if [ $size_offset_mb -gt 0 ]; then - echo "Partition size is bigger then the desired size, shrinking" - shrink_ext $image $partition $(($e2ftarget_mb - 1)) # -1 to compensat rounding mistakes - elif [ $size_offset_mb -lt 0 ]; then - echo "Partition size is lower then the desired size, enlarging" - enlarge_ext $image $partition $((-$size_offset_mb + 1)) # +1 to compensat rounding mistakes - fi -} - -function is_installed(){ - # checks if a package is installed, returns 1 if installed and 0 if not. - # usage: is_installed - dpkg-query -W -f='${Status}' $1 2>/dev/null | grep -c "ok installed" -} - -function is_in_apt(){ - #checks if a package is in the apt repo, returns 1 if exists and 0 if not - #usage is_in_apt - if [ $(apt-cache policy $1 | wc | awk '{print $1}') -gt 0 ]; then - echo 1 - else - echo 0 - fi -} - -function remove_if_installed(){ - remove_extra_list="" - for package in "$1" - do - if [ $( is_installed package ) -eq 1 ]; - then - remove_extra_list="$remove_extra_list $package" - fi - done - echo $remove_extra_list -} - -function systemctl_if_exists() { - if hash systemctl 2>/dev/null; then - systemctl "$@" - else - echo "no systemctl, not running" - fi -} diff --git a/src/config b/src/config old mode 100755 new mode 100644 index f984d6d1..a4cc49f8 --- a/src/config +++ b/src/config @@ -1,125 +1,4 @@ -CONFIG_DIR=$(dirname $(realpath -s $BASH_SOURCE)) +export DIST_NAME=OctoPi +export DIST_VERSION=0.14 +export MODULES="base(raspicam, octopi)" -# Import the variant config if we have one - -if [ -n "$VARIANT_CONFIG" ] && [ -f $VARIANT_CONFIG ] -then - echo "Sourcing variant config $VARIANT_CONFIG..." - source $VARIANT_CONFIG -fi - -# Import the flavor config if we have one - -if [ -n "$FLAVOR_CONFIG" ] && [ -f $FLAVOR_CONFIG ] -then - echo "Sourcing flavor config $FLAVOR_CONFIG..." - source $FLAVOR_CONFIG -fi - -# Import the local config if we have one - -if [ -f $CONFIG_DIR/config.local ] -then - echo "Sourcing config.local..." - source $CONFIG_DIR/config.local -fi - -############################################################################### -# All our config settings must start with OCTOPI_ - -[ -n "$OCTOPI_PRESCRIPT" ] || OCTOPI_PRESCRIPT= -[ -n "$OCTOPI_POSTSCRIPT" ] || OCTOPI_POSTSCRIPT= - -[ -n "$OCTOPI_SCRIPT_PATH" ] || OCTOPI_SCRIPT_PATH=$CONFIG_DIR -[ -n "$OCTOPI_IMAGE_PATH" ] || OCTOPI_IMAGE_PATH=$OCTOPI_SCRIPT_PATH/image -[ -n "$OCTOPI_IMAGE_RASPBIAN" ] || OCTOPI_IMAGE_RASPBIAN=yes - -[ -n "$OCTOPI_ZIP_IMG" ] || OCTOPI_ZIP_IMG=`ls -t $OCTOPI_IMAGE_PATH/*-raspbian*.zip | head -n 1` - -[ -n "$OCTOPI_WORKSPACE" ] || OCTOPI_WORKSPACE=$OCTOPI_SCRIPT_PATH/workspace$WORKSPACE_POSTFIX -[ -n "$OCTOPI_CHROOT_SCRIPT_PATH" ] || OCTOPI_CHROOT_SCRIPT_PATH=$OCTOPI_SCRIPT_PATH/chroot_script -[ -n "$OCTOPI_MOUNT_PATH" ] || OCTOPI_MOUNT_PATH=$OCTOPI_WORKSPACE/mount - -# The root partiton of the image filesystem, 2 for raspbian -[ -n "$OCTOPI_ROOT_PARTITION" ] || OCTOPI_ROOT_PARTITION=2 - -# if set will enlarge root parition prior to build by provided size in MB -[ -n "$OCTOPI_IMAGE_ENLARGEROOT" ] || OCTOPI_IMAGE_ENLARGEROOT=400 - -# if set will resize root partition on image after build to minimum size + -# provided size in MB -[ -n "$OCTOPI_IMAGE_RESIZEROOT" ] || OCTOPI_IMAGE_RESIZEROOT=200 - -# a local directory on the build server to bind mount under /var/cache/apt -[ -n "$OCTOPI_APT_CACHE" ] || OCTOPI_APT_CACHE=$OCTOPI_WORKSPACE/aptcache - -# a host:port combo for a apt-proxy (such as apt-cacher-ng) to use -[ -n "$OCTOPI_APT_PROXY" ] || OCTOPI_APT_PROXY= - -# an alternative pypi index url to use, e.g. a proxy such as devpi -[ -n "$OCTOPI_PYPI_INDEX" ] || OCTOPI_PYPI_INDEX= - -[ -n "$OCTOPI_OVERRIDE_HOSTNAME" ] || OCTOPI_OVERRIDE_HOSTNAME=octopi - -# a git mirror to use for git clones instead of original remotes -[ -n "$OCTOPI_BUILD_REPO_MIRROR" ] || OCTOPI_BUILD_REPO_MIRROR= - -# OctoPrint repo & branch -[ -n "$OCTOPI_OCTOPRINT_REPO_SHIP" ] || OCTOPI_OCTOPRINT_REPO_SHIP=https://github.com/foosel/OctoPrint.git -[ -n "$OCTOPI_OCTOPRINT_REPO_BUILD" ] || OCTOPI_OCTOPRINT_REPO_BUILD= -[ -n "$OCTOPI_OCTOPRINT_REPO_BRANCH" ] || OCTOPI_OCTOPRINT_REPO_BRANCH=master -[ -n "$OCTOPI_INCLUDE_OCTOPRINT" ] || OCTOPI_INCLUDE_OCTOPRINT=yes - -# CuraEngine archive & version -[ -n "$OCTOPI_CURAENGINE_VERSION" ] || OCTOPI_CURAENGINE_VERSION=15.04.6 -[ -n "$OCTOPI_CURAENGINE_ARCHIVE" ] || OCTOPI_CURAENGINE_ARCHIVE=https://github.com/Ultimaker/CuraEngine/archive/$OCTOPI_CURAENGINE_VERSION.zip -[ -n "$OCTOPI_INCLUDE_CURAENGINE" ] || OCTOPI_INCLUDE_CURAENGINE=yes - -# mjpg streamer -[ -n "$OCTOPI_MJPGSTREAMER_REPO_SHIP" ] || OCTOPI_MJPGSTREAMER_REPO_SHIP=https://github.com/jacksonliam/mjpg-streamer.git -[ -n "$OCTOPI_MJPGSTREAMER_REPO_BUILD" ] || OCTOPI_MJPGSTREAMER_REPO_BUILD= -[ -n "$OCTOPI_MJPGSTREAMER_REPO_BRANCH" ] || OCTOPI_MJPGSTREAMER_REPO_BRANCH=master -[ -n "$OCTOPI_MJPGSTREAMER_REPO_DEPTH" ] || OCTOPI_MJPGSTREAMER_REPO_DEPTH=1 -[ -n "$OCTOPI_INCLUDE_MJPGSTREAMER" ] || OCTOPI_INCLUDE_MJPGSTREAMER=yes - -# HAProxy -[ -n "$OCTOPI_INCLUDE_HAPROXY" ] || OCTOPI_INCLUDE_HAPROXY=yes - -# WiringPi -[ -n "$OCTOPI_INCLUDE_WIRINGPI" ] || OCTOPI_INCLUDE_WIRINGPI=yes - -############################################################################### -# Rewrite any build urls that are not yet set if we have a repository mirror -# configured. - -if [ -n "$OCTOPI_BUILD_REPO_MIRROR" ] -then - vars=`compgen -A variable | grep '^OCTOPI_' | grep 'REPO_BUILD'` - for var in $vars - do - if [ ! -n "${!var}" ] - then - repo_ship_var=${var%_BUILD}_SHIP - original=${!repo_ship_var} - rewritten=$OCTOPI_BUILD_REPO_MIRROR`echo $original | awk -F '/' '{print $(NF)}'` - - echo "Rewriting build repo for $var from $original to $rewritten" - eval $var=$rewritten - fi - done -fi - -############################################################################### -# Print and export the final configuration. - -echo "================================================================" -echo "Using the following config:" - -vars=`compgen -A variable | grep '^OCTOPI_'` -for var in $vars -do - echo "$var = ${!var}" - eval export $var -done - -echo "================================================================" diff --git a/src/jenkins-ci/console_parsing b/src/jenkins-ci/console_parsing deleted file mode 100644 index f3a971d8..00000000 --- a/src/jenkins-ci/console_parsing +++ /dev/null @@ -1,9 +0,0 @@ -error /BUILD FAILED/ -error /mv: cannot stat/ -error /md5sum: * No such file or directory/ -error /Error is not recoverable: exiting now/ -error /Network is unreachable/ -error /error: timed out/ -error /404 Not Found/ -error /Failed to fetch/ -error /Traceback/ diff --git a/src/modules/octopi/config b/src/modules/octopi/config new file mode 100755 index 00000000..d0214211 --- /dev/null +++ b/src/modules/octopi/config @@ -0,0 +1,64 @@ +############################################################################### +# All our config settings must start with OCTOPI_ + +[ -n "$BASE_PRESCRIPT" ] || BASE_PRESCRIPT= +[ -n "$BASE_POSTSCRIPT" ] || BASE_POSTSCRIPT= + +[ -n "$BASE_SCRIPT_PATH" ] || BASE_SCRIPT_PATH=$CONFIG_DIR +[ -n "$BASE_IMAGE_PATH" ] || BASE_IMAGE_PATH=$BASE_SCRIPT_PATH/image +[ -n "$BASE_IMAGE_RASPBIAN" ] || BASE_IMAGE_RASPBIAN=yes + +[ -n "$BASE_IMAGE_ZIP_IMG" ] || BASE_IMAGE_ZIP_IMG=`ls -t $BASE_IMAGE_PATH/*-raspbian*.zip | head -n 1` + +[ -n "$BASE_WORKSPACE" ] || BASE_WORKSPACE=$BASE_SCRIPT_PATH/workspace$WORKSPACE_POSTFIX +[ -n "$BASE_CHROOT_SCRIPT_PATH" ] || BASE_CHROOT_SCRIPT_PATH=$BASE_SCRIPT_PATH/chroot_script +[ -n "$BASE_ROOT_PARTITION" ] || BASE_ROOT_PARTITION=$BASE_WORKSPACE/mount + +# The root partiton of the image filesystem, 2 for raspbian +[ -n "$BASE_ROOT_PARTITION" ] || BASE_ROOT_PARTITION=2 + +# if set will enlarge root parition prior to build by provided size in MB +[ -n "$BASE_IMAGE_ENLARGEROOT" ] || BASE_IMAGE_ENLARGEROOT=400 + +# if set will resize root partition on image after build to minimum size + +# provided size in MB +[ -n "$BASE_IMAGE_RESIZEROOT" ] || BASE_IMAGE_RESIZEROOT=200 + +# a local directory on the build server to bind mount under /var/cache/apt +[ -n "$BASE_APT_CACHE" ] || BASE_APT_CACHE=$BASE_WORKSPACE/aptcache + +# a host:port combo for a apt-proxy (such as apt-cacher-ng) to use +[ -n "$BASE_APT_PROXY" ] || BASE_APT_PROXY= + +# an alternative pypi index url to use, e.g. a proxy such as devpi +[ -n "$BASE_PYPI_INDEX" ] || BASE_PYPI_INDEX= + +[ -n "$BASE_OVERRIDE_HOSTNAME" ] || BASE_OVERRIDE_HOSTNAME=octopi + +# a git mirror to use for git clones instead of original remotes +[ -n "$BASE_BUILD_REPO_MIRROR" ] || BASE_BUILD_REPO_MIRROR= + +# OctoPrint repo & branch +[ -n "$OCTOPI_OCTOPRINT_REPO_SHIP" ] || OCTOPI_OCTOPRINT_REPO_SHIP=https://github.com/foosel/OctoPrint.git +[ -n "$OCTOPI_OCTOPRINT_REPO_BUILD" ] || OCTOPI_OCTOPRINT_REPO_BUILD= +[ -n "$OCTOPI_OCTOPRINT_REPO_BRANCH" ] || OCTOPI_OCTOPRINT_REPO_BRANCH=master +[ -n "$OCTOPI_INCLUDE_OCTOPRINT" ] || OCTOPI_INCLUDE_OCTOPRINT=yes + +# CuraEngine archive & version +[ -n "$OCTOPI_CURAENGINE_VERSION" ] || OCTOPI_CURAENGINE_VERSION=15.04.6 +[ -n "$OCTOPI_CURAENGINE_ARCHIVE" ] || OCTOPI_CURAENGINE_ARCHIVE=https://github.com/Ultimaker/CuraEngine/archive/$OCTOPI_CURAENGINE_VERSION.zip +[ -n "$OCTOPI_INCLUDE_CURAENGINE" ] || OCTOPI_INCLUDE_CURAENGINE=yes + +# mjpg streamer +[ -n "$OCTOPI_MJPGSTREAMER_REPO_SHIP" ] || OCTOPI_MJPGSTREAMER_REPO_SHIP=https://github.com/jacksonliam/mjpg-streamer.git +[ -n "$OCTOPI_MJPGSTREAMER_REPO_BUILD" ] || OCTOPI_MJPGSTREAMER_REPO_BUILD= +[ -n "$OCTOPI_MJPGSTREAMER_REPO_BRANCH" ] || OCTOPI_MJPGSTREAMER_REPO_BRANCH=master +[ -n "$OCTOPI_MJPGSTREAMER_REPO_DEPTH" ] || OCTOPI_MJPGSTREAMER_REPO_DEPTH=1 +[ -n "$OCTOPI_INCLUDE_MJPGSTREAMER" ] || OCTOPI_INCLUDE_MJPGSTREAMER=yes + +# HAProxy +[ -n "$OCTOPI_INCLUDE_HAPROXY" ] || OCTOPI_INCLUDE_HAPROXY=yes + +# WiringPi +[ -n "$OCTOPI_INCLUDE_WIRINGPI" ] || OCTOPI_INCLUDE_WIRINGPI=yes + diff --git a/src/filesystem/boot/octopi-network.txt b/src/modules/octopi/filesystem/boot/octopi-network.txt similarity index 100% rename from src/filesystem/boot/octopi-network.txt rename to src/modules/octopi/filesystem/boot/octopi-network.txt diff --git a/src/filesystem/boot/octopi.txt b/src/modules/octopi/filesystem/boot/octopi.txt similarity index 100% rename from src/filesystem/boot/octopi.txt rename to src/modules/octopi/filesystem/boot/octopi.txt diff --git a/src/filesystem/boot/ssh b/src/modules/octopi/filesystem/boot/ssh similarity index 100% rename from src/filesystem/boot/ssh rename to src/modules/octopi/filesystem/boot/ssh diff --git a/src/filesystem/home/pi/.octoprint/config.yaml b/src/modules/octopi/filesystem/home/pi/.octoprint/config.yaml similarity index 100% rename from src/filesystem/home/pi/.octoprint/config.yaml rename to src/modules/octopi/filesystem/home/pi/.octoprint/config.yaml diff --git a/src/filesystem/home/pi/scripts/install-desktop b/src/modules/octopi/filesystem/home/pi/scripts/install-desktop similarity index 100% rename from src/filesystem/home/pi/scripts/install-desktop rename to src/modules/octopi/filesystem/home/pi/scripts/install-desktop diff --git a/src/filesystem/home/pi/scripts/welcome b/src/modules/octopi/filesystem/home/pi/scripts/welcome similarity index 100% rename from src/filesystem/home/pi/scripts/welcome rename to src/modules/octopi/filesystem/home/pi/scripts/welcome diff --git a/src/filesystem/home/root/bin/check_wpa_link b/src/modules/octopi/filesystem/home/root/bin/check_wpa_link similarity index 100% rename from src/filesystem/home/root/bin/check_wpa_link rename to src/modules/octopi/filesystem/home/root/bin/check_wpa_link diff --git a/src/filesystem/home/root/bin/git b/src/modules/octopi/filesystem/home/root/bin/git similarity index 100% rename from src/filesystem/home/root/bin/git rename to src/modules/octopi/filesystem/home/root/bin/git diff --git a/src/filesystem/home/root/bin/map_iface b/src/modules/octopi/filesystem/home/root/bin/map_iface similarity index 100% rename from src/filesystem/home/root/bin/map_iface rename to src/modules/octopi/filesystem/home/root/bin/map_iface diff --git a/src/filesystem/home/root/bin/webcamd b/src/modules/octopi/filesystem/home/root/bin/webcamd similarity index 100% rename from src/filesystem/home/root/bin/webcamd rename to src/modules/octopi/filesystem/home/root/bin/webcamd diff --git a/src/filesystem/root/etc/default/octoprint b/src/modules/octopi/filesystem/root/etc/default/octoprint similarity index 100% rename from src/filesystem/root/etc/default/octoprint rename to src/modules/octopi/filesystem/root/etc/default/octoprint diff --git a/src/filesystem/root/etc/default/webcamd b/src/modules/octopi/filesystem/root/etc/default/webcamd similarity index 100% rename from src/filesystem/root/etc/default/webcamd rename to src/modules/octopi/filesystem/root/etc/default/webcamd diff --git a/src/filesystem/root/etc/haproxy/errors/503-no-octoprint.http b/src/modules/octopi/filesystem/root/etc/haproxy/errors/503-no-octoprint.http similarity index 100% rename from src/filesystem/root/etc/haproxy/errors/503-no-octoprint.http rename to src/modules/octopi/filesystem/root/etc/haproxy/errors/503-no-octoprint.http diff --git a/src/filesystem/root/etc/haproxy/errors/503-no-webcam.http b/src/modules/octopi/filesystem/root/etc/haproxy/errors/503-no-webcam.http similarity index 100% rename from src/filesystem/root/etc/haproxy/errors/503-no-webcam.http rename to src/modules/octopi/filesystem/root/etc/haproxy/errors/503-no-webcam.http diff --git a/src/filesystem/root/etc/haproxy/haproxy.cfg b/src/modules/octopi/filesystem/root/etc/haproxy/haproxy.cfg similarity index 100% rename from src/filesystem/root/etc/haproxy/haproxy.cfg rename to src/modules/octopi/filesystem/root/etc/haproxy/haproxy.cfg diff --git a/src/filesystem/root/etc/init.d/change_hostname b/src/modules/octopi/filesystem/root/etc/init.d/change_hostname similarity index 100% rename from src/filesystem/root/etc/init.d/change_hostname rename to src/modules/octopi/filesystem/root/etc/init.d/change_hostname diff --git a/src/filesystem/root/etc/init.d/change_password b/src/modules/octopi/filesystem/root/etc/init.d/change_password similarity index 100% rename from src/filesystem/root/etc/init.d/change_password rename to src/modules/octopi/filesystem/root/etc/init.d/change_password diff --git a/src/filesystem/root/etc/init.d/gencert b/src/modules/octopi/filesystem/root/etc/init.d/gencert similarity index 100% rename from src/filesystem/root/etc/init.d/gencert rename to src/modules/octopi/filesystem/root/etc/init.d/gencert diff --git a/src/filesystem/root/etc/init.d/octoprint b/src/modules/octopi/filesystem/root/etc/init.d/octoprint similarity index 100% rename from src/filesystem/root/etc/init.d/octoprint rename to src/modules/octopi/filesystem/root/etc/init.d/octoprint diff --git a/src/filesystem/root/etc/init.d/webcamd b/src/modules/octopi/filesystem/root/etc/init.d/webcamd similarity index 100% rename from src/filesystem/root/etc/init.d/webcamd rename to src/modules/octopi/filesystem/root/etc/init.d/webcamd diff --git a/src/filesystem/root/etc/logrotate.d/map_iface.log b/src/modules/octopi/filesystem/root/etc/logrotate.d/map_iface.log similarity index 100% rename from src/filesystem/root/etc/logrotate.d/map_iface.log rename to src/modules/octopi/filesystem/root/etc/logrotate.d/map_iface.log diff --git a/src/filesystem/root/etc/logrotate.d/webcamd b/src/modules/octopi/filesystem/root/etc/logrotate.d/webcamd similarity index 100% rename from src/filesystem/root/etc/logrotate.d/webcamd rename to src/modules/octopi/filesystem/root/etc/logrotate.d/webcamd diff --git a/src/filesystem/root/etc/octopi_version b/src/modules/octopi/filesystem/root/etc/octopi_version similarity index 100% rename from src/filesystem/root/etc/octopi_version rename to src/modules/octopi/filesystem/root/etc/octopi_version diff --git a/src/filesystem/root/etc/systemd/system/check_wpa_link.service b/src/modules/octopi/filesystem/root/etc/systemd/system/check_wpa_link.service similarity index 100% rename from src/filesystem/root/etc/systemd/system/check_wpa_link.service rename to src/modules/octopi/filesystem/root/etc/systemd/system/check_wpa_link.service diff --git a/src/filesystem/root/etc/udev/rules.d/95-ads7846.rules b/src/modules/octopi/filesystem/root/etc/udev/rules.d/95-ads7846.rules similarity index 100% rename from src/filesystem/root/etc/udev/rules.d/95-ads7846.rules rename to src/modules/octopi/filesystem/root/etc/udev/rules.d/95-ads7846.rules diff --git a/src/chroot_script b/src/modules/octopi/start_chroot_script similarity index 86% rename from src/chroot_script rename to src/modules/octopi/start_chroot_script index 2b301c04..4d7772a0 100755 --- a/src/chroot_script +++ b/src/modules/octopi/start_chroot_script @@ -11,29 +11,7 @@ export LC_ALL=C source /common.sh install_cleanup_trap -if [ -n "$OCTOPI_APT_PROXY" ] -then - echo "Acquire::http { Proxy \"http://$OCTOPI_APT_PROXY\"; };" > /etc/apt/apt.conf.d/02octopi_build_proxy -fi - -if [ -n "$OCTOPI_PYPI_INDEX" ] -then - pip_index_config="[global]\nindex-url = $OCTOPI_PYPI_INDEX" - easyinstall_index_config="[easy_install]\nindex-url = $OCTOPI_PYPI_INDEX" - - mkdir -p /root/.pip - echo -e "$pip_index_config" > /root/.pip/pip.conf - echo -e "$easyinstall_index_config" > /root/.pydistutils.cfg - - mkdir -p /home/pi/.pip - sudo -u pi echo -e "$pip_index_config" > /home/pi/.pip/pip.conf - sudo -u pi echo -e "$easyinstall_index_config" > /home/pi/.pydistutils.cfg - - echo "Configured pypi index url $OCTOPI_PYPI_INDEX" - cat /home/pi/.pip/pip.conf - cat /home/pi/.pydistutils.cfg -fi - +### Script #### # prevent any installed services from automatically starting (I'm looking at you haproxy) echo exit 101 > /usr/sbin/policy-rc.d chmod +x /usr/sbin/policy-rc.d @@ -151,26 +129,19 @@ usermod -a -G dialout pi # store octopi commit used to build this image echo "$OCTOPI_COMMIT" > /etc/octopi_commit -echo "$OCTOPI_BUILDBASE" > /etc/octopi_buildbase + +# Keep legacy compatibility +ln -s /etc/custompios_buildbase /etc/octopi_buildbase # allow pi user to run shutdown and service commands echo "pi ALL=NOPASSWD: /sbin/shutdown" > /etc/sudoers.d/octoprint-shutdown echo "pi ALL=NOPASSWD: /sbin/service" > /etc/sudoers.d/octoprint-service -#reach printer by name -echo "$OCTOPI_OVERRIDE_HOSTNAME" > /etc/hostname -sed -i -e "s@raspberrypi@$OCTOPI_OVERRIDE_HOSTNAME@g" /etc/hosts - #make sure users don't run git with sudo, thus breaking permissions, by adding /root/bin to the #default sudo path and placing a git wrapper script there that checks if it's run as root sed -i "s@secure_path=\"@secure_path=\"/root/bin:@g" /etc/sudoers chmod +x /root/bin/git -# enable raspicam -echo "# enable raspicam" >> /boot/config.txt -echo "start_x=1" >> /boot/config.txt -echo "gpu_mem=128" >> /boot/config.txt - # allow network configuration via /boot/octopi-network.txt sed -i "s@iface wlan0 @iface wlan0-raspbian @g" /etc/network/interfaces sed -i "s@iface wlan1 @iface wlan1-raspbian @g" /etc/network/interfaces @@ -306,15 +277,3 @@ apt-get autoremove -y rm -r /usr/sbin/policy-rc.d -if [ -n "$OCTOPI_APT_PROXY" ] -then - rm -r /etc/apt/apt.conf.d/02octopi_build_proxy -fi - -if [ -n "$OCTOPI_PYPI_INDEX" ] -then - rm -r /root/.pip - rm -r /root/.pydistutils.cfg - rm -r /home/pi/.pip/pip.conf - rm -r /home/pi/.pydistutils.cfg -fi diff --git a/src/nightly_build_scripts/README.rst b/src/nightly_build_scripts/README.rst deleted file mode 100644 index ac417a15..00000000 --- a/src/nightly_build_scripts/README.rst +++ /dev/null @@ -1,11 +0,0 @@ -OctoPi Nightly Build Scripts -============================ - -The scripts in this folder are used to build OctoPi nightly. -The are also two scripts that help you checkout mirrors of the git repos used in the build, the cloning would not be done remotely fromt he github repos. - -* build_local_mirrors - Run this once to clone repos in to /var/www/git folder . -* update_git_mirrors - Run this before each build in order to update the mirrors. -* octopi_nightly_build - Run this to build OctoPi, can be set to run with sudo without a password so an executor like Jenkins can run it. - - diff --git a/src/nightly_build_scripts/build_local_mirrors b/src/nightly_build_scripts/build_local_mirrors deleted file mode 100755 index 1ed1fbab..00000000 --- a/src/nightly_build_scripts/build_local_mirrors +++ /dev/null @@ -1,5 +0,0 @@ -pushd /var/www/git -git clone --mirror https://github.com/foosel/OctoPrint -git clone --mirror https://github.com/jacksonliam/mjpg-streamer.git -git clone --mirror git://git.drogon.net/wiringPi -popd diff --git a/src/nightly_build_scripts/cleanup_storage.js b/src/nightly_build_scripts/cleanup_storage.js deleted file mode 100644 index 971be31a..00000000 --- a/src/nightly_build_scripts/cleanup_storage.js +++ /dev/null @@ -1,108 +0,0 @@ -/** - * Usage: node cleanup_storage.js [] - * - * action: - * "print" or "delete" - * keyfile: - * The key.json file to use for authentication - * - * Setup: - * npm install pkgcloud - */ - -//~~ setup - -// imports - -var pkgcloud = require('pkgcloud'), - fs = require('fs'), - path = require('path'); - -// polyfills - -if (!String.prototype.startsWith) { - String.prototype.startsWith = function (str) { - return !this.indexOf(str); - } -} - -if (!String.prototype.endsWith) { - String.prototype.endsWith = function(searchString, position) { - var subjectString = this.toString(); - if (typeof position !== 'number' || !isFinite(position) || Math.floor(position) !== position || position > subjectString.length) { - position = subjectString.length; - } - position -= searchString.length; - var lastIndex = subjectString.indexOf(searchString, position); - return lastIndex !== -1 && lastIndex === position; - }; -} - -//~~ argument parsing - -// "delete" -> delete, "print" -> only print -if (process.argv.length < 3) { - console.log("Missing mandatory action parameter"); - process.exit(); -} -var action = process.argv[2]; - -// key file to use => ./key.json or second command line argument -var keyfile = path.join(__dirname, 'key.json'); -if (process.argv.length >= 4) { - keyfile = process.argv[3]; -} - -//~~ helpers - -var sortByDate = function(a, b) { - if (a.timeCreated < b.timeCreated) return 1; - if (a.timeCreated > b.timeCreated) return -1; - return 0; -} - -//~~ action and go - -// construct client -var client = require('pkgcloud').storage.createClient({ - provider: 'google', - keyFilename: keyfile, // path to a JSON key file -}); -var container = "octoprint"; - -// fetch our files and render our page -var matchers = [ - { - matcher: function(obj) { return !obj.name.startsWith("stable/") && !obj.name.startsWith("bananapi-m1/") && /octopi-(wheezy|jessie)-/.test(obj.name); }, - limit: 14 - }, - { - matcher: function(obj) { return /^bananapi-m1\//.test(obj.name); }, - limit: 14 - } -] - -var now = new Date(); -client.getFiles(container, function (err, files) { - matchers.forEach(function(m) { - var cutoff = new Date(); - cutoff.setDate(now.getDate() - m.limit); - - var filesToDelete = files.filter(m.matcher) - .filter(function(obj) { return new Date(Date.parse(obj.timeCreated)) < cutoff }); - - filesToDelete.forEach(function (file) { - if (action == "delete") { - client.removeFile(container, encodeURIComponent(file.name), function(err) { - if (err) { - console.log("Error deleting " + file.name + ": " + err); - } else { - console.log("Deleted " + file.name + " on " + container); - } - }); - } else { - console.log("Would now delete " + file.name + " on " + container); - } - }); - }); -}); diff --git a/src/nightly_build_scripts/generate_nightly_page.js b/src/nightly_build_scripts/generate_nightly_page.js deleted file mode 100644 index 445f26fc..00000000 --- a/src/nightly_build_scripts/generate_nightly_page.js +++ /dev/null @@ -1,214 +0,0 @@ -/** - * Usage: node generate_nightly_page.js [ [ []]] - * - * keyfile: - * The key.json file to use for authentication - * outputfile: - * The file where to write the output to - * templatefile: - * The HTML template to use, supports the following placeholders: - * - "{{ title }}" - will be replaced with page title - * - "{{ description }}" - will be replaced with page description - * - "{{ content }}" - will be replaced with page content - * - * Setup: - * npm install pkgcloud - * For NodeJS < 0.10 also - * npm install readable-stream - */ - -//~~ setup - -// imports - -var pkgcloud = require('pkgcloud'), - fs = require('fs'), - path = require('path'), - stream = require('stream'), - util = require('util'); - -// polyfills - -if (!String.prototype.startsWith) { - String.prototype.startsWith = function (str) { - return !this.indexOf(str); - } -} - -if (!String.prototype.endsWith) { - String.prototype.endsWith = function(searchString, position) { - var subjectString = this.toString(); - if (typeof position !== 'number' || !isFinite(position) || Math.floor(position) !== position || position > subjectString.length) { - position = subjectString.length; - } - position -= searchString.length; - var lastIndex = subjectString.indexOf(searchString, position); - return lastIndex !== -1 && lastIndex === position; - }; -} - -//~~ argument parsing - -// key file to use => ./key.json or first command line argument -var keyfile = path.join(__dirname, 'key.json'); -if (process.argv.length >= 3) { - keyfile = process.argv[2]; -} - -// output file => ./index.html or second command line argument -var outputfile = path.join(__dirname, 'index.html'); -if (process.argv.length >= 4) { - outputfile = process.argv[3]; -} - -// template file ==> ./template.html or third command line argument -var templatefile = path.join(__dirname, 'template.html'); -if (process.argv.length >= 5) { - templatefile = process.argv[4]; -} - -//~~ helpers - -var filterByExtension = function(fileObjs, extensions) { - return fileObjs.filter(function (obj) { - var name = obj.name; - return extensions.some(function (extension) { return name.endsWith(extension); }) - }); -} - -var filterByName = function(fileObjs, name) { - return fileObjs.filter(function (obj) { return obj.name.startsWith(name) }); -} - -var filterNameByRegex = function(fileObjs, regex) { - return fileObjs.filter(function (obj) { return regex.test(obj.name) }); -} - -var stripLeading = function(name, toStrip) { - return name.substring(toStrip.length); -} - -var sortByDate = function(a, b) { - if (a.timeCreated < b.timeCreated) return 1; - if (a.timeCreated > b.timeCreated) return -1; - return 0; -} - -var formatDate = function(date) { - return date.replace(/T/, ' ').replace(/\..+/, '') + " UTC"; -} - -var formatSize = function(bytes) { - // Formats the given file size in bytes - if (!bytes) return "-"; - - var units = ["bytes", "KB", "MB"]; - for (var i = 0; i < units.length; i++) { - if (bytes < 1024) { - return bytes.toFixed(1) + units[i]; - } - bytes /= 1024; - } - return bytes.toFixed(1) + "GB"; -} - -var convertHash = function(hash) { - // Converts a hash from base64 to hex - return new Buffer(hash, 'base64').toString('hex'); -} - -var outputTable = function(fileObjs, s, nameProcessor, limit) { - // Outputs an HTML table to for the provided , limiting them to - // and preprocessing the filename with - - limit = limit || 20; - - s.write('\n'); - s.write('\n'); - - // sort by date and limit - fileObjs.sort(sortByDate).slice(0, limit).forEach(function(fileObj) { - console.log("Processing file object: %j", fileObj); - - var url = "https://storage.googleapis.com/octoprint/" + fileObj.name; - var name = nameProcessor(fileObj.name); - - s.write(''); - s.write('"); - s.write('"); - s.write(""); - s.write(""); - s.write("\n"); - }); - - s.write('
NameCreation DateSizeMD5 Hash
' + name + "' + formatDate(fileObj.timeCreated) + "" + formatSize(fileObj.size) + "" + convertHash(fileObj.md5Hash) + "
\n'); -} - -var outputPage = function(files, s) { - // Outputs the page for to stream , using the template. - var title = "OctoPi Downloads"; - var description = "OctoPi Downloads"; - - var Writable = stream.Writable || require('readable-stream').Writable; - function StringStream(options) { - Writable.call(this, options); - this.buffer = ""; - } - util.inherits(StringStream, Writable); - StringStream.prototype._write = function (chunk, enc, cb) { - this.buffer += chunk; - cb(); - }; - - var output = new StringStream(); - - output.write(""); - - output.write("

Raspberry Pi

\n"); - - output.write("

Stable Builds

\n") - outputTable(filterNameByRegex(files, /^stable\/.*octopi-(wheezy|jessie)-.*/), - output, - function(name) { return stripLeading(name, "stable/") }, - 3); - - output.write("

Nightly Builds

\n"); - output.write("Warning: These builds are untested and can be unstable and/or broken. If in doubt use a stable build."); - outputTable(filterNameByRegex(files.filter(function (obj) { return !obj.name.startsWith("stable/") && !obj.name.startsWith("bananapi-m1/") }), /octopi-(wheezy|jessie)-/), - output, - function(name) { return name }, - 14); - - output.write("

Banana Pi M1

\n") - - output.write("

Nightly Builds

\n"); - output.write("Warning: These builds are untested and can be unstable and/or broken."); - outputTable(filterNameByRegex(files, /^bananapi-m1\//), - output, - function(name) { return stripLeading(name, "bananapi-m1/") }, - 14); - - var content = output.buffer; - fs.readFile(templatefile, "utf8", function (err, template) { - var result = template.replace(/{{ content }}/g, content) - .replace(/{{ title }}/g, title) - .replace(/{{ description }}/g, description); - s.write(result); - }) - -} - -//~~ action and go - -// construct client -var client = require('pkgcloud').storage.createClient({ - provider: 'google', - keyFilename: keyfile, // path to a JSON key file -}); -var container = "octoprint"; - -// fetch our files and render our page -client.getFiles(container, function (err, files) { - var stream = fs.createWriteStream(outputfile); - outputPage(filterByExtension(files, [".zip"]), stream); -}); diff --git a/src/nightly_build_scripts/octopi_nightly_build b/src/nightly_build_scripts/octopi_nightly_build deleted file mode 100755 index 6116bdc2..00000000 --- a/src/nightly_build_scripts/octopi_nightly_build +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash -x -whoami -OCTOPIPATH=/OctoPi - -#Update repos used -#sudo -u guy /home/guy/stuff/scripts/gitmirror/update_git_mirrors - -for i in `lsof ${OCTOPIPATH}/src/workspace/mount | awk '{print $2}'`; do kill -9 $i; done - -rm ${OCTOPIPATH}/src/workspace/*.img -rm ${OCTOPIPATH}/src/workspace/*.zip - -pushd ${OCTOPIPATH} - umount ${OCTOPIPATH}/src/workspace/mount/boot - umount ${OCTOPIPATH}/src/workspace/mount/dev/pts - umount ${OCTOPIPATH}/src/workspace/mount - git pull origin devel - #export OCTOPI_OCTOPRINT_REPO_BUILD='http://localhost/git/OctoPrint.git/' - #export OCTOPI_MJPGSTREAMER_REPO_BUILD='http://localhost/git/mjpg-streamer.git/' - #export OCTOPI_WIRINGPI_REPO_BUILD='http://localhost/git/wiringPi.git/' - - ${OCTOPIPATH}/src/build $1 - pushd src - ${OCTOPIPATH}/src/release $1 - popd - chmod 777 ${OCTOPIPATH}/src/* -popd diff --git a/src/nightly_build_scripts/template.html b/src/nightly_build_scripts/template.html deleted file mode 100644 index 88989d1b..00000000 --- a/src/nightly_build_scripts/template.html +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - - {{ title }} - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- {{ content }} -
-
-
-
-
- - - - - diff --git a/src/nightly_build_scripts/update_git_mirrors b/src/nightly_build_scripts/update_git_mirrors deleted file mode 100755 index 03346a08..00000000 --- a/src/nightly_build_scripts/update_git_mirrors +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -MIRROR_LOCATION=/var/www/git -mkdir $MIRROR_LOCATION -pushd MIRROR_LOCATION - for repo in `ls` - do - pushd $repo - git fetch --prune - git update-server-info - popd - done -popd diff --git a/src/octopi b/src/octopi deleted file mode 100755 index 8efdf586..00000000 --- a/src/octopi +++ /dev/null @@ -1,107 +0,0 @@ -#!/usr/bin/env bash -# OctoPi generation script -# This script takes a Raspbian image and adds to it octoprint and verions addons -# Written by Guy Sheffer -# GPL V3 - -source $OCTOPI_SCRIPT_PATH/common.sh - -function execute_chroot_script() { - #move OctoPi filesystem files - cp -vr --preserve=mode,timestamps $1/filesystem . - - #black magic of qemu-arm-static - cp `which qemu-arm-static` usr/bin - - cp $2 chroot_script - chmod 755 chroot_script - cp $OCTOPI_SCRIPT_PATH/common.sh common.sh - chmod 755 common.sh - - chroot . usr/bin/qemu-arm-static /bin/bash /chroot_script - - #cleanup - rm chroot_script - rm -rfv filesystem -} - -mkdir -p $OCTOPI_WORKSPACE -mkdir -p $OCTOPI_MOUNT_PATH - -install_cleanup_trap -install_fail_on_error_trap $OCTOPI_MOUNT_PATH -unmount_image $OCTOPI_MOUNT_PATH force || true - -pushd $OCTOPI_WORKSPACE - if [ -e *.img ]; then - rm *.img - fi - unzip $OCTOPI_ZIP_IMG - OCTOPI_IMG_PATH=`ls | grep '.img\|.raw' | head -n 1` - export OCTOPI_BUILDBASE=$(basename $OCTOPI_IMG_PATH) - - if [ -n "$OCTOPI_IMAGE_ENLARGEROOT" ] - then - # make our image a bit larger so we don't run into size problems... - enlarge_ext $OCTOPI_IMG_PATH $OCTOPI_ROOT_PARTITION $OCTOPI_IMAGE_ENLARGEROOT - fi - - # mount root and boot partition - mount_image $OCTOPI_IMG_PATH $OCTOPI_ROOT_PARTITION $OCTOPI_MOUNT_PATH - if [ -n "$OCTOPI_APT_CACHE" ] - then - mkdir -p "$OCTOPI_APT_CACHE" - mount --bind "$OCTOPI_APT_CACHE" $OCTOPI_MOUNT_PATH/var/cache/apt - fi - - #Edit pi filesystem - pushd $OCTOPI_MOUNT_PATH - - #make QEMU boot (remember to return) - if [ "$OCTOPI_IMAGE_RASPBIAN" == "yes" ]; then - fixLd - fi - #sed -i 's@include /etc/ld.so.conf.d/\*.conf@\#include /etc/ld.so.conf.d/\*.conf@' etc/ld.so.conf - - # if an additional pre-script is defined, execute that now - if [ -n "$OCTOPI_PRESCRIPT" ] && [ -f $OCTOPI_PRESCRIPT/chroot_script ]; then - echo "Injecting environment pre script from $OCTOPI_PRESCRIPT..." - execute_chroot_script $OCTOPI_PRESCRIPT $OCTOPI_PRESCRIPT/chroot_script - fi - - # if building a variant, execute its pre-chroot script - if [ -n "$VARIANT_BASE" ] && [ -f $VARIANT_BASE/pre_chroot_script ]; then - echo "Injecting variant pre script from $VARIANT_BASE..." - execute_chroot_script $VARIANT_BASE $VARIANT_BASE/pre_chroot_script - fi - - # execute the base chroot script - execute_chroot_script $OCTOPI_SCRIPT_PATH $OCTOPI_CHROOT_SCRIPT_PATH - - # if building a variant, execute its post-chroot script - if [ -n "$VARIANT_BASE" ] && [ -f $VARIANT_BASE/post_chroot_script ]; then - echo "Injecting variant post script from $VARIANT_BASE..." - execute_chroot_script $VARIANT_BASE $VARIANT_BASE/post_chroot_script - fi - - # if an additional post-script is defined, execute that now - if [ -n "$OCTOPI_POSTSCRIPT" ] && [ -f $OCTOPI_POSTSCRIPT/chroot_script ]; then - echo "Injecting environment post script from $OCTOPI_POSTSCRIPT..." - execute_chroot_script $OCTOPI_POSTSCRIPT $OCTOPI_POSTSCRIPT/chroot_script - fi - if [ "$OCTOPI_IMAGE_RASPBIAN" == "yes" ]; then - restoreLd - fi - popd - - # unmount first boot, then root partition - unmount_image $OCTOPI_MOUNT_PATH - chmod 777 $OCTOPI_IMG_PATH - - if [ -n "$OCTOPI_IMAGE_RESIZEROOT" ] - then - # resize image to minimal size + provided size - minimize_ext $OCTOPI_IMG_PATH $OCTOPI_ROOT_PARTITION $OCTOPI_IMAGE_RESIZEROOT - fi -popd - diff --git a/src/release b/src/release deleted file mode 100755 index b42bb2df..00000000 --- a/src/release +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash -if [ -z "$1" ];then - pushd workspace -else - pushd workspace-$1 -fi - -FILENAME=$(basename `ls . | grep -e .img -e .raw | tail -n 1`) -OCTOPI_FILENAME=$(echo "${FILENAME::-4}"-`cat ../filesystem/root/etc/octopi_version` | sed 's/raspbian/octopi/').img -mv ${FILENAME} $OCTOPI_FILENAME -zip ${OCTOPI_FILENAME::-4}.zip $OCTOPI_FILENAME - -popd diff --git a/src/vagrant/Vagrantfile b/src/vagrant/Vagrantfile index 76d14f72..a947c807 100644 --- a/src/vagrant/Vagrantfile +++ b/src/vagrant/Vagrantfile @@ -1,9 +1,17 @@ +vagrant_root = File.dirname(__FILE__) Vagrant.configure("2") do |o| # o.vm.box = "octopi-build" - o.vm.box= "wzurowski/vivid64" + o.vm.box= "geerlingguy/ubuntu1604" o.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'" - o.vm.synced_folder "../../", "/OctoPi", create:true, type: "nfs" + o.vm.synced_folder "/path/to/CustomPiOS", "/OctoPi", create:true, type: "nfs" + o.vm.synced_folder "../", "/distro", create:true, type: "nfs" o.vm.network :private_network, ip: "192.168.55.55" o.vm.provision :shell, :path => "setup.sh", args: ENV['SHELL_ARGS'] + #o.vbguest.auto_update = false + + o.vm.provider "virtualbox" do |v| + v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] + v.customize ["modifyvm", :id, "--natdnsproxy1", "on"] + end end diff --git a/src/vagrant/run_vagrant_build.sh b/src/vagrant/run_vagrant_build.sh index 823ee81e..bf1f7be0 100755 --- a/src/vagrant/run_vagrant_build.sh +++ b/src/vagrant/run_vagrant_build.sh @@ -1,3 +1,3 @@ #!/usr/bin/env bash -sudo vagrant ssh -- -t "sudo /OctoPi/src/nightly_build_scripts/octopi_nightly_build $@" +sudo vagrant ssh -- -t "sudo /OctoPi/nightly_build_scripts/octopi_nightly_build $@" diff --git a/src/vagrant/setup.sh b/src/vagrant/setup.sh index 128841d4..73904833 100644 --- a/src/vagrant/setup.sh +++ b/src/vagrant/setup.sh @@ -2,5 +2,5 @@ sudo apt-get update sudo apt-get install -y gawk util-linux realpath git qemu-user-static unzip zip -cd /OctoPi/src -sudo bash ./build +#cd /OctoPi/src +#sudo bash ./build From b7877b01b16c86efd3e888b7846a8739d0fc8b7b Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Wed, 21 Jun 2017 01:32:18 +0300 Subject: [PATCH 164/352] Fix typo --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index fb986911..f8ba9f58 100644 --- a/README.rst +++ b/README.rst @@ -67,7 +67,7 @@ You can build it by issuing the following commands:: sudo apt-get install gawk util-linux realpath qemu-user-static git - https://github.com/guysoft/CustomPiOS.git + git clone https://github.com/guysoft/CustomPiOS.git git clone https://github.com/guysoft/OctoPi.git cd OctoPi/src/image curl -J -O -L http://downloads.raspberrypi.org/raspbian_latest From d94e89e17f3b2dbf86a9a9125d5f442ad34e47de Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Wed, 21 Jun 2017 01:33:37 +0300 Subject: [PATCH 165/352] Fix more typos --- README.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index f8ba9f58..9b6b5b38 100644 --- a/README.rst +++ b/README.rst @@ -72,9 +72,9 @@ You can build it by issuing the following commands:: cd OctoPi/src/image curl -J -O -L http://downloads.raspberrypi.org/raspbian_latest cd .. - ../CustomPiOS/src/update-custompios-paths + ../../CustomPiOS/src/update-custompios-paths sudo modprobe loop - sudo bash -x ./build + sudo bash -x ./build_dist Building OctoPi Variants ~~~~~~~~~~~~~~~~~~~~~~~~ From d063de74abbd49fe6e1c04c6d2b37286b3773cd7 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Fri, 23 Jun 2017 19:07:55 +0300 Subject: [PATCH 166/352] Move network logic out to standard network module --- src/config | 2 +- .../octopi/filesystem/boot/octopi-network.txt | 71 ------------------- .../filesystem/home/root/bin/check_wpa_link | 46 ------------ .../octopi/filesystem/home/root/bin/map_iface | 13 ---- .../root/etc/logrotate.d/map_iface.log | 10 --- .../etc/systemd/system/check_wpa_link.service | 17 ----- src/modules/octopi/start_chroot_script | 33 --------- 7 files changed, 1 insertion(+), 191 deletions(-) delete mode 100644 src/modules/octopi/filesystem/boot/octopi-network.txt delete mode 100755 src/modules/octopi/filesystem/home/root/bin/check_wpa_link delete mode 100755 src/modules/octopi/filesystem/home/root/bin/map_iface delete mode 100644 src/modules/octopi/filesystem/root/etc/logrotate.d/map_iface.log delete mode 100644 src/modules/octopi/filesystem/root/etc/systemd/system/check_wpa_link.service diff --git a/src/config b/src/config index a4cc49f8..cfdc67f6 100644 --- a/src/config +++ b/src/config @@ -1,4 +1,4 @@ export DIST_NAME=OctoPi export DIST_VERSION=0.14 -export MODULES="base(raspicam, octopi)" +export MODULES="base(raspicam, network, octopi)" diff --git a/src/modules/octopi/filesystem/boot/octopi-network.txt b/src/modules/octopi/filesystem/boot/octopi-network.txt deleted file mode 100644 index 34334783..00000000 --- a/src/modules/octopi/filesystem/boot/octopi-network.txt +++ /dev/null @@ -1,71 +0,0 @@ -# You can use this file to manually set up your network configuration. -# -# This file is included into /etc/network/interfaces, so anything that -# works by editing that file is also possible here. - -# !!!!! HEADS-UP MACOSX USERS !!!!! -# -# If you use Textedit to edit this file make sure to use "plain text format" -# and "disable smart quotes" in "Textedit > Preferences", otherwise Textedit -# will use none-compatible characters and your network configuration won't -# work! -# -# !!!!! HEADS-UP MACOSX USERS !!!!! - -### WIFI CONFIGURATION ###################################################### -# The three segments below should cover you in most cases if you run -# a wifi network that uses either WPA/WPA2 or WEP encryption. -# -# Just uncomment the lines prefixed with a single # of the configuration -# that matches your wifi setup and fill in SSID and passphrase. -# -# If you need to configure more than 1 wifi network, please use /boot/octopi-wpa-supplicant.txt instead -# -# ATTENTION: please note that the raspberry pi 3 internal wifi does currently not support the wifi channels 12 and 13 - -## WPA/WPA2 secured -#iface wlan0-octopi inet manual -# wpa-ssid "put SSID here" -# wpa-psk "put password here" - -## WEP secured -#iface wlan0-octopi inet manual -# wireless-essid "put SSID here" -# wireless-key "put password here" - -## Open/unsecured -#iface wlan0-octopi inet manual -# wireless-essid "put SSID here" -# wireless-mode managed - -### WIRED CONFIGURATION WITH DHCP ########################################### -# Nothing to do, OctoPi is already preconfigured that way. Just plug in your -# cable, wait for an IP to be assigned and stuff should work out of the box -# just fine. - -### WIRED CONFIGURATION WITH STATIC IP ###################################### -# The following segment allows you to configure your wired connection -# with a static IP. -# -# Just uncomment the lines prefixed with a single #. Then connect -# a cable to the Pi and another system, e.g. a Laptop, and set that -# other system's network configuration to: -# -# address: 192.168.250.10 -# netmask: 255.255.255.0 -# broadcast: 192.168.250.255 -# -# You can then reach the Pi from the system's browser by going to -# -# http://192.168.250.1 -# -# or -# -# http://octopi.local - -#auto eth0:1 -#iface eth0:1 inet static -# address 192.168.250.1 -# netmask 255.255.255.0 -# broadcast 192.168.250.255 - diff --git a/src/modules/octopi/filesystem/home/root/bin/check_wpa_link b/src/modules/octopi/filesystem/home/root/bin/check_wpa_link deleted file mode 100755 index f324a20e..00000000 --- a/src/modules/octopi/filesystem/home/root/bin/check_wpa_link +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/sh - -link_source="/etc/wpa_supplicant/wpa_supplicant.conf" -link_target="/boot/octopi-wpa-supplicant.txt" - -if ! [ -L $link_source ] && [ -f $link_target ] -then - # wpa_supplicant.conf is not a link, link target exists - echo "Symlink from $link_source to $link_target has been broken, attempting restore" - - if [ -f $link_source ] - then - # wpa_supplicant.conf exists but symlink has been removed. This can happen when - # the wifi country setting is changed through raspi-config (for versions of that - # older than early april 2017). See also guysoft/OctoPi#336 - # - # We'll now attempt to parse the current wifi country from wpa_supplicant.conf, - # apply it to our link target, remove the wpa_supplicant and then recreate the - # symlink. - - if grep -q "^country=" $link_source ; then - echo "Wifi country setting detected in $link_source, will copy" - - # parse country setting from wpa_supplicant.conf - this is adapted from raspi-config - country=`grep country= $link_source | cut -d "=" -f 2` - - # apply it to link target - this is adapted from raspi-config - if grep -q "^country=" $link_target ; then - sed -i --follow-symlinks "s/^country=.*/country=$country/g" $link_target - else - sed -i --follow-symlinks "1i country=$country" $link_target - fi - - echo "Copied wifi country setting $country to $link_target" - fi - - # remove wpa_supplicant.conf and recreate symlink - rm $link_source - ln -s $link_target $link_source - echo "Restored link from $link_source to $link_target" - else - # wpa_supplicant.conf is missing completely, recreate symlink - ln -s $link_target $link_source - echo "Restored link from $link_source to $link_target" - fi -fi diff --git a/src/modules/octopi/filesystem/home/root/bin/map_iface b/src/modules/octopi/filesystem/home/root/bin/map_iface deleted file mode 100755 index f8fa3b3f..00000000 --- a/src/modules/octopi/filesystem/home/root/bin/map_iface +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -set -e - -IFACE=$1 - -if grep -q "^\s*iface $IFACE-octopi " /boot/octopi-network.txt -then - echo "$IFACE-octopi" - echo "Using /boot/octopi-network.txt for configuring $IFACE..." >> /var/log/map_iface.log -else - echo "$IFACE-raspbian" - echo "Using original Raspbian configuration for configuring $IFACE..." >> /var/log/map_iface.log -fi diff --git a/src/modules/octopi/filesystem/root/etc/logrotate.d/map_iface.log b/src/modules/octopi/filesystem/root/etc/logrotate.d/map_iface.log deleted file mode 100644 index f7526a13..00000000 --- a/src/modules/octopi/filesystem/root/etc/logrotate.d/map_iface.log +++ /dev/null @@ -1,10 +0,0 @@ -/var/log/map_iface.log -{ - rotate 1 - daily - missingok - notifempty - compress - delaycompress - sharedscripts -} diff --git a/src/modules/octopi/filesystem/root/etc/systemd/system/check_wpa_link.service b/src/modules/octopi/filesystem/root/etc/systemd/system/check_wpa_link.service deleted file mode 100644 index b4a1adf3..00000000 --- a/src/modules/octopi/filesystem/root/etc/systemd/system/check_wpa_link.service +++ /dev/null @@ -1,17 +0,0 @@ -[Unit] -Description=Check that wpa-supplicant.conf is a symlink - -DefaultDependencies=no - -Before=network-pre.target -Wants=network-pre.target - -After=local-fs.target -Wants=local-fs.target - -[Service] -Type=oneshot -ExecStart=/root/bin/check_wpa_link - -[Install] -WantedBy=multi-user.target diff --git a/src/modules/octopi/start_chroot_script b/src/modules/octopi/start_chroot_script index 4d7772a0..ba083ccd 100755 --- a/src/modules/octopi/start_chroot_script +++ b/src/modules/octopi/start_chroot_script @@ -9,7 +9,6 @@ set -e export LC_ALL=C source /common.sh -install_cleanup_trap ### Script #### # prevent any installed services from automatically starting (I'm looking at you haproxy) @@ -142,35 +141,6 @@ echo "pi ALL=NOPASSWD: /sbin/service" > /etc/sudoers.d/octoprint-service sed -i "s@secure_path=\"@secure_path=\"/root/bin:@g" /etc/sudoers chmod +x /root/bin/git -# allow network configuration via /boot/octopi-network.txt -sed -i "s@iface wlan0 @iface wlan0-raspbian @g" /etc/network/interfaces -sed -i "s@iface wlan1 @iface wlan1-raspbian @g" /etc/network/interfaces -echo "mapping wlan0" >> /etc/network/interfaces -echo " script /root/bin/map_iface" >> /etc/network/interfaces -echo "mapping wlan1" >> /etc/network/interfaces -echo " script /root/bin/map_iface" >> /etc/network/interfaces -echo "source /boot/octopi-network.txt" >> /etc/network/interfaces - -# allow configuring multiple wifi networks via /boot/octopi-wpa-supplicant.txt -mv /etc/wpa_supplicant/wpa_supplicant.conf /boot/octopi-wpa-supplicant.txt -ln -s /boot/octopi-wpa-supplicant.txt /etc/wpa_supplicant/wpa_supplicant.conf -cat <> /etc/wpa_supplicant/wpa_supplicant.conf - -# This is only used to configure multiple wifi networks or other advanced wifi features. -# take a look into octopi-network.txt instead if you only need basic wifi configuration -# 'man -s 5 wpa_supplicant.conf' for advanced options -#network={ -# ssid="Your Wifi SSID" -# psk="supersecretwifipassword" -#} - -## You can configure more than 1 wifi networks by adding more 'network' blocks -#network={ -# ssid="Another Wifi" -# psk="password" -#} -EOT - # copy /etc/wpa_supplicant/ifupdown.sh to /etc/ifplugd/action.d/ifupdown - for wlan auto reconnect [ -f /etc/ifplugd/action.d/ifupdown ] && mv /etc/ifplugd/action.d/ifupdown /etc/ifplugd/action.d/ifupdown.original [ -f /etc/wpa_supplicant/ifupdown.sh ] && ln -s /etc/wpa_supplicant/ifupdown.sh /etc/ifplugd/action.d/ifupdown @@ -200,9 +170,6 @@ echo "------------------------------------------------------------" echo EOT -# prevent ntp updates from failing due to some Rpi3 weirdness, see also "Fix SSH" further below -echo '/sbin/iptables -t mangle -I POSTROUTING 1 -o wlan0 -p udp --dport 123 -j TOS --set-tos 0x00' >> /etc/rc.local - echo 'exit 0' >> /etc/rc.local # add a longer welcome text to ~pi/.bashrc From fec28aa8d7f423ddc8fa89cd506f63d458d44071 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Fri, 23 Jun 2017 19:11:50 +0300 Subject: [PATCH 167/352] Move also auto reconnect to network module --- src/modules/octopi/start_chroot_script | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/modules/octopi/start_chroot_script b/src/modules/octopi/start_chroot_script index ba083ccd..429b0866 100755 --- a/src/modules/octopi/start_chroot_script +++ b/src/modules/octopi/start_chroot_script @@ -141,10 +141,6 @@ echo "pi ALL=NOPASSWD: /sbin/service" > /etc/sudoers.d/octoprint-service sed -i "s@secure_path=\"@secure_path=\"/root/bin:@g" /etc/sudoers chmod +x /root/bin/git -# copy /etc/wpa_supplicant/ifupdown.sh to /etc/ifplugd/action.d/ifupdown - for wlan auto reconnect -[ -f /etc/ifplugd/action.d/ifupdown ] && mv /etc/ifplugd/action.d/ifupdown /etc/ifplugd/action.d/ifupdown.original -[ -f /etc/wpa_supplicant/ifupdown.sh ] && ln -s /etc/wpa_supplicant/ifupdown.sh /etc/ifplugd/action.d/ifupdown - # add some "How To" info to boot output sed -i 's@exit 0@@' /etc/rc.local cat <<'EOT' >> /etc/rc.local From e7ac59c9d288f670a78366c517bf7fdefa4a6d37 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Sat, 24 Jun 2017 01:01:48 +0300 Subject: [PATCH 168/352] Use new file model for custompios path --- .gitignore | 1 + src/build_dist | 3 ++- src/vagrant/Vagrantfile | 2 +- src/vagrant/run_vagrant_build.sh | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 01d9f4cb..601b9448 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ src/config.local +src/custompios_path src/image/*.zip **/key.json diff --git a/src/build_dist b/src/build_dist index 6df7a647..635f1608 100755 --- a/src/build_dist +++ b/src/build_dist @@ -1,7 +1,8 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" export DIST_PATH=${DIR} -export CUSTOM_PI_OS_PATH=/path/to/CustomPiOS +export CUSTOM_PI_OS_PATH=$(<${DIR}/custompios_path) export PATH=$PATH:$CUSTOM_PI_OS_PATH +echo ${CUSTOM_PI_OS_PATH} ${CUSTOM_PI_OS_PATH}/build_custom_os ${DIST_PATH} diff --git a/src/vagrant/Vagrantfile b/src/vagrant/Vagrantfile index a947c807..a52dd6eb 100644 --- a/src/vagrant/Vagrantfile +++ b/src/vagrant/Vagrantfile @@ -3,7 +3,7 @@ Vagrant.configure("2") do |o| # o.vm.box = "octopi-build" o.vm.box= "geerlingguy/ubuntu1604" o.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'" - o.vm.synced_folder "/path/to/CustomPiOS", "/OctoPi", create:true, type: "nfs" + o.vm.synced_folder File.read("../custompios_path").gsub("\n",""), "/CustomPiOS", create:true, type: "nfs" o.vm.synced_folder "../", "/distro", create:true, type: "nfs" o.vm.network :private_network, ip: "192.168.55.55" o.vm.provision :shell, :path => "setup.sh", args: ENV['SHELL_ARGS'] diff --git a/src/vagrant/run_vagrant_build.sh b/src/vagrant/run_vagrant_build.sh index bf1f7be0..1ef3189b 100755 --- a/src/vagrant/run_vagrant_build.sh +++ b/src/vagrant/run_vagrant_build.sh @@ -1,3 +1,3 @@ #!/usr/bin/env bash -sudo vagrant ssh -- -t "sudo /OctoPi/nightly_build_scripts/octopi_nightly_build $@" +sudo vagrant ssh -- -t "sudo /CustomPiOS/nightly_build_scripts/custompios_nightly_build $@" From 7eb56dcddfbe4f1fce89db4ec766ef7c7b95a283 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Sat, 24 Jun 2017 16:19:23 +0300 Subject: [PATCH 169/352] Make build work with 2017-06-23, non-vagrant builds need to have e2gsprogs 1.43+ --- src/common.sh | 2 +- src/vagrant/Vagrantfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common.sh b/src/common.sh index f908ba75..4aaaa96b 100755 --- a/src/common.sh +++ b/src/common.sh @@ -128,7 +128,7 @@ function mount_image() { # mount root and boot partition sudo mount -o loop,offset=$root_offset $image_path $mount_path/ if [[ "$boot_partition" != "$root_partition" ]]; then - sudo mount -o loop,offset=$boot_offset $image_path $mount_path/boot + sudo mount -o loop,offset=$boot_offset,sizelimit=$( expr $root_offset - $boot_offset ) $image_path $mount_path/boot fi sudo mkdir -p $mount_path/dev/pts sudo mount -o bind /dev $mount_path/dev diff --git a/src/vagrant/Vagrantfile b/src/vagrant/Vagrantfile index 76d14f72..8b937220 100644 --- a/src/vagrant/Vagrantfile +++ b/src/vagrant/Vagrantfile @@ -1,6 +1,6 @@ Vagrant.configure("2") do |o| # o.vm.box = "octopi-build" - o.vm.box= "wzurowski/vivid64" + o.vm.box= "ubuntu/zesty64" o.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'" o.vm.synced_folder "../../", "/OctoPi", create:true, type: "nfs" o.vm.network :private_network, ip: "192.168.55.55" From bacf064f03a903149501046bb56411d3214451ce Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Sat, 24 Jun 2017 17:31:03 +0300 Subject: [PATCH 170/352] Do not build on provision anymore --- src/vagrant/setup.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/vagrant/setup.sh b/src/vagrant/setup.sh index 128841d4..1ae65d5a 100644 --- a/src/vagrant/setup.sh +++ b/src/vagrant/setup.sh @@ -2,5 +2,3 @@ sudo apt-get update sudo apt-get install -y gawk util-linux realpath git qemu-user-static unzip zip -cd /OctoPi/src -sudo bash ./build From fc89313d39c8cc8fe5b3a55f110a2da713d7d481 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Fri, 7 Jul 2017 15:42:13 +0300 Subject: [PATCH 171/352] Make variants work --- .gitignore | 6 ++++ src/variants/armbian/config | 8 ------ .../filesystem/root/etc/network/interfaces | 21 -------------- .../armbian/filesystem/root/etc/resolv.conf | 2 -- .../etc/wpa_supplicant/wpa_supplicant.conf | 2 -- src/variants/armbian/post_chroot_script | 1 - src/variants/armbian/pre_chroot_script | 28 ------------------- src/variants/bananapi-m1/config | 2 -- .../filesystem/root/etc/resolv.conf | 2 -- src/variants/bananapi-m1/post_chroot_script | 1 - src/variants/bananapi-m1/pre_chroot_script | 12 -------- src/variants/example/config | 4 --- src/variants/example/config.nightly | 3 -- .../example/filesystem/root/etc/dhclient.conf | 0 src/variants/example/post_chroot_script | 11 -------- src/variants/jessielite/config | 1 - 16 files changed, 6 insertions(+), 98 deletions(-) delete mode 100755 src/variants/armbian/config delete mode 100644 src/variants/armbian/filesystem/root/etc/network/interfaces delete mode 100644 src/variants/armbian/filesystem/root/etc/resolv.conf delete mode 100644 src/variants/armbian/filesystem/root/etc/wpa_supplicant/wpa_supplicant.conf delete mode 100755 src/variants/armbian/post_chroot_script delete mode 100755 src/variants/armbian/pre_chroot_script delete mode 100755 src/variants/bananapi-m1/config delete mode 100644 src/variants/bananapi-m1/filesystem/root/etc/resolv.conf delete mode 100644 src/variants/bananapi-m1/post_chroot_script delete mode 100755 src/variants/bananapi-m1/pre_chroot_script delete mode 100755 src/variants/example/config delete mode 100755 src/variants/example/config.nightly delete mode 100644 src/variants/example/filesystem/root/etc/dhclient.conf delete mode 100755 src/variants/example/post_chroot_script delete mode 100644 src/variants/jessielite/config diff --git a/.gitignore b/.gitignore index 601b9448..585909e6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,10 @@ src/config.local src/custompios_path src/image/*.zip +src/image-variants/*.zip **/key.json +src/workspace-* +src/workspace +src/build.log +src/vagrant/*.log +src/vagrant/.vagrant diff --git a/src/variants/armbian/config b/src/variants/armbian/config deleted file mode 100755 index dd47f166..00000000 --- a/src/variants/armbian/config +++ /dev/null @@ -1,8 +0,0 @@ -VARIANT_CONFIG_DIR=$(realpath -s $(dirname $(realpath -s $BASH_SOURCE))/../..) -OCTOPI_ZIP_IMG=`ls -t $VARIANT_CONFIG_DIR/image-variants/Armbian*.zip | head -n 1` -#OCTOPI_APT_CACHE="" -OCTOPI_INCLUDE_WIRINGPI=no -# The root partiton of the image filesystem, 2 for raspbian, 1 for armbian -OCTOPI_ROOT_PARTITION=1 -OCTOPI_IMAGE_RESIZEROOT=500 -OCTOPI_IMAGE_RASPBIAN=no diff --git a/src/variants/armbian/filesystem/root/etc/network/interfaces b/src/variants/armbian/filesystem/root/etc/network/interfaces deleted file mode 100644 index 3648282f..00000000 --- a/src/variants/armbian/filesystem/root/etc/network/interfaces +++ /dev/null @@ -1,21 +0,0 @@ -# interfaces(5) file used by ifup(8) and ifdown(8) - -# Please note that this file is written to be used with dhcpcd -# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf' - -# Include files from /etc/network/interfaces.d: -source-directory /etc/network/interfaces.d - -auto lo -iface lo inet loopback - -iface eth0 inet manual - -allow-hotplug wlan0 -iface wlan0 inet manual - wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf - -allow-hotplug wlan1 -iface wlan1 inet manual - wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf - diff --git a/src/variants/armbian/filesystem/root/etc/resolv.conf b/src/variants/armbian/filesystem/root/etc/resolv.conf deleted file mode 100644 index ec22e23c..00000000 --- a/src/variants/armbian/filesystem/root/etc/resolv.conf +++ /dev/null @@ -1,2 +0,0 @@ -nameserver localhost -nameserver 8.8.8.8 diff --git a/src/variants/armbian/filesystem/root/etc/wpa_supplicant/wpa_supplicant.conf b/src/variants/armbian/filesystem/root/etc/wpa_supplicant/wpa_supplicant.conf deleted file mode 100644 index 0fc335eb..00000000 --- a/src/variants/armbian/filesystem/root/etc/wpa_supplicant/wpa_supplicant.conf +++ /dev/null @@ -1,2 +0,0 @@ -ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev -update_config=1 diff --git a/src/variants/armbian/post_chroot_script b/src/variants/armbian/post_chroot_script deleted file mode 100755 index 9a103c68..00000000 --- a/src/variants/armbian/post_chroot_script +++ /dev/null @@ -1 +0,0 @@ -sed -i -e "s@manual@dhcp@g" /boot/octopi-network.txt diff --git a/src/variants/armbian/pre_chroot_script b/src/variants/armbian/pre_chroot_script deleted file mode 100755 index 71b0e3c3..00000000 --- a/src/variants/armbian/pre_chroot_script +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash -set -x -echo "" > /dev/null - -#fix W: Not using locking for nfs mounted lock file /var/cache/apt/archives/lock -mount -o remount,rw / - - -password=$(perl -e 'printf("%s\n", crypt($ARGV[0], "password"))' "raspberry") -useradd -m -p "${password}" -s /bin/bash pi -usermod -aG video,audio,plugdev,games,netdev,i2c,sudo pi - -source /common.sh -install_chroot_fail_on_error_trap - -# install dhclient.conf and possibly other files -unpack /filesystem/root / - -#cleanup -mkdir -p /var/cache/apt/archives -apt-get clean -apt-get update -apt-get -y --force-yes install avahi-daemon || true -apt-get -y --force-yes install -f -apt-get -y --force-yes install python-pip -pip install virtualenv --upgrade - -mkdir -p /var/run/wpa_supplicant diff --git a/src/variants/bananapi-m1/config b/src/variants/bananapi-m1/config deleted file mode 100755 index d5d67d6e..00000000 --- a/src/variants/bananapi-m1/config +++ /dev/null @@ -1,2 +0,0 @@ -VARIANT_CONFIG_DIR=$(realpath -s $(dirname $(realpath -s $BASH_SOURCE))/../..) -OCTOPI_ZIP_IMG=`ls -t $VARIANT_CONFIG_DIR/image-varients/*-raspbian-bpi-R1-M1*.zip | head -n 1` diff --git a/src/variants/bananapi-m1/filesystem/root/etc/resolv.conf b/src/variants/bananapi-m1/filesystem/root/etc/resolv.conf deleted file mode 100644 index ec22e23c..00000000 --- a/src/variants/bananapi-m1/filesystem/root/etc/resolv.conf +++ /dev/null @@ -1,2 +0,0 @@ -nameserver localhost -nameserver 8.8.8.8 diff --git a/src/variants/bananapi-m1/post_chroot_script b/src/variants/bananapi-m1/post_chroot_script deleted file mode 100644 index 8b137891..00000000 --- a/src/variants/bananapi-m1/post_chroot_script +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/variants/bananapi-m1/pre_chroot_script b/src/variants/bananapi-m1/pre_chroot_script deleted file mode 100755 index f24455be..00000000 --- a/src/variants/bananapi-m1/pre_chroot_script +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash -set -x - -source /common.sh -install_chroot_fail_on_error_trap - -# install dhclient.conf and possibly other files -unpack /filesystem/root / - -#cleanup -mkdir -p /var/cache/apt/archives -apt-get clean diff --git a/src/variants/example/config b/src/variants/example/config deleted file mode 100755 index 0f638e0b..00000000 --- a/src/variants/example/config +++ /dev/null @@ -1,4 +0,0 @@ -# variant example, flavor default: override hostname & custom config setting - -OCTOPI_OVERRIDE_HOSTNAME=blueberrypi -OCTOPI_EXAMPLE_CUSTOM="Hello there" diff --git a/src/variants/example/config.nightly b/src/variants/example/config.nightly deleted file mode 100755 index 209b3bd4..00000000 --- a/src/variants/example/config.nightly +++ /dev/null @@ -1,3 +0,0 @@ -# variant example, flavor nightly: override hostname & octoprint branch - -OCTOPI_OCTOPRINT_REPO_BRANCH=devel diff --git a/src/variants/example/filesystem/root/etc/dhclient.conf b/src/variants/example/filesystem/root/etc/dhclient.conf deleted file mode 100644 index e69de29b..00000000 diff --git a/src/variants/example/post_chroot_script b/src/variants/example/post_chroot_script deleted file mode 100755 index da988bb9..00000000 --- a/src/variants/example/post_chroot_script +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash -set -x - -source /common.sh -install_chroot_fail_on_error_trap - -# install dhclient.conf and possibly other files -unpack /filesystem/root / - -#cleanup -apt-get clean diff --git a/src/variants/jessielite/config b/src/variants/jessielite/config deleted file mode 100644 index 65f30cd1..00000000 --- a/src/variants/jessielite/config +++ /dev/null @@ -1 +0,0 @@ -OCTOPI_IMAGE_ENLARGEROOT=250 From e8438b5c71781d824acb7768088197273557652f Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Mon, 17 Jul 2017 11:45:17 +0300 Subject: [PATCH 172/352] Fix nightly_build_scripts to include OctoPi publish again --- .gitignore | 2 + src/nightly_build_scripts/cleanup_storage.js | 108 +++++++++ .../generate_nightly_page.js | 214 ++++++++++++++++++ src/nightly_build_scripts/template.html | 76 +++++++ src/nightly_build_scripts/update_git_mirrors | 12 + 5 files changed, 412 insertions(+) create mode 100644 src/nightly_build_scripts/cleanup_storage.js create mode 100644 src/nightly_build_scripts/generate_nightly_page.js create mode 100644 src/nightly_build_scripts/template.html create mode 100755 src/nightly_build_scripts/update_git_mirrors diff --git a/.gitignore b/.gitignore index 585909e6..caa2b02e 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,8 @@ src/custompios_path src/image/*.zip src/image-variants/*.zip **/key.json +src/nightly_build_scripts/index.html +src/nightly_build_scripts/node_modules src/workspace-* src/workspace src/build.log diff --git a/src/nightly_build_scripts/cleanup_storage.js b/src/nightly_build_scripts/cleanup_storage.js new file mode 100644 index 00000000..971be31a --- /dev/null +++ b/src/nightly_build_scripts/cleanup_storage.js @@ -0,0 +1,108 @@ +/** + * Usage: node cleanup_storage.js [] + * + * action: + * "print" or "delete" + * keyfile: + * The key.json file to use for authentication + * + * Setup: + * npm install pkgcloud + */ + +//~~ setup + +// imports + +var pkgcloud = require('pkgcloud'), + fs = require('fs'), + path = require('path'); + +// polyfills + +if (!String.prototype.startsWith) { + String.prototype.startsWith = function (str) { + return !this.indexOf(str); + } +} + +if (!String.prototype.endsWith) { + String.prototype.endsWith = function(searchString, position) { + var subjectString = this.toString(); + if (typeof position !== 'number' || !isFinite(position) || Math.floor(position) !== position || position > subjectString.length) { + position = subjectString.length; + } + position -= searchString.length; + var lastIndex = subjectString.indexOf(searchString, position); + return lastIndex !== -1 && lastIndex === position; + }; +} + +//~~ argument parsing + +// "delete" -> delete, "print" -> only print +if (process.argv.length < 3) { + console.log("Missing mandatory action parameter"); + process.exit(); +} +var action = process.argv[2]; + +// key file to use => ./key.json or second command line argument +var keyfile = path.join(__dirname, 'key.json'); +if (process.argv.length >= 4) { + keyfile = process.argv[3]; +} + +//~~ helpers + +var sortByDate = function(a, b) { + if (a.timeCreated < b.timeCreated) return 1; + if (a.timeCreated > b.timeCreated) return -1; + return 0; +} + +//~~ action and go + +// construct client +var client = require('pkgcloud').storage.createClient({ + provider: 'google', + keyFilename: keyfile, // path to a JSON key file +}); +var container = "octoprint"; + +// fetch our files and render our page +var matchers = [ + { + matcher: function(obj) { return !obj.name.startsWith("stable/") && !obj.name.startsWith("bananapi-m1/") && /octopi-(wheezy|jessie)-/.test(obj.name); }, + limit: 14 + }, + { + matcher: function(obj) { return /^bananapi-m1\//.test(obj.name); }, + limit: 14 + } +] + +var now = new Date(); +client.getFiles(container, function (err, files) { + matchers.forEach(function(m) { + var cutoff = new Date(); + cutoff.setDate(now.getDate() - m.limit); + + var filesToDelete = files.filter(m.matcher) + .filter(function(obj) { return new Date(Date.parse(obj.timeCreated)) < cutoff }); + + filesToDelete.forEach(function (file) { + if (action == "delete") { + client.removeFile(container, encodeURIComponent(file.name), function(err) { + if (err) { + console.log("Error deleting " + file.name + ": " + err); + } else { + console.log("Deleted " + file.name + " on " + container); + } + }); + } else { + console.log("Would now delete " + file.name + " on " + container); + } + }); + }); +}); diff --git a/src/nightly_build_scripts/generate_nightly_page.js b/src/nightly_build_scripts/generate_nightly_page.js new file mode 100644 index 00000000..445f26fc --- /dev/null +++ b/src/nightly_build_scripts/generate_nightly_page.js @@ -0,0 +1,214 @@ +/** + * Usage: node generate_nightly_page.js [ [ []]] + * + * keyfile: + * The key.json file to use for authentication + * outputfile: + * The file where to write the output to + * templatefile: + * The HTML template to use, supports the following placeholders: + * - "{{ title }}" - will be replaced with page title + * - "{{ description }}" - will be replaced with page description + * - "{{ content }}" - will be replaced with page content + * + * Setup: + * npm install pkgcloud + * For NodeJS < 0.10 also + * npm install readable-stream + */ + +//~~ setup + +// imports + +var pkgcloud = require('pkgcloud'), + fs = require('fs'), + path = require('path'), + stream = require('stream'), + util = require('util'); + +// polyfills + +if (!String.prototype.startsWith) { + String.prototype.startsWith = function (str) { + return !this.indexOf(str); + } +} + +if (!String.prototype.endsWith) { + String.prototype.endsWith = function(searchString, position) { + var subjectString = this.toString(); + if (typeof position !== 'number' || !isFinite(position) || Math.floor(position) !== position || position > subjectString.length) { + position = subjectString.length; + } + position -= searchString.length; + var lastIndex = subjectString.indexOf(searchString, position); + return lastIndex !== -1 && lastIndex === position; + }; +} + +//~~ argument parsing + +// key file to use => ./key.json or first command line argument +var keyfile = path.join(__dirname, 'key.json'); +if (process.argv.length >= 3) { + keyfile = process.argv[2]; +} + +// output file => ./index.html or second command line argument +var outputfile = path.join(__dirname, 'index.html'); +if (process.argv.length >= 4) { + outputfile = process.argv[3]; +} + +// template file ==> ./template.html or third command line argument +var templatefile = path.join(__dirname, 'template.html'); +if (process.argv.length >= 5) { + templatefile = process.argv[4]; +} + +//~~ helpers + +var filterByExtension = function(fileObjs, extensions) { + return fileObjs.filter(function (obj) { + var name = obj.name; + return extensions.some(function (extension) { return name.endsWith(extension); }) + }); +} + +var filterByName = function(fileObjs, name) { + return fileObjs.filter(function (obj) { return obj.name.startsWith(name) }); +} + +var filterNameByRegex = function(fileObjs, regex) { + return fileObjs.filter(function (obj) { return regex.test(obj.name) }); +} + +var stripLeading = function(name, toStrip) { + return name.substring(toStrip.length); +} + +var sortByDate = function(a, b) { + if (a.timeCreated < b.timeCreated) return 1; + if (a.timeCreated > b.timeCreated) return -1; + return 0; +} + +var formatDate = function(date) { + return date.replace(/T/, ' ').replace(/\..+/, '') + " UTC"; +} + +var formatSize = function(bytes) { + // Formats the given file size in bytes + if (!bytes) return "-"; + + var units = ["bytes", "KB", "MB"]; + for (var i = 0; i < units.length; i++) { + if (bytes < 1024) { + return bytes.toFixed(1) + units[i]; + } + bytes /= 1024; + } + return bytes.toFixed(1) + "GB"; +} + +var convertHash = function(hash) { + // Converts a hash from base64 to hex + return new Buffer(hash, 'base64').toString('hex'); +} + +var outputTable = function(fileObjs, s, nameProcessor, limit) { + // Outputs an HTML table to for the provided , limiting them to + // and preprocessing the filename with + + limit = limit || 20; + + s.write('\n'); + s.write('\n'); + + // sort by date and limit + fileObjs.sort(sortByDate).slice(0, limit).forEach(function(fileObj) { + console.log("Processing file object: %j", fileObj); + + var url = "https://storage.googleapis.com/octoprint/" + fileObj.name; + var name = nameProcessor(fileObj.name); + + s.write(''); + s.write('"); + s.write('"); + s.write(""); + s.write(""); + s.write("\n"); + }); + + s.write('
NameCreation DateSizeMD5 Hash
' + name + "' + formatDate(fileObj.timeCreated) + "" + formatSize(fileObj.size) + "" + convertHash(fileObj.md5Hash) + "
\n'); +} + +var outputPage = function(files, s) { + // Outputs the page for to stream , using the template. + var title = "OctoPi Downloads"; + var description = "OctoPi Downloads"; + + var Writable = stream.Writable || require('readable-stream').Writable; + function StringStream(options) { + Writable.call(this, options); + this.buffer = ""; + } + util.inherits(StringStream, Writable); + StringStream.prototype._write = function (chunk, enc, cb) { + this.buffer += chunk; + cb(); + }; + + var output = new StringStream(); + + output.write(""); + + output.write("

Raspberry Pi

\n"); + + output.write("

Stable Builds

\n") + outputTable(filterNameByRegex(files, /^stable\/.*octopi-(wheezy|jessie)-.*/), + output, + function(name) { return stripLeading(name, "stable/") }, + 3); + + output.write("

Nightly Builds

\n"); + output.write("Warning: These builds are untested and can be unstable and/or broken. If in doubt use a stable build."); + outputTable(filterNameByRegex(files.filter(function (obj) { return !obj.name.startsWith("stable/") && !obj.name.startsWith("bananapi-m1/") }), /octopi-(wheezy|jessie)-/), + output, + function(name) { return name }, + 14); + + output.write("

Banana Pi M1

\n") + + output.write("

Nightly Builds

\n"); + output.write("Warning: These builds are untested and can be unstable and/or broken."); + outputTable(filterNameByRegex(files, /^bananapi-m1\//), + output, + function(name) { return stripLeading(name, "bananapi-m1/") }, + 14); + + var content = output.buffer; + fs.readFile(templatefile, "utf8", function (err, template) { + var result = template.replace(/{{ content }}/g, content) + .replace(/{{ title }}/g, title) + .replace(/{{ description }}/g, description); + s.write(result); + }) + +} + +//~~ action and go + +// construct client +var client = require('pkgcloud').storage.createClient({ + provider: 'google', + keyFilename: keyfile, // path to a JSON key file +}); +var container = "octoprint"; + +// fetch our files and render our page +client.getFiles(container, function (err, files) { + var stream = fs.createWriteStream(outputfile); + outputPage(filterByExtension(files, [".zip"]), stream); +}); diff --git a/src/nightly_build_scripts/template.html b/src/nightly_build_scripts/template.html new file mode 100644 index 00000000..88989d1b --- /dev/null +++ b/src/nightly_build_scripts/template.html @@ -0,0 +1,76 @@ + + + + + + + + + {{ title }} + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+
+
+ {{ content }} +
+
+
+
+
+ + + + + diff --git a/src/nightly_build_scripts/update_git_mirrors b/src/nightly_build_scripts/update_git_mirrors new file mode 100755 index 00000000..03346a08 --- /dev/null +++ b/src/nightly_build_scripts/update_git_mirrors @@ -0,0 +1,12 @@ +#!/bin/bash +MIRROR_LOCATION=/var/www/git +mkdir $MIRROR_LOCATION +pushd MIRROR_LOCATION + for repo in `ls` + do + pushd $repo + git fetch --prune + git update-server-info + popd + done +popd From 99fe6e5420033e48f714701ea869d78025aabf98 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Mon, 17 Jul 2017 12:33:31 +0300 Subject: [PATCH 173/352] Increment version to 0.15.0 --- src/config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config b/src/config index cfdc67f6..c4de9d26 100644 --- a/src/config +++ b/src/config @@ -1,4 +1,4 @@ export DIST_NAME=OctoPi -export DIST_VERSION=0.14 +export DIST_VERSION=0.15 export MODULES="base(raspicam, network, octopi)" From 59fff611b9d690a4c2bdd5dada4a265ff16a0472 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Mon, 17 Jul 2017 12:40:17 +0300 Subject: [PATCH 174/352] Modify haproxy.cfg to listen on both IPv4 and IPv6, Merge #384 --- src/modules/octopi/filesystem/root/etc/haproxy/haproxy.cfg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/octopi/filesystem/root/etc/haproxy/haproxy.cfg b/src/modules/octopi/filesystem/root/etc/haproxy/haproxy.cfg index f19cbb8e..e20b80c8 100644 --- a/src/modules/octopi/filesystem/root/etc/haproxy/haproxy.cfg +++ b/src/modules/octopi/filesystem/root/etc/haproxy/haproxy.cfg @@ -19,8 +19,8 @@ defaults timeout server 15min frontend public - bind *:80 - bind 0.0.0.0:443 ssl crt /etc/ssl/snakeoil.pem + bind :::80 v4v6 + bind :::443 v4v6 ssl crt /etc/ssl/snakeoil.pem option forwardfor except 127.0.0.1 use_backend webcam if { path_beg /webcam/ } default_backend octoprint From 2e82f256a0c7ee5910d38c2c8685295995e2799d Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Wed, 19 Jul 2017 11:33:40 +0300 Subject: [PATCH 175/352] Fix #389 --- src/build_dist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/build_dist b/src/build_dist index 635f1608..0bb858c1 100755 --- a/src/build_dist +++ b/src/build_dist @@ -5,4 +5,4 @@ export CUSTOM_PI_OS_PATH=$(<${DIR}/custompios_path) export PATH=$PATH:$CUSTOM_PI_OS_PATH echo ${CUSTOM_PI_OS_PATH} -${CUSTOM_PI_OS_PATH}/build_custom_os ${DIST_PATH} +${CUSTOM_PI_OS_PATH}/build_custom_os $@ From c01d0015de733922a119b8c17cca01d23ce410fd Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Wed, 19 Jul 2017 11:43:13 +0300 Subject: [PATCH 176/352] Fix #387 --- src/modules/octopi/start_chroot_script | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/octopi/start_chroot_script b/src/modules/octopi/start_chroot_script index 429b0866..64a100cf 100755 --- a/src/modules/octopi/start_chroot_script +++ b/src/modules/octopi/start_chroot_script @@ -134,7 +134,7 @@ ln -s /etc/custompios_buildbase /etc/octopi_buildbase # allow pi user to run shutdown and service commands echo "pi ALL=NOPASSWD: /sbin/shutdown" > /etc/sudoers.d/octoprint-shutdown -echo "pi ALL=NOPASSWD: /sbin/service" > /etc/sudoers.d/octoprint-service +echo "pi ALL=NOPASSWD: /usr/sbin/service" > /etc/sudoers.d/octoprint-service #make sure users don't run git with sudo, thus breaking permissions, by adding /root/bin to the #default sudo path and placing a git wrapper script there that checks if it's run as root From 02b47e03a77f0baa1c105768500f5dda3104c837 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Wed, 19 Jul 2017 12:03:31 +0300 Subject: [PATCH 177/352] You also need CustomPiOS for Vagrant, see #388 --- README.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 9b6b5b38..c3aaf606 100644 --- a/README.rst +++ b/README.rst @@ -90,10 +90,14 @@ Building Using Vagrant There is a vagrant machine configuration to let build OctoPi in case your build environment behaves differently. Unless you do extra configuration, vagrant must run as root to have nfs folder sync working. To use it:: - + sudo apt-get install vagrant nfs-kernel-server sudo vagrant plugin install vagrant-nfs_guest sudo modprobe nfs + cd ../OctoPi + git clone https://github.com/guysoft/CustomPiOS.git + cd OctoPi/src + ../../CustomPiOS/src/update-custompios-paths cd OctoPi/src/vagrant sudo vagrant up run_vagrant_build.sh From 8555523cbb9101566704bd9d918afad8c9f9a986 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Wed, 19 Jul 2017 12:47:53 +0300 Subject: [PATCH 178/352] Manage ssh from CustomPiOS --- src/modules/octopi/filesystem/boot/ssh | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 src/modules/octopi/filesystem/boot/ssh diff --git a/src/modules/octopi/filesystem/boot/ssh b/src/modules/octopi/filesystem/boot/ssh deleted file mode 100644 index e69de29b..00000000 From d5b342d1aa17b8562e14d360f450d2b36e583f45 Mon Sep 17 00:00:00 2001 From: andreas 'randy' weinberger <30588551+1randy@users.noreply.github.com> Date: Fri, 4 Aug 2017 22:09:14 +0200 Subject: [PATCH 179/352] fix issue #385 --- src/modules/octopi/filesystem/home/pi/scripts/welcome | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/modules/octopi/filesystem/home/pi/scripts/welcome b/src/modules/octopi/filesystem/home/pi/scripts/welcome index 4b674ec9..ec030680 100755 --- a/src/modules/octopi/filesystem/home/pi/scripts/welcome +++ b/src/modules/octopi/filesystem/home/pi/scripts/welcome @@ -1,5 +1,6 @@ #!/bin/bash +_NAME=$(hostname) _IP=$(hostname -I) _OCTOPRINT_VERSION=$(/home/pi/oprint/bin/python -c "from octoprint._version import get_versions; print(get_versions()['version'])" || echo "unknown") _OCTOPI_VERSION=$(cat /etc/octopi_version || echo "unknown") @@ -8,8 +9,11 @@ echo echo "------------------------------------------------------------------------------" echo "Access OctoPrint from a web browser on your network by navigating to any of:" echo -echo " http://octopi.local" +for name in $_NAME; +do + echo " http://$name.local" +done for ip in $_IP; do echo " http://$ip" From 615c5fe580f40d43d33260cf3d58d5a4b6c7406f Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Sat, 5 Aug 2017 23:55:28 +0300 Subject: [PATCH 180/352] Fix header --- src/modules/octopi/start_chroot_script | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/modules/octopi/start_chroot_script b/src/modules/octopi/start_chroot_script index 64a100cf..ef225c82 100755 --- a/src/modules/octopi/start_chroot_script +++ b/src/modules/octopi/start_chroot_script @@ -1,10 +1,11 @@ #!/usr/bin/env bash -set -x -set -e # OctoPI generation script # Helper script that runs in a Raspbian chroot to create the OctoPI distro -# Written by Guy Sheffer +# Written by Guy Sheffer and Gina Häußge # GPL V3 +######## +set -x +set -e export LC_ALL=C From 3101c522a56146eb68bb523fba64c85846213ded Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Sat, 5 Aug 2017 23:57:44 +0300 Subject: [PATCH 181/352] Use disable-services module --- src/config | 2 +- src/modules/octopi/start_chroot_script | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/config b/src/config index c4de9d26..e24491c3 100644 --- a/src/config +++ b/src/config @@ -1,4 +1,4 @@ export DIST_NAME=OctoPi export DIST_VERSION=0.15 -export MODULES="base(raspicam, network, octopi)" +export MODULES="base(raspicam, network, disable-services(octopi))" diff --git a/src/modules/octopi/start_chroot_script b/src/modules/octopi/start_chroot_script index ef225c82..61d79834 100755 --- a/src/modules/octopi/start_chroot_script +++ b/src/modules/octopi/start_chroot_script @@ -12,9 +12,6 @@ export LC_ALL=C source /common.sh ### Script #### -# prevent any installed services from automatically starting (I'm looking at you haproxy) -echo exit 101 > /usr/sbin/policy-rc.d -chmod +x /usr/sbin/policy-rc.d unpack /filesystem/home/pi /home/pi pi unpack /filesystem/home/root /root root @@ -239,5 +236,3 @@ fi apt-get clean apt-get autoremove -y -rm -r /usr/sbin/policy-rc.d - From c3327eade9b7025ee3bf686ff7f59007f194588f Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Sun, 6 Aug 2017 00:10:37 +0300 Subject: [PATCH 182/352] Remove BASE_ varaibles that are stored in the base module --- src/modules/octopi/config | 37 ------------------------------------- 1 file changed, 37 deletions(-) diff --git a/src/modules/octopi/config b/src/modules/octopi/config index d0214211..5a8a737f 100755 --- a/src/modules/octopi/config +++ b/src/modules/octopi/config @@ -1,43 +1,6 @@ ############################################################################### # All our config settings must start with OCTOPI_ -[ -n "$BASE_PRESCRIPT" ] || BASE_PRESCRIPT= -[ -n "$BASE_POSTSCRIPT" ] || BASE_POSTSCRIPT= - -[ -n "$BASE_SCRIPT_PATH" ] || BASE_SCRIPT_PATH=$CONFIG_DIR -[ -n "$BASE_IMAGE_PATH" ] || BASE_IMAGE_PATH=$BASE_SCRIPT_PATH/image -[ -n "$BASE_IMAGE_RASPBIAN" ] || BASE_IMAGE_RASPBIAN=yes - -[ -n "$BASE_IMAGE_ZIP_IMG" ] || BASE_IMAGE_ZIP_IMG=`ls -t $BASE_IMAGE_PATH/*-raspbian*.zip | head -n 1` - -[ -n "$BASE_WORKSPACE" ] || BASE_WORKSPACE=$BASE_SCRIPT_PATH/workspace$WORKSPACE_POSTFIX -[ -n "$BASE_CHROOT_SCRIPT_PATH" ] || BASE_CHROOT_SCRIPT_PATH=$BASE_SCRIPT_PATH/chroot_script -[ -n "$BASE_ROOT_PARTITION" ] || BASE_ROOT_PARTITION=$BASE_WORKSPACE/mount - -# The root partiton of the image filesystem, 2 for raspbian -[ -n "$BASE_ROOT_PARTITION" ] || BASE_ROOT_PARTITION=2 - -# if set will enlarge root parition prior to build by provided size in MB -[ -n "$BASE_IMAGE_ENLARGEROOT" ] || BASE_IMAGE_ENLARGEROOT=400 - -# if set will resize root partition on image after build to minimum size + -# provided size in MB -[ -n "$BASE_IMAGE_RESIZEROOT" ] || BASE_IMAGE_RESIZEROOT=200 - -# a local directory on the build server to bind mount under /var/cache/apt -[ -n "$BASE_APT_CACHE" ] || BASE_APT_CACHE=$BASE_WORKSPACE/aptcache - -# a host:port combo for a apt-proxy (such as apt-cacher-ng) to use -[ -n "$BASE_APT_PROXY" ] || BASE_APT_PROXY= - -# an alternative pypi index url to use, e.g. a proxy such as devpi -[ -n "$BASE_PYPI_INDEX" ] || BASE_PYPI_INDEX= - -[ -n "$BASE_OVERRIDE_HOSTNAME" ] || BASE_OVERRIDE_HOSTNAME=octopi - -# a git mirror to use for git clones instead of original remotes -[ -n "$BASE_BUILD_REPO_MIRROR" ] || BASE_BUILD_REPO_MIRROR= - # OctoPrint repo & branch [ -n "$OCTOPI_OCTOPRINT_REPO_SHIP" ] || OCTOPI_OCTOPRINT_REPO_SHIP=https://github.com/foosel/OctoPrint.git [ -n "$OCTOPI_OCTOPRINT_REPO_BUILD" ] || OCTOPI_OCTOPRINT_REPO_BUILD= From 16e2ac60a4c6bde07cd57359e5546d3175c65ab3 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Sun, 6 Aug 2017 11:33:05 +0300 Subject: [PATCH 183/352] Fixes https://github.com/guysoft/FullPageOS/issues/144 --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index c3aaf606..d095f0eb 100644 --- a/README.rst +++ b/README.rst @@ -70,7 +70,7 @@ You can build it by issuing the following commands:: git clone https://github.com/guysoft/CustomPiOS.git git clone https://github.com/guysoft/OctoPi.git cd OctoPi/src/image - curl -J -O -L http://downloads.raspberrypi.org/raspbian_latest + wget -c --trust-server-names 'https://downloads.raspberrypi.org/raspbian_lite_latest' cd .. ../../CustomPiOS/src/update-custompios-paths sudo modprobe loop From 4584ec1e67fc25b771d107c43ca53c6221fc7886 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Fri, 18 Aug 2017 15:22:34 +0300 Subject: [PATCH 184/352] Add stretch in nightly script --- src/nightly_build_scripts/generate_nightly_page.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/nightly_build_scripts/generate_nightly_page.js b/src/nightly_build_scripts/generate_nightly_page.js index 445f26fc..3e0f5196 100644 --- a/src/nightly_build_scripts/generate_nightly_page.js +++ b/src/nightly_build_scripts/generate_nightly_page.js @@ -167,14 +167,14 @@ var outputPage = function(files, s) { output.write("

Raspberry Pi

\n"); output.write("

Stable Builds

\n") - outputTable(filterNameByRegex(files, /^stable\/.*octopi-(wheezy|jessie)-.*/), + outputTable(filterNameByRegex(files, /^stable\/.*octopi-(wheezy|jessie|stretch)-.*/), output, function(name) { return stripLeading(name, "stable/") }, 3); output.write("

Nightly Builds

\n"); output.write("Warning: These builds are untested and can be unstable and/or broken. If in doubt use a stable build."); - outputTable(filterNameByRegex(files.filter(function (obj) { return !obj.name.startsWith("stable/") && !obj.name.startsWith("bananapi-m1/") }), /octopi-(wheezy|jessie)-/), + outputTable(filterNameByRegex(files.filter(function (obj) { return !obj.name.startsWith("stable/") && !obj.name.startsWith("bananapi-m1/") }), /octopi-(wheezy|jessie|stretch)-/), output, function(name) { return name }, 14); From 9a41cac69cb28058e565d7b30a1d4b7baa306064 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Tue, 26 Sep 2017 13:58:13 +0300 Subject: [PATCH 185/352] Add virtualbox as a provider for vagrant, and vagrnat 1.9+ requirement --- README.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index d095f0eb..f4c2df78 100644 --- a/README.rst +++ b/README.rst @@ -89,9 +89,13 @@ Building Using Vagrant ~~~~~~~~~~~~~~~~~~~~~~ There is a vagrant machine configuration to let build OctoPi in case your build environment behaves differently. Unless you do extra configuration, vagrant must run as root to have nfs folder sync working. +Make sure you have a version of vagrant later than 1.9! + +If you are using older versions of Ubuntu/Debian and not using apt-get `from the download page `_. + To use it:: - sudo apt-get install vagrant nfs-kernel-server + sudo apt-get install vagrant nfs-kernel-server virtualbox sudo vagrant plugin install vagrant-nfs_guest sudo modprobe nfs cd ../OctoPi From 866552fe6408505ac5140e2d4bd066a1376b88e8 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Tue, 26 Sep 2017 16:28:30 +0300 Subject: [PATCH 186/352] Fix error reported in talk here https://github.com/huelvayork/OctoPi/commit/f78e793822f45eb453b9458d03be7b90c2c03256#commitcomment-23625428 --- src/modules/octopi/start_chroot_script | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/octopi/start_chroot_script b/src/modules/octopi/start_chroot_script index 61d79834..b4111519 100755 --- a/src/modules/octopi/start_chroot_script +++ b/src/modules/octopi/start_chroot_script @@ -176,7 +176,7 @@ unpack /filesystem/root / ### setup services ### Disable GUI at start -systemctl_if_exists disable lightdm.service +systemctl_if_exists disable lightdm.service || true update-rc.d change_password defaults update-rc.d change_hostname defaults From e52e702580a458ec01a34bc1eef217770cb12772 Mon Sep 17 00:00:00 2001 From: TheAssassin Date: Wed, 11 Oct 2017 15:44:54 +0200 Subject: [PATCH 187/352] Add missing shebang The script is flagged executable, but due to the missing shebang, only an error message is produced: ``` OctoPi/src (devel)> ./build_dist Failed to execute process './build_dist'. Reason: exec: Exec format error The file './build_dist' is marked as an executable but could not be run by the operating system. ``` --- src/build_dist | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/build_dist b/src/build_dist index 0bb858c1..d64a0acc 100755 --- a/src/build_dist +++ b/src/build_dist @@ -1,3 +1,5 @@ +#! /bin/bash + DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" export DIST_PATH=${DIR} From 37040ab0bdb973ab4c3c891d78144d09ca1e0672 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 16 Oct 2017 09:01:42 +0000 Subject: [PATCH 188/352] README: Add p7zip-full to list of dependencies --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index f4c2df78..ddcbd714 100644 --- a/README.rst +++ b/README.rst @@ -65,7 +65,7 @@ OctoPi can be built from Debian, Ubuntu, Raspbian, or even OctoPi. Build requires about 2.5 GB of free space available. You can build it by issuing the following commands:: - sudo apt-get install gawk util-linux realpath qemu-user-static git + sudo apt-get install gawk util-linux realpath qemu-user-static git p7zip-full git clone https://github.com/guysoft/CustomPiOS.git git clone https://github.com/guysoft/OctoPi.git From af9671635ba424a135131063c1f634fda3671f2e Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Wed, 18 Oct 2017 15:53:32 +0300 Subject: [PATCH 189/352] Add missing p7zip-full --- src/vagrant/setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vagrant/setup.sh b/src/vagrant/setup.sh index 1ae65d5a..71a32b03 100644 --- a/src/vagrant/setup.sh +++ b/src/vagrant/setup.sh @@ -1,4 +1,4 @@ #!/usr/bin/env bash sudo apt-get update -sudo apt-get install -y gawk util-linux realpath git qemu-user-static unzip zip +sudo apt-get install -y gawk util-linux realpath git qemu-user-static p7zip-full unzip zip From 759e274d9647717a3b03d0083cbf714ae7579410 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 23 Oct 2017 14:25:26 +0000 Subject: [PATCH 190/352] Add password-for-sudo to config That way "sudo somecommand" will require entering the user's password again (another password entry for consecutive sudo requests won't be needed in the same session for the next 15min or so). Since OctoPi has always shipped with allowing reboot and such without sudo, even before Raspbian switched over to allowing that for EVERY command, no further action is needed to keep the preconfigured system commands working. --- src/config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config b/src/config index e24491c3..49423c1e 100644 --- a/src/config +++ b/src/config @@ -1,4 +1,4 @@ export DIST_NAME=OctoPi export DIST_VERSION=0.15 -export MODULES="base(raspicam, network, disable-services(octopi))" +export MODULES="base(raspicam, network, disable-services(octopi), password-for-sudo)" From 7ab78c41ce372046da2f966d385c4969de29ed3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 23 Oct 2017 15:48:52 +0000 Subject: [PATCH 191/352] Move gencert from SysVInit to systemd For some reason, no matter what I tried the old SysVInit style init script was no longer starting on boot under Stretch based images. That meant that no cert was generated on initial boot and haproxy could not start due to the missing SSL cert as also mentioned in #402 Switching it to a simple systemd oneshot service solved the issue. --- .../octopi/filesystem/home/root/bin/gencert | 11 +++++ .../octopi/filesystem/root/etc/init.d/gencert | 41 ------------------- .../root/etc/systemd/system/gencert.service | 17 ++++++++ src/modules/octopi/start_chroot_script | 4 +- 4 files changed, 30 insertions(+), 43 deletions(-) create mode 100755 src/modules/octopi/filesystem/home/root/bin/gencert delete mode 100755 src/modules/octopi/filesystem/root/etc/init.d/gencert create mode 100644 src/modules/octopi/filesystem/root/etc/systemd/system/gencert.service diff --git a/src/modules/octopi/filesystem/home/root/bin/gencert b/src/modules/octopi/filesystem/home/root/bin/gencert new file mode 100755 index 00000000..9145677f --- /dev/null +++ b/src/modules/octopi/filesystem/home/root/bin/gencert @@ -0,0 +1,11 @@ +#!/bin/sh + +keyfile=/etc/ssl/private/ssl-cert-snakeoil.key +pemfile=/etc/ssl/certs/ssl-cert-snakeoil.pem +certfile=/etc/ssl/snakeoil.pem + +if [ ! -f $keyfile ] || [ ! -s $keyfile ] || [ ! -f $pemfile ] || [ ! -s $pemfile ] || [ ! -f $certfile ] || [ ! -s $certfile ]; then + echo "Generating SSL certificate" + sudo make-ssl-cert generate-default-snakeoil --force-overwrite + sudo cat $keyfile $pemfile > $certfile +fi \ No newline at end of file diff --git a/src/modules/octopi/filesystem/root/etc/init.d/gencert b/src/modules/octopi/filesystem/root/etc/init.d/gencert deleted file mode 100755 index 03d3cc71..00000000 --- a/src/modules/octopi/filesystem/root/etc/init.d/gencert +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/sh -### BEGIN INIT INFO -# Provides: gencert -# Required-Start: $local_fs -# Required-Stop: -# Default-Start: S -# Default-Stop: -# Short-Description: Make sure an SSL certificate is generated for haproxy on first boot -# Description: -### END INIT INFO - -. /lib/lsb/init-functions - -do_start () { - keyfile=/etc/ssl/private/ssl-cert-snakeoil.key - pemfile=/etc/ssl/certs/ssl-cert-snakeoil.pem - certfile=/etc/ssl/snakeoil.pem - - if [ ! -f $keyfile ] || [ ! -s $keyfile ] || [ ! -f $pemfile ] || [ ! -s $pemfile ] || [ ! -f $certfile ] || [ ! -s $certfile ]; then - echo "Generating SSL certificate" - sudo make-ssl-cert generate-default-snakeoil --force-overwrite - sudo cat $keyfile $pemfile > $certfile - fi -} - -case "$1" in - start|"") - do_start - ;; - restart|reload|force-reload) - echo "Error: argument '$1' not supported" >&2 - exit 3 - ;; - stop) - # No-op - ;; - *) - echo "Usage: gencert [start|stop]" >&2 - exit 3 - ;; -esac diff --git a/src/modules/octopi/filesystem/root/etc/systemd/system/gencert.service b/src/modules/octopi/filesystem/root/etc/systemd/system/gencert.service new file mode 100644 index 00000000..c22b6ffa --- /dev/null +++ b/src/modules/octopi/filesystem/root/etc/systemd/system/gencert.service @@ -0,0 +1,17 @@ +[Unit] +Description=Ensure that haproxy certs are generated + +DefaultDependencies=no + +Before=network-pre.target +Wants=network-pre.target + +After=local-fs.target +Wants=local-fs.target + +[Service] +Type=oneshot +ExecStart=/root/bin/gencert + +[Install] +WantedBy=multi-user.target diff --git a/src/modules/octopi/start_chroot_script b/src/modules/octopi/start_chroot_script index b4111519..0f2e0cc3 100755 --- a/src/modules/octopi/start_chroot_script +++ b/src/modules/octopi/start_chroot_script @@ -201,10 +201,10 @@ fi if [ "$OCTOPI_INCLUDE_HAPROXY" == "yes" ] then - update-rc.d gencert defaults + systemctl_if_exists enable gencert.service else # let's remove the configs for system services we don't need - rm /etc/init.d/gencert + rm /etc/systemd/system/gencert.service # also we need to make OctoPrint bind to all interfaces because otherwise # it will be unaccessible... From 43db6ab5c136abf342d18b61669a1f0466227e73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Thu, 29 Jun 2017 13:44:40 +0200 Subject: [PATCH 192/352] Add instructions on how to remove git wrapper Some users run into issues with the git wrapper preventing usage as root when trying to install third party software on OctoPi that for some reason requires to run git as root. See comments to #114 and #373. This adds a small message to the output generated by the wrapper script to explain to people how to remove the wrapper in order to allow for that kind of usage of git. --- src/modules/octopi/filesystem/home/root/bin/git | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/modules/octopi/filesystem/home/root/bin/git b/src/modules/octopi/filesystem/home/root/bin/git index 31f499d5..d10f25c0 100644 --- a/src/modules/octopi/filesystem/home/root/bin/git +++ b/src/modules/octopi/filesystem/home/root/bin/git @@ -2,8 +2,15 @@ if [ "$(id -u)" == "0" ] then - echo "Please run git without sudo, your regular user account is enough :)" 2>&1 + echo "Please do not run git as root, your regular user account is enough :)" + echo + echo "If you need to run git with root rights for some other application than" + echo "what comes preinstalled on this image you can remove this sanity check:" + echo + echo " sudo rm /root/bin/git" + echo + echo "You might have to restart your login session after doing that." exit 1 fi -/usr/bin/git "$@" \ No newline at end of file +/usr/bin/git "$@" From 8a51d6686d2b6604137814e3bb37e3ccb74c6a75 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Mon, 30 Oct 2017 11:11:22 +0200 Subject: [PATCH 193/352] Change permissions --- src/config | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 src/config diff --git a/src/config b/src/config old mode 100644 new mode 100755 From dfeb3d1d744b37f5196bc218d4373f4bb3f067cb Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Tue, 31 Oct 2017 18:03:11 +0200 Subject: [PATCH 194/352] Add workaround and logging to ssh key generation, fixes #424 --- src/modules/octopi/start_chroot_script | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/modules/octopi/start_chroot_script b/src/modules/octopi/start_chroot_script index 0f2e0cc3..e25bbb08 100755 --- a/src/modules/octopi/start_chroot_script +++ b/src/modules/octopi/start_chroot_script @@ -186,6 +186,12 @@ systemctl_if_exists enable check_wpa_link.service ### Fix SSH echo "IPQoS 0x00" >> /etc/ssh/sshd_config + +### Try and fix https://github.com/guysoft/OctoPi/issues/424 + +sed -i "s@ExecStart=/usr/bin/ssh-keygen -A -v@ExecStart=/bin/bash -c ' /usr/bin/ssh-keygen -A -v >> /var/log/regenerate_ssh_host_keys.log 2>\&1'@g" /lib/systemd/system/regenerate_ssh_host_keys.service +sed -i "s@ExecStartPost=/bin/systemctl disable regenerate_ssh_host_keys@ExecStartPost=/bin/bash -c 'for i in /etc/ssh/ssh_host_*_key*; do actualsize=\$(wc -c <\"\$i\") ;if [ \$actualsize -eq 0 ]; then echo size is 0 bytes ; exit 1 ; fi ; done ; /bin/systemctl disable regenerate_ssh_host_keys'@g" /lib/systemd/system/regenerate_ssh_host_keys.service + ### OctoPrint if [ "$OCTOPI_INCLUDE_OCTOPRINT" == "yes" ] From 36af82350c20e69543bf3467c12fa188f08ad577 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Wed, 1 Nov 2017 11:34:12 +0200 Subject: [PATCH 195/352] Remove obsolete version file --- src/modules/octopi/filesystem/root/etc/octopi_version | 1 - 1 file changed, 1 deletion(-) delete mode 100644 src/modules/octopi/filesystem/root/etc/octopi_version diff --git a/src/modules/octopi/filesystem/root/etc/octopi_version b/src/modules/octopi/filesystem/root/etc/octopi_version deleted file mode 100644 index a803cc22..00000000 --- a/src/modules/octopi/filesystem/root/etc/octopi_version +++ /dev/null @@ -1 +0,0 @@ -0.14.0 From 775f9b8078623bf8cb41891a61cedef57a8a5d58 Mon Sep 17 00:00:00 2001 From: Eyal Date: Wed, 29 Nov 2017 12:41:49 +0200 Subject: [PATCH 196/352] Add GEMBIRD webcam to list of brokenfps_usb_devices The GEMBIRD webcam is brokenfps. Adding the webcam's usb id to the list allows the webcam to work. Here's the device's USB: Bus 001 Device 005: ID 1908:2310 GEMBIRD This is the camera: https://ae01.alicdn.com/kf/HTB1OlilPpXXXXbWaXXXq6xXFXXXW/Newest-Webcam-USB-12-Megapixel-High-Definition-Camera-Web-Cam-360-Degree-MIC-Clip-on-For.jpg Here's where I bought it: https://www.aliexpress.com/store/product/FW1S-USB-2-0-Webcam-12-0-Mega-Pixel-HD-Camera-Webcam-360-Degree-MIC-Clip/1283494_32659656232.html --- src/modules/octopi/filesystem/home/root/bin/webcamd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/octopi/filesystem/home/root/bin/webcamd b/src/modules/octopi/filesystem/home/root/bin/webcamd index ca23d919..a7cb75ac 100755 --- a/src/modules/octopi/filesystem/home/root/bin/webcamd +++ b/src/modules/octopi/filesystem/home/root/bin/webcamd @@ -27,7 +27,7 @@ if [ -e "/boot/octopi.txt" ]; then source "/boot/octopi.txt" fi -brokenfps_usb_devices=("046d:082b" "${additional_brokenfps_usb_devices[@]}") +brokenfps_usb_devices=("046d:082b" "1908:2310" "${additional_brokenfps_usb_devices[@]}") # cleans up when the script receives a SIGINT or SIGTERM function cleanup() { From 83d0e0da623cb7c43148ea3e316bc79359e6f180 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Tue, 26 Dec 2017 10:47:49 +0200 Subject: [PATCH 197/352] Fixes #449 --- src/modules/octopi/filesystem/boot/octopi.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/octopi/filesystem/boot/octopi.txt b/src/modules/octopi/filesystem/boot/octopi.txt index 149ed2ad..2f8c1e39 100644 --- a/src/modules/octopi/filesystem/boot/octopi.txt +++ b/src/modules/octopi/filesystem/boot/octopi.txt @@ -39,7 +39,7 @@ # If this fixes your problem, please report it back so we can include the device # out of the box. # -#additional_brokenfps_usb_devices=("046d:082b" "aabb:ccdd") +#additional_brokenfps_usb_devices=("046d:082b" "1908:2310" "aabb:ccdd") ### Additional options to supply to MJPG Streamer for the RasPi Cam # From bc762d753c7b17503d445c65d44749514a102625 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Wed, 24 Jan 2018 16:29:37 +0200 Subject: [PATCH 198/352] Fixes #460 documintation bug --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index ddcbd714..3646f521 100644 --- a/README.rst +++ b/README.rst @@ -65,7 +65,7 @@ OctoPi can be built from Debian, Ubuntu, Raspbian, or even OctoPi. Build requires about 2.5 GB of free space available. You can build it by issuing the following commands:: - sudo apt-get install gawk util-linux realpath qemu-user-static git p7zip-full + sudo apt-get install gawk util-linux realpath qemu-user-static git p7zip-full python3 git clone https://github.com/guysoft/CustomPiOS.git git clone https://github.com/guysoft/OctoPi.git From 303a751c2f99c1c14baf321cff725d5cd43d7c4d Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Sun, 28 Jan 2018 18:38:52 +0200 Subject: [PATCH 199/352] Fixes #466 , moved to debian/stretch64 on vagrant, update your VMs --- src/vagrant/Vagrantfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vagrant/Vagrantfile b/src/vagrant/Vagrantfile index a2d0438e..a4567d95 100644 --- a/src/vagrant/Vagrantfile +++ b/src/vagrant/Vagrantfile @@ -1,7 +1,7 @@ vagrant_root = File.dirname(__FILE__) Vagrant.configure("2") do |o| # o.vm.box = "octopi-build" - o.vm.box= "ubuntu/zesty64" + o.vm.box= "debian/stretch64" o.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'" o.vm.synced_folder File.read("../custompios_path").gsub("\n",""), "/CustomPiOS", create:true, type: "nfs" o.vm.synced_folder "../", "/distro", create:true, type: "nfs" From 20bfbf2f42e0bc19a0fa14702427023990989d64 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Wed, 7 Feb 2018 13:18:38 +0200 Subject: [PATCH 200/352] Fixes #469 --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 3646f521..f6ffd49e 100644 --- a/README.rst +++ b/README.rst @@ -79,7 +79,7 @@ You can build it by issuing the following commands:: Building OctoPi Variants ~~~~~~~~~~~~~~~~~~~~~~~~ -OctoPi supports building variants, which are builds with changes from the main release build. An example and other variants are available in the folder ``src/variants/example``. +OctoPi supports building variants, which are builds with changes from the main release build. An example and other variants are available in [CustomPiOS, folder ``src/variants/example``](https://github.com/guysoft/CustomPiOS/tree/CustomPiOS/src/variants/example). To build a variant use:: From 98bf292894e03548eaff426d171e4b8083ce5f8f Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Tue, 13 Feb 2018 12:43:12 +0200 Subject: [PATCH 201/352] Fixes #410 --- src/modules/octopi/start_chroot_script | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/modules/octopi/start_chroot_script b/src/modules/octopi/start_chroot_script index e25bbb08..b8382ecd 100755 --- a/src/modules/octopi/start_chroot_script +++ b/src/modules/octopi/start_chroot_script @@ -140,6 +140,7 @@ sed -i "s@secure_path=\"@secure_path=\"/root/bin:@g" /etc/sudoers chmod +x /root/bin/git # add some "How To" info to boot output +# Note, this code is also in /filesystem/home/pi/scripts/ sed -i 's@exit 0@@' /etc/rc.local cat <<'EOT' >> /etc/rc.local @@ -150,7 +151,10 @@ echo "You may now open a web browser on your local network and " echo "navigate to any of the following addresses to access " echo "OctoPrint:" echo -echo " http://octopi.local" +for name in $_NAME; +do + echo " http://$name.local" +done for ip in $(hostname -I); do From 62849e849740004eb3799131adcbbd55de0b370f Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Sat, 17 Feb 2018 12:47:20 +0200 Subject: [PATCH 202/352] Fixes #480 --- src/modules/octopi/filesystem/boot/octopi.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/octopi/filesystem/boot/octopi.txt b/src/modules/octopi/filesystem/boot/octopi.txt index 2f8c1e39..2909cbb0 100644 --- a/src/modules/octopi/filesystem/boot/octopi.txt +++ b/src/modules/octopi/filesystem/boot/octopi.txt @@ -39,7 +39,7 @@ # If this fixes your problem, please report it back so we can include the device # out of the box. # -#additional_brokenfps_usb_devices=("046d:082b" "1908:2310" "aabb:ccdd") +#additional_brokenfps_usb_devices=("046d:082b" "1908:2310" "1e4e:0102" "aabb:ccdd") ### Additional options to supply to MJPG Streamer for the RasPi Cam # From 4a14f51482f9c37ce78557a16e4439f41966ca72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 19 Feb 2018 15:31:23 +0000 Subject: [PATCH 203/352] Install OctoPrint from network via pip OctoPrint 1.3.6+ no longer relies on git for updating itself, so there's really no use to ship with a full blown git checkout any more. In case people miss that however, there's a README.txt in place that tells people how to get it back if they do need it. --- src/modules/octopi/config | 8 ++++--- .../filesystem/home/pi/.octoprint/config.yaml | 4 ---- src/modules/octopi/start_chroot_script | 21 ++++++++++++++----- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/modules/octopi/config b/src/modules/octopi/config index 5a8a737f..04efea81 100755 --- a/src/modules/octopi/config +++ b/src/modules/octopi/config @@ -1,12 +1,14 @@ ############################################################################### # All our config settings must start with OCTOPI_ -# OctoPrint repo & branch +# OctoPrint archive +[ -n "$OCTOPI_OCTOPRINT_ARCHIVE" ] || OCTOPI_OCTOPRINT_ARCHIVE=$(curl -s https://api.github.com/repos/foosel/OctoPrint/releases/latest | grep "zipball_url" | cut -d : -f 2,3 | tr -d \" | tr -d ,) [ -n "$OCTOPI_OCTOPRINT_REPO_SHIP" ] || OCTOPI_OCTOPRINT_REPO_SHIP=https://github.com/foosel/OctoPrint.git -[ -n "$OCTOPI_OCTOPRINT_REPO_BUILD" ] || OCTOPI_OCTOPRINT_REPO_BUILD= -[ -n "$OCTOPI_OCTOPRINT_REPO_BRANCH" ] || OCTOPI_OCTOPRINT_REPO_BRANCH=master [ -n "$OCTOPI_INCLUDE_OCTOPRINT" ] || OCTOPI_INCLUDE_OCTOPRINT=yes +# PyBonjour archive +[ -n "$OCTOPI_PYBONJOUR_ARCHIVE" ] || OCTOPI_PYBONJOUR_ARCHIVE=https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/pybonjour/pybonjour-1.1.1.tar.gz + # CuraEngine archive & version [ -n "$OCTOPI_CURAENGINE_VERSION" ] || OCTOPI_CURAENGINE_VERSION=15.04.6 [ -n "$OCTOPI_CURAENGINE_ARCHIVE" ] || OCTOPI_CURAENGINE_ARCHIVE=https://github.com/Ultimaker/CuraEngine/archive/$OCTOPI_CURAENGINE_VERSION.zip diff --git a/src/modules/octopi/filesystem/home/pi/.octoprint/config.yaml b/src/modules/octopi/filesystem/home/pi/.octoprint/config.yaml index 1089900c..88361e3e 100644 --- a/src/modules/octopi/filesystem/home/pi/.octoprint/config.yaml +++ b/src/modules/octopi/filesystem/home/pi/.octoprint/config.yaml @@ -7,10 +7,6 @@ plugins: cura_engine: /usr/local/bin/cura_engine discovery: publicPort: 80 - softwareupdate: - checks: - octoprint: - update_folder: /home/pi/OctoPrint server: commands: systemShutdownCommand: sudo shutdown -h now diff --git a/src/modules/octopi/start_chroot_script b/src/modules/octopi/start_chroot_script index b8382ecd..88b1e650 100755 --- a/src/modules/octopi/start_chroot_script +++ b/src/modules/octopi/start_chroot_script @@ -44,13 +44,24 @@ pushd /home/pi echo "--- Installing OctoPrint" #pybonjour (for mdns discovery) - sudo -u pi /home/pi/oprint/bin/pip install https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/pybonjour/pybonjour-1.1.1.tar.gz + sudo -u pi /home/pi/oprint/bin/pip install $OCTOPI_PYBONJOUR_ARCHIVE #OctoPrint - gitclone OCTOPI_OCTOPRINT_REPO OctoPrint - pushd OctoPrint - PIP_DEFAULT_TIMEOUT=60 sudo -u pi /home/pi/oprint/bin/python setup.py install - popd + PIP_DEFAULT_TIMEOUT=60 sudo -u pi /home/pi/oprint/bin/pip install $OCTOPI_OCTOPRINT_ARCHIVE + + #"redirect" for people still expecting a source checkout at ~/OctoPrint... + sudo -u pi mkdir OctoPrint + cat <> OctoPrint/README.txt +OctoPrint 1.3.6 and newer no longer rely on a git checkout for updates, +so OctoPi no longer goes that route either. + +Feel free to manually create a git clone though if you need it (e.g. for +branch based updates or on board development): + + cd ~ + rm -r OctoPrint + git clone $OCTOPI_OCTOPRINT_REPO_SHIP +EOT fi #mjpg-streamer From 0a3e43495199dbf5bcdbe6ac73d2ea8847a7c16f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 19 Feb 2018 15:23:20 +0000 Subject: [PATCH 204/352] Add "redirect" for octopi-network.txt If a user follows some outdated docs after the release of 0.15, we still want them to find something that helps them get things running. --- src/modules/octopi/filesystem/boot/octopi-network.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 src/modules/octopi/filesystem/boot/octopi-network.txt diff --git a/src/modules/octopi/filesystem/boot/octopi-network.txt b/src/modules/octopi/filesystem/boot/octopi-network.txt new file mode 100644 index 00000000..85c4c0b1 --- /dev/null +++ b/src/modules/octopi/filesystem/boot/octopi-network.txt @@ -0,0 +1,3 @@ +# Using this file to configure your network connection is no longer supported. +# +# Please use octopi-wpa-supplicant.txt instead. From 999a2469ffe51b9fa2ff2bb5de05d26cf564074b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 19 Feb 2018 17:50:02 +0000 Subject: [PATCH 205/352] Warning about text editors in octopi.txt Followup to #441 --- src/modules/octopi/filesystem/boot/octopi.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/modules/octopi/filesystem/boot/octopi.txt b/src/modules/octopi/filesystem/boot/octopi.txt index 2909cbb0..9440cd50 100644 --- a/src/modules/octopi/filesystem/boot/octopi.txt +++ b/src/modules/octopi/filesystem/boot/octopi.txt @@ -1,3 +1,9 @@ +### Windows users: To edit this file use Notepad++, VSCode, Atom or SublimeText. +### Do not use Notepad or WordPad. + +### MacOSX users: If you use Textedit to edit this file make sure to use +### "plain text format" and "disable smart quotes" in "Textedit > Preferences" + ### Configure which camera to use # # Available options are: From 7c8ad04770a7356e4d1d8d474e38a1e9245f4295 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 20 Feb 2018 08:56:21 +0000 Subject: [PATCH 206/352] Add script to add git checkout & update folder in config.yaml For the latter we also add yq to the image. Might also be useful for other tasks. --- src/modules/octopi/config | 2 + .../filesystem/home/pi/OctoPrint/README.txt | 7 +++ .../home/pi/scripts/add-octoprint-checkout | 43 +++++++++++++++++++ src/modules/octopi/start_chroot_script | 17 ++------ 4 files changed, 55 insertions(+), 14 deletions(-) create mode 100644 src/modules/octopi/filesystem/home/pi/OctoPrint/README.txt create mode 100755 src/modules/octopi/filesystem/home/pi/scripts/add-octoprint-checkout diff --git a/src/modules/octopi/config b/src/modules/octopi/config index 04efea81..12544a69 100755 --- a/src/modules/octopi/config +++ b/src/modules/octopi/config @@ -27,3 +27,5 @@ # WiringPi [ -n "$OCTOPI_INCLUDE_WIRINGPI" ] || OCTOPI_INCLUDE_WIRINGPI=yes +# yq +[ -n "$OCTOPI_YQ_DOWNLOAD" ] || OCTOPI_YQ_DOWNLOAD=$(curl -s https://api.github.com/repos/mikefarah/yq/releases/latest | grep "browser_download_url" | grep "yq_linux_arm" | cut -d : -f 2,3 | tr -d \" | tr -d ,) diff --git a/src/modules/octopi/filesystem/home/pi/OctoPrint/README.txt b/src/modules/octopi/filesystem/home/pi/OctoPrint/README.txt new file mode 100644 index 00000000..4214bd8f --- /dev/null +++ b/src/modules/octopi/filesystem/home/pi/OctoPrint/README.txt @@ -0,0 +1,7 @@ +OctoPrint 1.3.6 and newer no longer rely on a git checkout for updates, +so OctoPi no longer goes that route either. + +Feel free to manually create a git clone though if you need it (e.g. for +branch based updates or on board development): + + ~/scripts/add-octoprint-checkout diff --git a/src/modules/octopi/filesystem/home/pi/scripts/add-octoprint-checkout b/src/modules/octopi/filesystem/home/pi/scripts/add-octoprint-checkout new file mode 100755 index 00000000..615a2d92 --- /dev/null +++ b/src/modules/octopi/filesystem/home/pi/scripts/add-octoprint-checkout @@ -0,0 +1,43 @@ +#!/bin/bash + +OCTOPRINT_FOLDER=/home/pi/OctoPrint +OCTOPRINT_CONFIG=/home/pi/.octoprint/config.yaml + +pause() { + read -n1 -r -p $'Press any key to continue or Ctrl+C to exit...\n' key +} + +echo +echo "This will add a git checkout of OctoPrint to ~/OctoPrint." +echo +echo "This can be helpful if you want to run development branches" +echo "of OctoPrint or do local development yourself." +echo +echo "It is however not needed for OctoPrint's normal operation." +echo +echo "If you do not want to add the git checkout after all, please" +echo "hit Ctrl+C now." +echo + +pause + +echo "--- Adding git checkout" + +rm -r $OCTOPRINT_FOLDER || true +git clone https://github.com/foosel/OctoPrint.git $OCTOPRINT_FOLDER + +echo "--- Configuring checkout folder in OctoPrint's config.yaml" + +echo "plugins: {softwareupdate: {checks: {octoprint: {update_folder: $OCTOPRINT_FOLDER}}}}" | yq m -i $OCTOPRINT_CONFIG - + +echo +echo "--- Done!" +echo + +echo "Your git checkout is now available at ~/OctoPrint. Please note that it" +echo "is currently not installed. If you want to replace the default installation" +echo "of OctoPrint with whatever is currently checked out in your git checkout" +echo "you'll need to do this manually. You'll also need to keep your checkout" +echo "up to date manually if you still have OctoPrint's update mode set to release" +echo "tracking." +echo diff --git a/src/modules/octopi/start_chroot_script b/src/modules/octopi/start_chroot_script index 88b1e650..a5f37f9b 100755 --- a/src/modules/octopi/start_chroot_script +++ b/src/modules/octopi/start_chroot_script @@ -48,20 +48,6 @@ pushd /home/pi #OctoPrint PIP_DEFAULT_TIMEOUT=60 sudo -u pi /home/pi/oprint/bin/pip install $OCTOPI_OCTOPRINT_ARCHIVE - - #"redirect" for people still expecting a source checkout at ~/OctoPrint... - sudo -u pi mkdir OctoPrint - cat <> OctoPrint/README.txt -OctoPrint 1.3.6 and newer no longer rely on a git checkout for updates, -so OctoPi no longer goes that route either. - -Feel free to manually create a git clone though if you need it (e.g. for -branch based updates or on board development): - - cd ~ - rm -r OctoPrint - git clone $OCTOPI_OCTOPRINT_REPO_SHIP -EOT fi #mjpg-streamer @@ -128,6 +114,9 @@ EOT echo "--- Installing WiringPi" apt-get install wiringpi fi + + # fetch current yq build and install to /usr/local/bin + wget -O yq $OCTOPI_YQ_DOWNLOAD && chmod +x yq && mv yq /usr/local/bin popd From 3c959671276705358e0761851bee1a47f95368da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Wed, 21 Feb 2018 17:31:24 +0100 Subject: [PATCH 207/352] Back to MAJOR.MINOR.PATCH version scheme We so far followed MAJOR.MINOR.PATCH as version scheme. I suggest we stay there to not confuse people ("why does 0.15 follow 0.14.0?"). --- src/config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config b/src/config index 49423c1e..05352183 100755 --- a/src/config +++ b/src/config @@ -1,4 +1,4 @@ export DIST_NAME=OctoPi -export DIST_VERSION=0.15 +export DIST_VERSION=0.15.0 export MODULES="base(raspicam, network, disable-services(octopi), password-for-sudo)" From 4fc1d1f9f2a6000daafce544b81fd79dacdaeb05 Mon Sep 17 00:00:00 2001 From: Lauri Hakkarainen Date: Thu, 22 Feb 2018 22:19:31 +0100 Subject: [PATCH 208/352] Checking for multiple usb webcams instead of /dev/video0 --- src/modules/octopi/filesystem/home/root/bin/webcamd | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/modules/octopi/filesystem/home/root/bin/webcamd b/src/modules/octopi/filesystem/home/root/bin/webcamd index a7cb75ac..702d6a40 100755 --- a/src/modules/octopi/filesystem/home/root/bin/webcamd +++ b/src/modules/octopi/filesystem/home/root/bin/webcamd @@ -65,7 +65,7 @@ function startRaspi { function startUsb { options="$camera_usb_options" device="video0" - + extracted_device=`echo $options | sed 's@.*-d /dev/\(video[0-9]+\).*@\1@'` if [ "$extracted_device" != "$options" ] then @@ -79,7 +79,7 @@ function startUsb { product=`cat $uevent_file | grep PRODUCT | cut -d"=" -f2` vid=`echo $product | cut -d"/" -f1` pid=`echo $product | cut -d"/" -f2` - vidpid=`printf "%04x:%04x" "0x$vid" "0x$pid"` + vidpid=`printf "%04x:%04x" "0x$vid" "0x$pid"` # ... then look if it is in our list of known broken-fps-devices and if so remove # the -f parameter from the options (if it's in there, else that's just a no-op) @@ -120,7 +120,9 @@ vcgencmd version > /dev/null 2>&1 # keep mjpg streamer running if some camera is attached while true; do - if [ -e "/dev/video0" ] && { [ "$camera" = "auto" ] || [ "$camera" = "usb" ] ; }; then + # get number of usb video devices + video_device_count = $(ls /dev/video? 2> /dev/null | wc -l) + if [ "$video_device_count" != "0" ] && { [ "$camera" = "auto" ] || [ "$camera" = "usb" ] ; }; then startUsb sleep 30 & wait From e521351a111f217b6eefb070cc79f5f6883f49b3 Mon Sep 17 00:00:00 2001 From: Lauri Hakkarainen Date: Fri, 23 Feb 2018 15:47:01 +0100 Subject: [PATCH 209/352] Fixed white space to fix setting the video_device_count variable --- src/modules/octopi/filesystem/home/root/bin/webcamd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/octopi/filesystem/home/root/bin/webcamd b/src/modules/octopi/filesystem/home/root/bin/webcamd index 702d6a40..e11da35c 100755 --- a/src/modules/octopi/filesystem/home/root/bin/webcamd +++ b/src/modules/octopi/filesystem/home/root/bin/webcamd @@ -121,7 +121,7 @@ vcgencmd version > /dev/null 2>&1 # keep mjpg streamer running if some camera is attached while true; do # get number of usb video devices - video_device_count = $(ls /dev/video? 2> /dev/null | wc -l) + video_device_count=$(ls /dev/video? 2> /dev/null | wc -l) if [ "$video_device_count" != "0" ] && { [ "$camera" = "auto" ] || [ "$camera" = "usb" ] ; }; then startUsb sleep 30 & From 6a7d988390059b4a279b12de0c2f85ff7ad6676d Mon Sep 17 00:00:00 2001 From: Lauri Hakkarainen Date: Sun, 25 Feb 2018 22:51:07 +0100 Subject: [PATCH 210/352] Support for other webcams than /dev/video0, fixed a regular expression --- .../octopi/filesystem/home/root/bin/webcamd | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/modules/octopi/filesystem/home/root/bin/webcamd b/src/modules/octopi/filesystem/home/root/bin/webcamd index e11da35c..1f755ab1 100755 --- a/src/modules/octopi/filesystem/home/root/bin/webcamd +++ b/src/modules/octopi/filesystem/home/root/bin/webcamd @@ -66,11 +66,21 @@ function startUsb { options="$camera_usb_options" device="video0" - extracted_device=`echo $options | sed 's@.*-d /dev/\(video[0-9]+\).*@\1@'` + # check for parameter and set the device if it is given as a parameter + input=$1 + if [[ -n $input ]]; then + device=`basename "$input"` + fi + + # override the device if it is set in the config + extracted_device=`echo $options | sed 's@.*-d /dev/\(video[0-9]\+\).*@\1@'` if [ "$extracted_device" != "$options" ] then - # the camera options refer to another device, use that for determining product + # the camera options refer to a device, use that for determining product device=$extracted_device + else + # there was no device explicitly set in the options, let's add it there + options="$options -d /dev/$device" fi uevent_file="/sys/class/video4linux/$device/device/uevent" @@ -120,10 +130,11 @@ vcgencmd version > /dev/null 2>&1 # keep mjpg streamer running if some camera is attached while true; do - # get number of usb video devices - video_device_count=$(ls /dev/video? 2> /dev/null | wc -l) - if [ "$video_device_count" != "0" ] && { [ "$camera" = "auto" ] || [ "$camera" = "usb" ] ; }; then - startUsb + # get list of usb video devices into an array + video_devices=($(ls /dev/video? 2> /dev/null)) + if [ ${#video_devices[@]} != 0 ] && { [ "$camera" = "auto" ] || [ "$camera" = "usb" ] ; }; then + #start with first usb camera as the parameter + startUsb "${video_devices[0]}" sleep 30 & wait elif [ "`vcgencmd get_camera`" = "supported=1 detected=1" ] && { [ "$camera" = "auto" ] || [ "$camera" = "raspi" ] ; }; then From d03534b62d9a57af08854c3eb6f42f69952ac8e7 Mon Sep 17 00:00:00 2001 From: Jens Lindgren Date: Mon, 26 Feb 2018 00:15:27 +0100 Subject: [PATCH 211/352] add genius f100 to brokenfps --- src/modules/octopi/filesystem/home/root/bin/webcamd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/octopi/filesystem/home/root/bin/webcamd b/src/modules/octopi/filesystem/home/root/bin/webcamd index e11da35c..00f078f6 100755 --- a/src/modules/octopi/filesystem/home/root/bin/webcamd +++ b/src/modules/octopi/filesystem/home/root/bin/webcamd @@ -27,7 +27,7 @@ if [ -e "/boot/octopi.txt" ]; then source "/boot/octopi.txt" fi -brokenfps_usb_devices=("046d:082b" "1908:2310" "${additional_brokenfps_usb_devices[@]}") +brokenfps_usb_devices=("046d:082b" "1908:2310" "0458:708c" "${additional_brokenfps_usb_devices[@]}") # cleans up when the script receives a SIGINT or SIGTERM function cleanup() { From 5cf9c68a1906c7c83293164d748b3281513e20bf Mon Sep 17 00:00:00 2001 From: Lauri Hakkarainen Date: Mon, 26 Feb 2018 18:43:39 +0100 Subject: [PATCH 212/352] Webcam device is not overridden by config anymore --- .../octopi/filesystem/home/root/bin/webcamd | 65 +++++++++++++++---- 1 file changed, 51 insertions(+), 14 deletions(-) diff --git a/src/modules/octopi/filesystem/home/root/bin/webcamd b/src/modules/octopi/filesystem/home/root/bin/webcamd index 1f755ab1..3a7021b7 100755 --- a/src/modules/octopi/filesystem/home/root/bin/webcamd +++ b/src/modules/octopi/filesystem/home/root/bin/webcamd @@ -29,6 +29,14 @@ fi brokenfps_usb_devices=("046d:082b" "1908:2310" "${additional_brokenfps_usb_devices[@]}") +# check if array contains a string +function containsString() { + local e match="$1" + shift + for e; do [[ "$e" == "$match" ]] && return 0; done + return 1 +} + # cleans up when the script receives a SIGINT or SIGTERM function cleanup() { # make sure that all child processed die when we die @@ -63,7 +71,7 @@ function startRaspi { # starts up the USB webcam function startUsb { - options="$camera_usb_options" + options="$usb_options" device="video0" # check for parameter and set the device if it is given as a parameter @@ -72,16 +80,8 @@ function startUsb { device=`basename "$input"` fi - # override the device if it is set in the config - extracted_device=`echo $options | sed 's@.*-d /dev/\(video[0-9]\+\).*@\1@'` - if [ "$extracted_device" != "$options" ] - then - # the camera options refer to a device, use that for determining product - device=$extracted_device - else - # there was no device explicitly set in the options, let's add it there - options="$options -d /dev/$device" - fi + # add video device into options + options="$options -d /dev/$device" uevent_file="/sys/class/video4linux/$device/device/uevent" if [ -e $uevent_file ]; then @@ -128,22 +128,59 @@ echo "" # I have no idea why, but that's how it is... vcgencmd version > /dev/null 2>&1 +usb_options="$camera_usb_options" + +# if webcam device is explicitly given in /boot/octopi.txt, save the path of the device +# to a variable and remove its parameter from usb_options +extracted_device=`echo $usb_options | sed 's@.*-d \(/dev/video[0-9]\+\).*@\1@'` +if [ "$extracted_device" != "$usb_options" ] +then + # the camera options refer to a device, save it in a variable + usb_device_path="$extracted_device" + # replace video device parameter with empty string and strip extra whitespace + usb_options=`echo $usb_options | sed 's/\-d \/dev\/video[0-9]\+//g' | awk '$1=$1'` + echo "Explicitly set USB device was found in options: $usb_device_path" +fi + # keep mjpg streamer running if some camera is attached while true; do + # get list of usb video devices into an array - video_devices=($(ls /dev/video? 2> /dev/null)) + video_devices=($(find /dev -regextype sed -regex '\/dev/video[0-9]\+' | sort 2> /dev/null)) + echo "Found video devices:" && printf '%s\n' "${video_devices[@]}" + if [ ${#video_devices[@]} != 0 ] && { [ "$camera" = "auto" ] || [ "$camera" = "usb" ] ; }; then - #start with first usb camera as the parameter - startUsb "${video_devices[0]}" + + if [[ $usb_device_path ]]; then + # usb device is explicitly set in options + if containsString "$usb_device_path" "${video_devices[@]}"; then + # explicitly set usb device was found in video_devices array, start usb with the found device + echo "USB device was set in options and found in devices, start MJPG-streamer with the configured USB video device: $usb_device_path" + startUsb "$usb_device_path" + else + # explicitly set usb device was not found + echo "Configured USB camera was not detected, trying again in two minutes" + sleep 120 & + wait + fi + else + # device is not set explicitly in options, start usb with first found usb camera as the device + echo "USB device was not set in options, start MJPG-streamer with the first found video device: ${video_devices[0]}" + startUsb "${video_devices[0]}" + fi + sleep 30 & wait + elif [ "`vcgencmd get_camera`" = "supported=1 detected=1" ] && { [ "$camera" = "auto" ] || [ "$camera" = "raspi" ] ; }; then startRaspi sleep 30 & wait + else echo "No camera detected, trying again in two minutes" sleep 120 & wait + fi done From a55b3a1c7a521490a48f605ec1e7ed8a17c6ed72 Mon Sep 17 00:00:00 2001 From: Lauri Hakkarainen Date: Tue, 27 Feb 2018 09:30:57 +0100 Subject: [PATCH 213/352] Will now echo found devices only if trying to use an USB cam and if devices are found --- src/modules/octopi/filesystem/home/root/bin/webcamd | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/modules/octopi/filesystem/home/root/bin/webcamd b/src/modules/octopi/filesystem/home/root/bin/webcamd index 3a7021b7..08fd0037 100755 --- a/src/modules/octopi/filesystem/home/root/bin/webcamd +++ b/src/modules/octopi/filesystem/home/root/bin/webcamd @@ -147,10 +147,12 @@ while true; do # get list of usb video devices into an array video_devices=($(find /dev -regextype sed -regex '\/dev/video[0-9]\+' | sort 2> /dev/null)) - echo "Found video devices:" && printf '%s\n' "${video_devices[@]}" if [ ${#video_devices[@]} != 0 ] && { [ "$camera" = "auto" ] || [ "$camera" = "usb" ] ; }; then + echo "Found video devices:" + printf '%s\n' "${video_devices[@]}" + if [[ $usb_device_path ]]; then # usb device is explicitly set in options if containsString "$usb_device_path" "${video_devices[@]}"; then From 4d2e66eed3d08b114f27088b878da1c3783ea31f Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Thu, 1 Mar 2018 12:34:51 +0200 Subject: [PATCH 214/352] Revert #337 because https://github.com/RPi-Distro/raspi-config/pull/50 was merged, also see talk in #336 --- src/modules/octopi/start_chroot_script | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/modules/octopi/start_chroot_script b/src/modules/octopi/start_chroot_script index a5f37f9b..9b82460f 100755 --- a/src/modules/octopi/start_chroot_script +++ b/src/modules/octopi/start_chroot_script @@ -185,8 +185,6 @@ systemctl_if_exists disable lightdm.service || true update-rc.d change_password defaults update-rc.d change_hostname defaults -systemctl_if_exists enable check_wpa_link.service - ### Fix SSH echo "IPQoS 0x00" >> /etc/ssh/sshd_config From 87708f0ea553035832ea4d29d93c61eec5c987d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 5 Mar 2018 10:09:47 +0100 Subject: [PATCH 215/352] Fix definition of some broken webcams They were only added to the (by default commented out) config line in octopi.txt but missing in webcamd. Also the defaults weren't properly documented. --- src/modules/octopi/filesystem/boot/octopi.txt | 11 ++++++++--- src/modules/octopi/filesystem/home/root/bin/webcamd | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/modules/octopi/filesystem/boot/octopi.txt b/src/modules/octopi/filesystem/boot/octopi.txt index 9440cd50..b09fa8be 100644 --- a/src/modules/octopi/filesystem/boot/octopi.txt +++ b/src/modules/octopi/filesystem/boot/octopi.txt @@ -36,16 +36,21 @@ # # By default, this is done for the following devices: # Logitech C170 (046d:082b) +# GEMBIRD (1908:2310) +# Genius F100 (0458:708c) +# Cubeternet GL-UPC822 UVC WebCam (1e4e:0102) # # Using the following option it is possible to add additional devices. If # your webcam happens to show above symptoms, try determining your cam's # vendor and product id via lsusb, activating the line below by removing # and -# adding it as shown examplatory. +# adding it, e.g. for two broken cameras "aabb:ccdd" and "aabb:eeff" +# +# additional_brokenfps_usb_devices=("aabb:ccdd" "aabb:eeff") # # If this fixes your problem, please report it back so we can include the device -# out of the box. +# out of the box: https://github.com/guysoft/OctoPi/issues # -#additional_brokenfps_usb_devices=("046d:082b" "1908:2310" "1e4e:0102" "aabb:ccdd") +#additional_brokenfps_usb_devices=() ### Additional options to supply to MJPG Streamer for the RasPi Cam # diff --git a/src/modules/octopi/filesystem/home/root/bin/webcamd b/src/modules/octopi/filesystem/home/root/bin/webcamd index b4fc6129..0a32abaf 100755 --- a/src/modules/octopi/filesystem/home/root/bin/webcamd +++ b/src/modules/octopi/filesystem/home/root/bin/webcamd @@ -27,7 +27,7 @@ if [ -e "/boot/octopi.txt" ]; then source "/boot/octopi.txt" fi -brokenfps_usb_devices=("046d:082b" "1908:2310" "0458:708c" "${additional_brokenfps_usb_devices[@]}") +brokenfps_usb_devices=("046d:082b" "1908:2310" "0458:708c" "1e4e:0102" "${additional_brokenfps_usb_devices[@]}") # check if array contains a string function containsString() { From 215b2edef0e7d20ac27512bc4d8b4bd8da9db57b Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Mon, 5 Mar 2018 16:45:18 +0200 Subject: [PATCH 216/352] Fix #484 , use wget instead of curl --- src/modules/octopi/config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/octopi/config b/src/modules/octopi/config index 12544a69..d6c954eb 100755 --- a/src/modules/octopi/config +++ b/src/modules/octopi/config @@ -2,7 +2,7 @@ # All our config settings must start with OCTOPI_ # OctoPrint archive -[ -n "$OCTOPI_OCTOPRINT_ARCHIVE" ] || OCTOPI_OCTOPRINT_ARCHIVE=$(curl -s https://api.github.com/repos/foosel/OctoPrint/releases/latest | grep "zipball_url" | cut -d : -f 2,3 | tr -d \" | tr -d ,) +[ -n "$OCTOPI_OCTOPRINT_ARCHIVE" ] || OCTOPI_OCTOPRINT_ARCHIVE=$(wget -q -O - https://api.github.com/repos/foosel/OctoPrint/releases/latest | grep "zipball_url" | cut -d : -f 2,3 | tr -d \" | tr -d ,) [ -n "$OCTOPI_OCTOPRINT_REPO_SHIP" ] || OCTOPI_OCTOPRINT_REPO_SHIP=https://github.com/foosel/OctoPrint.git [ -n "$OCTOPI_INCLUDE_OCTOPRINT" ] || OCTOPI_INCLUDE_OCTOPRINT=yes @@ -28,4 +28,4 @@ [ -n "$OCTOPI_INCLUDE_WIRINGPI" ] || OCTOPI_INCLUDE_WIRINGPI=yes # yq -[ -n "$OCTOPI_YQ_DOWNLOAD" ] || OCTOPI_YQ_DOWNLOAD=$(curl -s https://api.github.com/repos/mikefarah/yq/releases/latest | grep "browser_download_url" | grep "yq_linux_arm" | cut -d : -f 2,3 | tr -d \" | tr -d ,) +[ -n "$OCTOPI_YQ_DOWNLOAD" ] || OCTOPI_YQ_DOWNLOAD=$(wget -q -O - https://api.github.com/repos/mikefarah/yq/releases/latest | grep "browser_download_url" | grep "yq_linux_arm" | cut -d : -f 2,3 | tr -d \" | tr -d ,) From 1c2f620f3d1253752a78f9a8e601b1face88fdbc Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Wed, 7 Mar 2018 13:50:46 +0200 Subject: [PATCH 217/352] Fix paths to assets --- src/nightly_build_scripts/template.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/nightly_build_scripts/template.html b/src/nightly_build_scripts/template.html index 88989d1b..3955c8b9 100644 --- a/src/nightly_build_scripts/template.html +++ b/src/nightly_build_scripts/template.html @@ -17,11 +17,11 @@ - + - + + + +
+

The HLS webcam server is currently not running

+
+ + + diff --git a/src/modules/octopi/filesystem/root/etc/haproxy/haproxy.cfg b/src/modules/octopi/filesystem/root/etc/haproxy/haproxy.cfg index 34b21fab..06b533dd 100644 --- a/src/modules/octopi/filesystem/root/etc/haproxy/haproxy.cfg +++ b/src/modules/octopi/filesystem/root/etc/haproxy/haproxy.cfg @@ -24,6 +24,8 @@ frontend public bind :::443 v4v6 ssl crt /etc/ssl/snakeoil.pem option forwardfor except 127.0.0.1 use_backend webcam if { path_beg /webcam/ } + use_backend webcam_hls if { path_beg /hls/ } + use_backend webcam_hls if { path_beg /jpeg/ } default_backend octoprint backend octoprint @@ -41,3 +43,6 @@ backend webcam server webcam1 127.0.0.1:8080 errorfile 503 /etc/haproxy/errors/503-no-webcam.http +backend webcam_hls + server webcam_hls_1 127.0.0.1:28126 + errorfile 503 /etc/haproxy/errors/503-no-webcam-hls.http diff --git a/src/modules/octopi/filesystem/root/etc/nginx/sites-available/default b/src/modules/octopi/filesystem/root/etc/nginx/sites-available/default index 251348f2..3ca36780 100644 --- a/src/modules/octopi/filesystem/root/etc/nginx/sites-available/default +++ b/src/modules/octopi/filesystem/root/etc/nginx/sites-available/default @@ -1,5 +1,5 @@ server { - listen 8051 default_server; + listen 127.0.0.1:28126; root /tmp/webcam; diff --git a/src/modules/octopi/filesystem/root/etc/systemd/system/ffmpeg_hls.service b/src/modules/octopi/filesystem/root/etc/systemd/system/ffmpeg_hls.service index 520b35be..35846d15 100644 --- a/src/modules/octopi/filesystem/root/etc/systemd/system/ffmpeg_hls.service +++ b/src/modules/octopi/filesystem/root/etc/systemd/system/ffmpeg_hls.service @@ -17,15 +17,16 @@ ExecStart=/usr/bin/ffmpeg \ -i /dev/video0 \ \ -c:v mjpeg -q:v 0 \ - -f image2 -update 1 \ + -f image2 -update 1 -atomic_writing 1 \ /tmp/webcam/jpeg/frame.jpg \ \ -c:v h264_omx -profile:v high \ -b:v 2048k -flags +cgop \ -g 30 -keyint_min 30 \ \ - -f hls -hls_time 1 -hls_flags delete_segments \ - -hls_allow_cache 1 -hls_segment_type fmp4 \ + -f hls -hls_time 1 \ + -hls_flags delete_segments+program_date_time+temp_file+independent_segments \ + -hls_allow_cache 0 -hls_segment_type fmp4 \ -hls_list_size 32 -hls_delete_threshold 64 \ /tmp/webcam/hls/stream.m3u8 From 7afaf01365df9c8c0960f7ae54e01a2e6ddf597b Mon Sep 17 00:00:00 2001 From: Nigel2x4 Date: Wed, 26 Aug 2020 09:57:25 -0400 Subject: [PATCH 282/352] added default listener to localhost for webcamd --- src/modules/octopi/filesystem/home/root/bin/webcamd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/octopi/filesystem/home/root/bin/webcamd b/src/modules/octopi/filesystem/home/root/bin/webcamd index b60bc0e7..f51a8c52 100755 --- a/src/modules/octopi/filesystem/home/root/bin/webcamd +++ b/src/modules/octopi/filesystem/home/root/bin/webcamd @@ -46,7 +46,7 @@ for cfg_file in ${cfg_files[@]}; do camera_usb_options="-r 640x480 -f 10" camera_raspi_options="-fps 10" camera_http_webroot="./www-octopi" - camera_http_options="-n" + camera_http_options="-n --listen 127.0.0.1" additional_brokenfps_usb_devices=() if [[ -e ${cfg_file} ]]; then From adab4e6b9f6ac4cf13b8ea1323b66b792a8d03fc Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Tue, 29 Sep 2020 10:51:33 +0300 Subject: [PATCH 283/352] Remove checkinstall that is not needed anymore, missed in this commit https://github.com/guysoft/OctoPi/commit/d3a8991879e5ae5c9c6d21e0bcaf55b3356e02b7 --- src/modules/octopi/start_chroot_script | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/octopi/start_chroot_script b/src/modules/octopi/start_chroot_script index c5879180..966a756d 100755 --- a/src/modules/octopi/start_chroot_script +++ b/src/modules/octopi/start_chroot_script @@ -33,7 +33,7 @@ echo "removing:" $remove_extra apt-get remove -y --purge $remove_extra apt-get autoremove -y -apt-get -y --force-yes install python3 python3-virtualenv python3-dev git screen subversion cmake checkinstall avahi-daemon libavahi-compat-libdnssd1 libffi-dev libssl-dev +apt-get -y --force-yes install python3 python3-virtualenv python3-dev git screen subversion cmake avahi-daemon libavahi-compat-libdnssd1 libffi-dev libssl-dev echo " - Reinstall iputils-ping" apt-get install --reinstall iputils-ping From d2a7016c8b1760dcb10d0c14e1b049f173579c86 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Tue, 29 Sep 2020 11:42:51 +0300 Subject: [PATCH 284/352] Install extra dependencies if needed due to arm64 --- src/modules/octopi/start_chroot_script | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/octopi/start_chroot_script b/src/modules/octopi/start_chroot_script index 966a756d..216e08aa 100755 --- a/src/modules/octopi/start_chroot_script +++ b/src/modules/octopi/start_chroot_script @@ -138,7 +138,7 @@ EOT if [ "$OCTOPI_INCLUDE_WIRINGPI" == "yes" ] then echo "--- Installing WiringPi" - apt-get install wiringpi + apt-get -y install wiringpi fi # fetch current yq build and install to /usr/local/bin From 4003dbd388263676a63e20e72291e14419659597 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Wed, 30 Sep 2020 13:17:27 +0200 Subject: [PATCH 285/352] Remove pybonjour dependency install OctoPrint no longer depends on it (it's no longer maintained and also not compatible to Python 3) and instead now uses zeroconf. As it's incompatible to Python 3 anyhow, installing it no longer makes sense. --- src/modules/octopi/config | 6 ++---- src/modules/octopi/start_chroot_script | 7 +------ 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/modules/octopi/config b/src/modules/octopi/config index 996b1bc9..e9f3d064 100755 --- a/src/modules/octopi/config +++ b/src/modules/octopi/config @@ -6,9 +6,6 @@ [ -n "$OCTOPI_OCTOPRINT_REPO_SHIP" ] || OCTOPI_OCTOPRINT_REPO_SHIP=https://github.com/foosel/OctoPrint.git [ -n "$OCTOPI_INCLUDE_OCTOPRINT" ] || OCTOPI_INCLUDE_OCTOPRINT=yes -# PyBonjour archive -[ -n "$OCTOPI_PYBONJOUR_ARCHIVE" ] || OCTOPI_PYBONJOUR_ARCHIVE=https://github.com/OctoPrint/pybonjour-python3/archive/master.zip - # CuraEngine archive & version [ -n "$OCTOPI_CURAENGINE_VERSION" ] || OCTOPI_CURAENGINE_VERSION=15.04.6 [ -n "$OCTOPI_CURAENGINE_ARCHIVE" ] || OCTOPI_CURAENGINE_ARCHIVE=https://github.com/Ultimaker/CuraEngine/archive/$OCTOPI_CURAENGINE_VERSION.zip @@ -36,4 +33,5 @@ [ -n "$OCTOPI_COMMIT" ] || OCTOPI_COMMIT=`pushd "${DIST_PATH}" > /dev/null ; git rev-parse HEAD ; popd > /dev/null` # Fixed apt mirror -[ -n "$OCTOPI_APTMIRROR" ] || OCTOPI_APTMIRROR= \ No newline at end of file +[ -n "$OCTOPI_APTMIRROR" ] || OCTOPI_APTMIRROR= + diff --git a/src/modules/octopi/start_chroot_script b/src/modules/octopi/start_chroot_script index 216e08aa..ded78331 100755 --- a/src/modules/octopi/start_chroot_script +++ b/src/modules/octopi/start_chroot_script @@ -44,15 +44,10 @@ pushd /home/pi sudo -u pi python3 -m virtualenv --python=python3 oprint sudo -u pi /home/pi/oprint/bin/pip install --upgrade pip - # OctoPrint & pyserial + # OctoPrint if [ "$OCTOPI_INCLUDE_OCTOPRINT" == "yes" ] then echo "--- Installing OctoPrint" - - #pybonjour (for mdns discovery) - sudo -u pi /home/pi/oprint/bin/pip install $OCTOPI_PYBONJOUR_ARCHIVE - - #OctoPrint PIP_DEFAULT_TIMEOUT=60 sudo -u pi /home/pi/oprint/bin/pip install $OCTOPI_OCTOPRINT_ARCHIVE fi From 1bd2ffabcacbf78305e08c9f7daae8c5cb0dc2d6 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Fri, 2 Oct 2020 15:08:10 +0300 Subject: [PATCH 286/352] Fixes #678 --- src/modules/octopi/filesystem/home/root/bin/webcamd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/octopi/filesystem/home/root/bin/webcamd b/src/modules/octopi/filesystem/home/root/bin/webcamd index f51a8c52..effdfbe2 100755 --- a/src/modules/octopi/filesystem/home/root/bin/webcamd +++ b/src/modules/octopi/filesystem/home/root/bin/webcamd @@ -15,7 +15,7 @@ MJPGSTREAMER_HOME=/home/pi/mjpg-streamer MJPGSTREAMER_INPUT_USB="input_uvc.so" MJPGSTREAMER_INPUT_RASPICAM="input_raspicam.so" -brokenfps_usb_devices=("046d:082b" "1908:2310" "0458:708c" "1e4e:0102" "0471:0311" "038f:6001" "046d:0804" "046d:0825" "046d:0994" "0ac8:3450") +brokenfps_usb_devices=("046d:082b" "1908:2310" "0458:708c" "0458:6006" "1e4e:0102" "0471:0311" "038f:6001" "046d:0804" "046d:0825" "046d:0994" "0ac8:3450") config_dir="/boot/octopi.conf.d" From 623efdd49dc5f9d589b385f4e03da01409818006 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Fri, 2 Oct 2020 15:22:09 +0300 Subject: [PATCH 287/352] Fixes #676 and adds deps to install numpy from wheel --- src/modules/octopi/start_chroot_script | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/octopi/start_chroot_script b/src/modules/octopi/start_chroot_script index ded78331..596015b4 100755 --- a/src/modules/octopi/start_chroot_script +++ b/src/modules/octopi/start_chroot_script @@ -33,7 +33,7 @@ echo "removing:" $remove_extra apt-get remove -y --purge $remove_extra apt-get autoremove -y -apt-get -y --force-yes install python3 python3-virtualenv python3-dev git screen subversion cmake avahi-daemon libavahi-compat-libdnssd1 libffi-dev libssl-dev +apt-get -y --force-yes install python3 python3-virtualenv python3-dev git screen subversion cmake avahi-daemon libavahi-compat-libdnssd1 libffi-dev libssl-dev libatlas3-base echo " - Reinstall iputils-ping" apt-get install --reinstall iputils-ping From 0e6de698a840a4d44e29cb9fac8019f6d88079bf Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Wed, 7 Oct 2020 13:49:30 +0300 Subject: [PATCH 288/352] Add arm64 builds, remove bananapi builds --- src/nightly_build_scripts/generate_nightly_page.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/nightly_build_scripts/generate_nightly_page.js b/src/nightly_build_scripts/generate_nightly_page.js index 2d25ceb7..5d761ab8 100644 --- a/src/nightly_build_scripts/generate_nightly_page.js +++ b/src/nightly_build_scripts/generate_nightly_page.js @@ -162,7 +162,7 @@ var outputPage = function(files, s) { var output = new StringStream(); - output.write(""); + output.write(""); output.write("

Raspberry Pi

\n"); @@ -174,18 +174,18 @@ var outputPage = function(files, s) { output.write("

Nightly Builds

\n"); output.write("Warning: These builds are untested and can be unstable and/or broken. If in doubt use a stable build."); - outputTable(filterNameByRegex(files.filter(function (obj) { return !obj.name.startsWith("stable/") && !obj.name.startsWith("bananapi-m1/") }), /octopi-(wheezy|jessie|stretch|buster)-/), + outputTable(filterNameByRegex(files.filter(function (obj) { return !obj.name.startsWith("stable/") && !obj.name.startsWith("bananapi-m1/") }), /octopi-(wheezy|jessie|stretch|buster)-armhf/), output, function(name) { return name }, 14); - output.write("

Banana Pi M1

\n") + output.write("

64Bit Nightly Builds

\n") - output.write("

Nightly Builds

\n"); + output.write("

Nightly Builds arm64

\n"); output.write("Warning: These builds are untested and can be unstable and/or broken."); - outputTable(filterNameByRegex(files, /^bananapi-m1\//), + outputTable(filterNameByRegex(files.filter(function (obj) { return !obj.name.startsWith("stable/") && !obj.name.startsWith("bananapi-m1/") }), /octopi-(wheezy|jessie|stretch|buster)-arm64/), output, - function(name) { return stripLeading(name, "bananapi-m1/") }, + function(name) { return name }, 14); var content = output.buffer; @@ -212,3 +212,4 @@ client.getFiles(container, function (err, files) { var stream = fs.createWriteStream(outputfile); outputPage(filterByExtension(files, [".zip"]), stream); }); + From 582617b8398e8df5596056b2bde8b017a7aa6388 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Mon, 12 Oct 2020 09:47:24 +0300 Subject: [PATCH 289/352] Add raspios_lite_arm64 build variant image folder and update README --- .gitignore | 1 + src/image-raspios_lite_arm64/README | 5 +++++ src/image/README | 4 ++-- 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 src/image-raspios_lite_arm64/README diff --git a/.gitignore b/.gitignore index 386e2ff8..1638832a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ src/config.local src/custompios_path src/image/*.zip +src/image-raspios_lite_arm64/*.zip src/image-variants/*.zip **/key.json src/nightly_build_scripts/index.html diff --git a/src/image-raspios_lite_arm64/README b/src/image-raspios_lite_arm64/README new file mode 100644 index 00000000..e5aa7b03 --- /dev/null +++ b/src/image-raspios_lite_arm64/README @@ -0,0 +1,5 @@ +Place zipped Raspberry Pi OS 64bit image here. + +If not otherwise specified, the build script will always use the most +recent zip file matching the file name pattern "*-raspbian.zip" or "*-rpios.zip" located +here. diff --git a/src/image/README b/src/image/README index 8c07825f..a536aca2 100644 --- a/src/image/README +++ b/src/image/README @@ -1,5 +1,5 @@ -Place zipped Rasbian image here. +Place zipped Raspberry Pi OS image here. Or any other variant you want to build/ If not otherwise specified, the build script will always use the most -recent zip file matching the file name pattern "*-raspbian.zip" located +recent zip file matching the file name pattern "*-raspbian.zip" or "*-rpios.zip" located here. From 68dc378e2f053fb7798063d769d645ed9abac18b Mon Sep 17 00:00:00 2001 From: AJRepo Date: Sun, 18 Oct 2020 15:14:43 -0500 Subject: [PATCH 290/352] Fix for 'haprocy -c -f haproxy.cfg' warning HA-Proxy version on RasPi Buster is HA-Proxy version 1.8.19-1+rpi1 2019/03/14 Running a test of the config file sudo haproxy -c -f /etc/haproxy/haproxy.cfg Generates the warning ``` [WARNING] 291/152612 (2843) : Setting tune.ssl.default-dh-param to 1024 by default, if your workload permits it you should set it to at least 2048. Please set a value >= 1024 to make this warning disappear. ``` Documentation for this feature states that higher values might increase server load. Higher values increase CPU load and may not be supported by some clients (IE:Java 7). Tested with values both at 1024 and 2048 Assuming that the use-case for OctoPrint is usually one user at a time, tested on a RasPi 3B with `ab -n 20 -c 1 ...` and also tested by firefox browser by refreshing the home page at about 1 request per second. Load tests showed no measureable difference in user load (uptime) between a value of 1024 and the recommend value 2048. Tests using `ab` showed no measurable difference in response time or failure rate between 1024 and 2048 (2048 was actually faster, but might have been due to caching). Adding `tune.ssl.default-hd-param 2048` to haproxy.cfg file gets rid of warning message and does not measurably impact performance --- src/modules/octopi/filesystem/root/etc/haproxy/haproxy.cfg | 1 + 1 file changed, 1 insertion(+) diff --git a/src/modules/octopi/filesystem/root/etc/haproxy/haproxy.cfg b/src/modules/octopi/filesystem/root/etc/haproxy/haproxy.cfg index 06b533dd..443dd002 100644 --- a/src/modules/octopi/filesystem/root/etc/haproxy/haproxy.cfg +++ b/src/modules/octopi/filesystem/root/etc/haproxy/haproxy.cfg @@ -3,6 +3,7 @@ global user haproxy group haproxy log /dev/log local1 debug + tune.ssl.default-dh-param 2048 defaults log global From fb178084339bb91ede9e5132c806bfd332667564 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Fri, 23 Oct 2020 02:04:05 +0300 Subject: [PATCH 291/352] Update nightly builds location --- README.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index c79069ef..1a2b2a2f 100644 --- a/README.rst +++ b/README.rst @@ -19,7 +19,11 @@ Download the latest stable build via this button: Official mirror is `here `_ -Nightly builds are available `here `_ +Nightly builds are available `here `_ + +64bit Nightly builds are available `here `_ + +We recently had to move to building location, donations for somewhere with HTTPS would be great. How to use it? -------------- From 3ba8ad7b026a44322bf5cfea7f5e3b74ec053be4 Mon Sep 17 00:00:00 2001 From: Chudsaviet Date: Sun, 25 Oct 2020 23:42:49 -0700 Subject: [PATCH 292/352] Made HLS stream adaptive. --- .../etc/systemd/system/ffmpeg_hls.service | 22 ++++++++++++++++--- .../root/var/lib/ffmpeg_hls/stream.m3u8 | 6 +++++ 2 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 src/modules/octopi/filesystem/root/var/lib/ffmpeg_hls/stream.m3u8 diff --git a/src/modules/octopi/filesystem/root/etc/systemd/system/ffmpeg_hls.service b/src/modules/octopi/filesystem/root/etc/systemd/system/ffmpeg_hls.service index 35846d15..c2a7b494 100644 --- a/src/modules/octopi/filesystem/root/etc/systemd/system/ffmpeg_hls.service +++ b/src/modules/octopi/filesystem/root/etc/systemd/system/ffmpeg_hls.service @@ -9,26 +9,42 @@ RestartSec=5 Nice=10 ExecStartPre=/bin/rm -rf /tmp/webcam ExecStartPre=/bin/mkdir -p /tmp/webcam/hls +ExecStartPre=/bin/mkdir -p /tmp/webcam/hls/240p +ExecStartPre=/bin/mkdir -p /tmp/webcam/hls/480p ExecStartPre=/bin/mkdir -p /tmp/webcam/jpeg +ExecStartPre=/bin/cp /var/lib/ffmpeg_hls/stream.m3u8 /tmp/webcam/hls/stream.m3u8 ExecStart=/usr/bin/ffmpeg \ \ - -framerate 30 -video_size 800x600 \ + -framerate 30 -video_size 640x480 \ -i /dev/video0 \ + -pix_fmt yuv420p \ \ -c:v mjpeg -q:v 0 \ -f image2 -update 1 -atomic_writing 1 \ /tmp/webcam/jpeg/frame.jpg \ \ -c:v h264_omx -profile:v high \ - -b:v 2048k -flags +cgop \ + -b:v 1264k -flags +cgop \ -g 30 -keyint_min 30 \ \ -f hls -hls_time 1 \ -hls_flags delete_segments+program_date_time+temp_file+independent_segments \ -hls_allow_cache 0 -hls_segment_type fmp4 \ -hls_list_size 32 -hls_delete_threshold 64 \ - /tmp/webcam/hls/stream.m3u8 + /tmp/webcam/hls/480p/stream.m3u8 \ + \ + -vf scale=-1:240 \ + \ + -c:v h264_omx -profile:v high \ + -b:v 240k -flags +cgop \ + -g 30 -keyint_min 30 \ + \ + -f hls -hls_time 1 \ + -hls_flags delete_segments+program_date_time+temp_file+independent_segments \ + -hls_allow_cache 0 -hls_segment_type fmp4 \ + -hls_list_size 32 -hls_delete_threshold 64 \ + /tmp/webcam/hls/240p/stream.m3u8 [Install] WantedBy=multi-user.target \ No newline at end of file diff --git a/src/modules/octopi/filesystem/root/var/lib/ffmpeg_hls/stream.m3u8 b/src/modules/octopi/filesystem/root/var/lib/ffmpeg_hls/stream.m3u8 new file mode 100644 index 00000000..a28b385e --- /dev/null +++ b/src/modules/octopi/filesystem/root/var/lib/ffmpeg_hls/stream.m3u8 @@ -0,0 +1,6 @@ +#EXTM3U +#EXT-X-VERSION:3 +#EXT-X-STREAM-INF:BANDWIDTH=245760,RESOLUTION=320x240 +240p/stream.m3u8 +#EXT-X-STREAM-INF:BANDWIDTH=1294336,RESOLUTION=640x480 +480p/stream.m3u8 \ No newline at end of file From 56f7e587a4be5dac5f74f8b4bcda29748e696a4b Mon Sep 17 00:00:00 2001 From: Patrick Fowler Date: Wed, 28 Oct 2020 16:21:28 -0700 Subject: [PATCH 293/352] Update octopi.txt Add note about problem with raspi cams reporting as usb and config options not being used. --- src/modules/octopi/filesystem/boot/octopi.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/modules/octopi/filesystem/boot/octopi.txt b/src/modules/octopi/filesystem/boot/octopi.txt index b81a1f3f..bc015399 100644 --- a/src/modules/octopi/filesystem/boot/octopi.txt +++ b/src/modules/octopi/filesystem/boot/octopi.txt @@ -53,7 +53,10 @@ ### Additional options to supply to MJPG Streamer for the RasPi Cam # -# See https://faq.octoprint.org/mjpg-streamer-config for available options +# See https://faq.octoprint.org/mjpg-streamer-config for available options. +# +# NOTE: Newer raspi cam modules are reporting as usb devices causing these +# options to be ignored. Set `camera="raspi"` to avoid these issues. # # Defaults to 10fps # From 8aa44187aafa52e487f2b6661007a5aad35c62a6 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Thu, 10 Dec 2020 12:46:41 +0200 Subject: [PATCH 294/352] Fixes #703 --- .../filesystem/root/{ => usr}/lib/systemd/system/nginx.service | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/modules/octopi/filesystem/root/{ => usr}/lib/systemd/system/nginx.service (100%) diff --git a/src/modules/octopi/filesystem/root/lib/systemd/system/nginx.service b/src/modules/octopi/filesystem/root/usr/lib/systemd/system/nginx.service similarity index 100% rename from src/modules/octopi/filesystem/root/lib/systemd/system/nginx.service rename to src/modules/octopi/filesystem/root/usr/lib/systemd/system/nginx.service From ddfc9f500b6e798feae0870fed35f367c2bfd714 Mon Sep 17 00:00:00 2001 From: coliss86 Date: Fri, 18 Dec 2020 18:09:45 +0100 Subject: [PATCH 295/352] Increase restart time to 1 second by default, when the service crash, it is restarted within 100 ms. This patch increase the time in order to eventually let the usb device to be ready. --- .../octopi/filesystem/root/etc/systemd/system/webcamd.service | 1 + 1 file changed, 1 insertion(+) diff --git a/src/modules/octopi/filesystem/root/etc/systemd/system/webcamd.service b/src/modules/octopi/filesystem/root/etc/systemd/system/webcamd.service index 2416f578..ea494e40 100644 --- a/src/modules/octopi/filesystem/root/etc/systemd/system/webcamd.service +++ b/src/modules/octopi/filesystem/root/etc/systemd/system/webcamd.service @@ -9,6 +9,7 @@ StandardError=append:/var/log/webcamd.log ExecStart=/root/bin/webcamd Restart=always Type=forking +RestartSec=1 [Install] WantedBy=multi-user.target From 4a1864b94421d1b667dfa9afb89d48d8bd5442f5 Mon Sep 17 00:00:00 2001 From: Charlie Powell <31997505+cp2004@users.noreply.github.com> Date: Sun, 27 Dec 2020 15:58:15 +0000 Subject: [PATCH 296/352] Remove preinstalled cura reference See https://github.com/guysoft/OctoPi/issues/692#issuecomment-751482637 and https://github.com/guysoft/OctoPi/commit/62eabbf492c42a9e73cd4b094cbb10b7a7e19d64 --- README.rst | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.rst b/README.rst index 1a2b2a2f..6091ecc9 100644 --- a/README.rst +++ b/README.rst @@ -47,7 +47,6 @@ To install plugins from the commandline instead of OctoPrint's built-in plugin m If a USB webcam or the Raspberry Pi camera is detected, MJPG-streamer will be started automatically as webcam server. OctoPrint on OctoPi ships with correctly configured stream and snapshot URLs pointing at it. If necessary, you can reach it under `http://octopi.local/webcam/?action=stream `_ and SSL respectively, or directly on its configured port 8080: `http://octopi.local:8080/?action=stream `_. -CuraEngine is installed and OctoPrint ships pre-configured with the correct path to utilize it for on-board-slicing. Just import a Cura Slicing Profile in OctoPrint's settings and start slicing directly on your Pi. Features -------- @@ -55,7 +54,6 @@ Features * `OctoPrint `_ host software for 3d printers out of the box * `Raspbian `_ tweaked for maximum performance for printing out of the box * `mjpg-streamer with RaspiCam support `_ for live viewing of prints and timelapse video creation. -* `CuraEngine `_ pre-installed for slicing directly on the Raspberry Pi Developing ---------- From b3b2d456df395478e6c076dc6e08d57df0ad9380 Mon Sep 17 00:00:00 2001 From: Timofei Korostelev Date: Thu, 31 Dec 2020 11:40:59 -0800 Subject: [PATCH 297/352] Changed HLS root directory from `/tmp` to `/run`. --- .../root/etc/nginx/sites-available/default | 2 +- .../etc/systemd/system/ffmpeg_hls.service | 25 +++++++++++-------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/modules/octopi/filesystem/root/etc/nginx/sites-available/default b/src/modules/octopi/filesystem/root/etc/nginx/sites-available/default index 3ca36780..a4183d87 100644 --- a/src/modules/octopi/filesystem/root/etc/nginx/sites-available/default +++ b/src/modules/octopi/filesystem/root/etc/nginx/sites-available/default @@ -1,7 +1,7 @@ server { listen 127.0.0.1:28126; - root /tmp/webcam; + root /run/webcam; location / { # First attempt to serve request as file, then diff --git a/src/modules/octopi/filesystem/root/etc/systemd/system/ffmpeg_hls.service b/src/modules/octopi/filesystem/root/etc/systemd/system/ffmpeg_hls.service index c2a7b494..b3a4d9ce 100644 --- a/src/modules/octopi/filesystem/root/etc/systemd/system/ffmpeg_hls.service +++ b/src/modules/octopi/filesystem/root/etc/systemd/system/ffmpeg_hls.service @@ -3,18 +3,21 @@ Description=FFMPEG HLS webcam streaming service ConditionPathExists=/etc/octopi_streamer/hls [Service] -User=webcam +User=root Restart=always RestartSec=5 Nice=10 -ExecStartPre=/bin/rm -rf /tmp/webcam -ExecStartPre=/bin/mkdir -p /tmp/webcam/hls -ExecStartPre=/bin/mkdir -p /tmp/webcam/hls/240p -ExecStartPre=/bin/mkdir -p /tmp/webcam/hls/480p -ExecStartPre=/bin/mkdir -p /tmp/webcam/jpeg -ExecStartPre=/bin/cp /var/lib/ffmpeg_hls/stream.m3u8 /tmp/webcam/hls/stream.m3u8 +ExecStartPre=/bin/rm -rf /run/webcam +ExecStartPre=/bin/mkdir -p /run/webcam/hls +ExecStartPre=/bin/mkdir -p /run/webcam/hls/240p +ExecStartPre=/bin/mkdir -p /run/webcam/hls/480p +ExecStartPre=/bin/mkdir -p /run/webcam/jpeg +ExecStartPre=/bin/cp /var/lib/ffmpeg_hls/stream.m3u8 /run/webcam/hls/stream.m3u8 +ExecStartPre=/bin/chown -R webcam:webcam /run/webcam +ExecStartPre=/bin/chmod -R 0755 /run/webcam -ExecStart=/usr/bin/ffmpeg \ +ExecStart=/usr/bin/sudo -u webcam \ + /usr/bin/ffmpeg \ \ -framerate 30 -video_size 640x480 \ -i /dev/video0 \ @@ -22,7 +25,7 @@ ExecStart=/usr/bin/ffmpeg \ \ -c:v mjpeg -q:v 0 \ -f image2 -update 1 -atomic_writing 1 \ - /tmp/webcam/jpeg/frame.jpg \ + /run/webcam/jpeg/frame.jpg \ \ -c:v h264_omx -profile:v high \ -b:v 1264k -flags +cgop \ @@ -32,7 +35,7 @@ ExecStart=/usr/bin/ffmpeg \ -hls_flags delete_segments+program_date_time+temp_file+independent_segments \ -hls_allow_cache 0 -hls_segment_type fmp4 \ -hls_list_size 32 -hls_delete_threshold 64 \ - /tmp/webcam/hls/480p/stream.m3u8 \ + /run/webcam/hls/480p/stream.m3u8 \ \ -vf scale=-1:240 \ \ @@ -44,7 +47,7 @@ ExecStart=/usr/bin/ffmpeg \ -hls_flags delete_segments+program_date_time+temp_file+independent_segments \ -hls_allow_cache 0 -hls_segment_type fmp4 \ -hls_list_size 32 -hls_delete_threshold 64 \ - /tmp/webcam/hls/240p/stream.m3u8 + /run/webcam/hls/240p/stream.m3u8 [Install] WantedBy=multi-user.target \ No newline at end of file From 3445351397fd179cd62e0dbe5d2b9aea4f5fd57a Mon Sep 17 00:00:00 2001 From: Timofei Korostelev Date: Sat, 2 Jan 2021 14:53:33 -0800 Subject: [PATCH 298/352] Made HLS stream restart every 6 hours. --- .../octopi/filesystem/root/etc/systemd/system/ffmpeg_hls.service | 1 + 1 file changed, 1 insertion(+) diff --git a/src/modules/octopi/filesystem/root/etc/systemd/system/ffmpeg_hls.service b/src/modules/octopi/filesystem/root/etc/systemd/system/ffmpeg_hls.service index c2a7b494..b628ee6e 100644 --- a/src/modules/octopi/filesystem/root/etc/systemd/system/ffmpeg_hls.service +++ b/src/modules/octopi/filesystem/root/etc/systemd/system/ffmpeg_hls.service @@ -6,6 +6,7 @@ ConditionPathExists=/etc/octopi_streamer/hls User=webcam Restart=always RestartSec=5 +WatchdogSec=21600 Nice=10 ExecStartPre=/bin/rm -rf /tmp/webcam ExecStartPre=/bin/mkdir -p /tmp/webcam/hls From 2f51ef2dcb60508f25b47c4c2bc070ffe2b363df Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Wed, 6 Jan 2021 21:15:12 +0200 Subject: [PATCH 299/352] Switch user pi to BASE_USER --- src/modules/octopi/start_chroot_script | 48 +++++++++++++------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/modules/octopi/start_chroot_script b/src/modules/octopi/start_chroot_script index 596015b4..6398aea4 100755 --- a/src/modules/octopi/start_chroot_script +++ b/src/modules/octopi/start_chroot_script @@ -22,7 +22,7 @@ WEBCAM_USER=webcam ### Script #### -unpack /filesystem/home/pi /home/pi pi +unpack /filesystem/home/pi /home/"${BASE_USER}" "${BASE_USER}" unpack /filesystem/home/root /root root unpack /filesystem/boot /boot apt-get update @@ -38,17 +38,17 @@ apt-get -y --force-yes install python3 python3-virtualenv python3-dev git screen echo " - Reinstall iputils-ping" apt-get install --reinstall iputils-ping -pushd /home/pi +pushd /home/"${BASE_USER}" # build virtualenv - sudo -u pi python3 -m virtualenv --python=python3 oprint - sudo -u pi /home/pi/oprint/bin/pip install --upgrade pip + sudo -u "${BASE_USER}" python3 -m virtualenv --python=python3 oprint + sudo -u "${BASE_USER}" /home/"${BASE_USER}"/oprint/bin/pip install --upgrade pip # OctoPrint if [ "$OCTOPI_INCLUDE_OCTOPRINT" == "yes" ] then echo "--- Installing OctoPrint" - PIP_DEFAULT_TIMEOUT=60 sudo -u pi /home/pi/oprint/bin/pip install $OCTOPI_OCTOPRINT_ARCHIVE + PIP_DEFAULT_TIMEOUT=60 sudo -u "${BASE_USER}" /home/"${BASE_USER}"/oprint/bin/pip install $OCTOPI_OCTOPRINT_ARCHIVE fi #mjpg-streamer @@ -70,17 +70,17 @@ pushd /home/pi # To apply -j option, we have to unwrap it. MJPG_STREAMER_BUILD_DIR=_build [ -d ${MJPG_STREAMER_BUILD_DIR} ] || (mkdir ${MJPG_STREAMER_BUILD_DIR} && \ - chown pi:pi ${MJPG_STREAMER_BUILD_DIR}) + chown "${BASE_USER}:${BASE_USER}" ${MJPG_STREAMER_BUILD_DIR}) [ -f ${MJPG_STREAMER_BUILD_DIR}/Makefile ] || (cd ${MJPG_STREAMER_BUILD_DIR} && \ - sudo -u pi cmake -DCMAKE${MJPG_STREAMER_BUILD_DIR}_TYPE=Release ..) + sudo -u "${BASE_USER}" cmake -DCMAKE${MJPG_STREAMER_BUILD_DIR}_TYPE=Release ..) - sudo -u pi make -j $(nproc) -C ${MJPG_STREAMER_BUILD_DIR} + sudo -u "${BASE_USER}" make -j $(nproc) -C ${MJPG_STREAMER_BUILD_DIR} - sudo -u pi cp ${MJPG_STREAMER_BUILD_DIR}/mjpg_streamer . - sudo -u pi find ${MJPG_STREAMER_BUILD_DIR} -name "*.so" -type f -exec cp {} . \; + sudo -u "${BASE_USER}" cp ${MJPG_STREAMER_BUILD_DIR}/mjpg_streamer . + sudo -u "${BASE_USER}" find ${MJPG_STREAMER_BUILD_DIR} -name "*.so" -type f -exec cp {} . \; # create our custom web folder and add a minimal index.html to it - sudo -u pi mkdir www-octopi + sudo -u "${BASE_USER}" mkdir www-octopi pushd www-octopi cat <> index.html @@ -113,13 +113,13 @@ EOT folder=CuraEngine-$OCTOPI_CURAENGINE_VERSION zipfile=$folder.zip apt-get -y install gcc-4.9 g++-4.9 - sudo -u pi wget -O$zipfile $OCTOPI_CURAENGINE_ARCHIVE - sudo -u pi unzip $zipfile + sudo -u "${BASE_USER}" wget -O$zipfile $OCTOPI_CURAENGINE_ARCHIVE + sudo -u "${BASE_USER}" unzip $zipfile pushd $folder - sudo -u pi make -j$(nproc) CXX=g++-4.9 VERSION=$OCTOPI_CURAENGINE_VERSION + sudo -u "${BASE_USER}" make -j$(nproc) CXX=g++-4.9 VERSION=$OCTOPI_CURAENGINE_VERSION cp build/CuraEngine /usr/local/bin/cura_engine popd - sudo -u pi rm -r $folder $zipfile + sudo -u "${BASE_USER}" rm -r $folder $zipfile fi #setup haproxy for http and https, and webcam @@ -141,9 +141,9 @@ EOT popd -#Make sure user pi has access to serial ports -usermod -a -G tty pi -usermod -a -G dialout pi +#Make sure user pi / ${BASE_USER} has access to serial ports +usermod -a -G tty "${BASE_USER}" +usermod -a -G dialout "${BASE_USER}" # store octopi commit used to build this image echo "$OCTOPI_COMMIT" > /etc/octopi_commit @@ -151,9 +151,9 @@ echo "$OCTOPI_COMMIT" > /etc/octopi_commit # Keep legacy compatibility ln -s /etc/custompios_buildbase /etc/octopi_buildbase -# allow pi user to run shutdown and service commands -echo "pi ALL=NOPASSWD: /sbin/shutdown" > /etc/sudoers.d/octoprint-shutdown -echo "pi ALL=NOPASSWD: /usr/sbin/service" > /etc/sudoers.d/octoprint-service +# allow pi / ${BASE_USER} user to run shutdown and service commands +echo "${BASE_USER} ALL=NOPASSWD: /sbin/shutdown" > /etc/sudoers.d/octoprint-shutdown +echo "${BASE_USER} ALL=NOPASSWD: /usr/sbin/service" > /etc/sudoers.d/octoprint-service #make sure users don't run git with sudo, thus breaking permissions, by adding /root/bin to the #default sudo path and placing a git wrapper script there that checks if it's run as root @@ -191,8 +191,8 @@ EOT echo 'exit 0' >> /etc/rc.local -# add a longer welcome text to ~pi/.bashrc -echo "source /home/pi/scripts/welcome" >> /home/pi/.bashrc +# add a longer welcome text to ~pi/.bashrc / ~${BASE_USER}/.bashrc +echo "source /home/${BASE_USER}/scripts/welcome" >> /home/${BASE_USER}/.bashrc #unpack root in the end, so etc file are not overwritten, might need to add two roots int he future unpack /filesystem/root / @@ -236,7 +236,7 @@ fi if [ ! "$OCTOPI_INCLUDE_CURAENGINE" == "yes" ] then # unconfigure the cura engine path in octoprint's config.yaml - sudo -u pi sed -i -e "s@cura_engine: /usr/local/bin/cura_engine@cura_engine:@g" /home/pi/.octoprint/config.yaml + sudo -u "${BASE_USER}" sed -i -e "s@cura_engine: /usr/local/bin/cura_engine@cura_engine:@g" /home/"${BASE_USER}"/.octoprint/config.yaml fi ### Streamer select service. From ff9f931753db5bb8388a541015f1474af3872456 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Thu, 7 Jan 2021 13:18:39 +0200 Subject: [PATCH 300/352] Add Ubuntu arm64bit variant --- src/variants/ubuntu_arm64/config | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100755 src/variants/ubuntu_arm64/config diff --git a/src/variants/ubuntu_arm64/config b/src/variants/ubuntu_arm64/config new file mode 100755 index 00000000..5fa90462 --- /dev/null +++ b/src/variants/ubuntu_arm64/config @@ -0,0 +1,8 @@ +export BASE_ARCH=aarch64 +export BASE_DISTRO=ubuntu + +export BASE_IMAGE_PATH=${DIST_PATH}/image-ubuntu_arm64 +export BASE_ZIP_IMG=`ls -t $BASE_IMAGE_PATH/*-{ubuntu}-*-arm64-*.xz | head -n 1` +export BASE_IGNORE_VARIANT_NAME=yes +export BASE_USER=pi +export BASE_USER_PASSWORD=raspberry From 4267ec6f07776d07829c1abc90c2dee606162208 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Mon, 11 Jan 2021 12:00:12 +0200 Subject: [PATCH 301/352] Add install libraspberrypi-bin for vcgencmd --- src/variants/ubuntu_arm64/post_chroot_script | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/variants/ubuntu_arm64/post_chroot_script diff --git a/src/variants/ubuntu_arm64/post_chroot_script b/src/variants/ubuntu_arm64/post_chroot_script new file mode 100644 index 00000000..ff0ed505 --- /dev/null +++ b/src/variants/ubuntu_arm64/post_chroot_script @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +set -x +set -e + +export LC_ALL=C + +source /common.sh +install_cleanup_trap + + +# add-apt-repository ppa:ubuntu-raspi2/ppa -y +apt-get update +apt-get -y --force-yes install libraspberrypi-bin +apt-get clean +apt-get autoremove -y From 1fe451932a5783c00274bf48348991a6a39dc2d1 Mon Sep 17 00:00:00 2001 From: Benjamin Urban Date: Sat, 23 Jan 2021 19:56:00 +0100 Subject: [PATCH 302/352] Add explanation of git wrapper script --- src/modules/octopi/filesystem/home/root/bin/git | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/modules/octopi/filesystem/home/root/bin/git b/src/modules/octopi/filesystem/home/root/bin/git index 39a0e07b..4e8a986a 100644 --- a/src/modules/octopi/filesystem/home/root/bin/git +++ b/src/modules/octopi/filesystem/home/root/bin/git @@ -3,6 +3,8 @@ if [ "$(id -u)" == "0" ] then echo "Please do not run git as root, your regular user account is enough :)" + echo "The rationale behind this restriction is to prevent cloning the OctoPrint" + echo "repository as root, which will most likely break some functionality." echo echo "If you need to run git with root rights for some other application than" echo "what comes preinstalled on this image you can remove this sanity check:" From b6b7f3623aa59021513693596537543b725aff04 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Sun, 31 Jan 2021 16:01:04 +0200 Subject: [PATCH 303/352] Increment version to 1.0.0, I think it's about time --- src/config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config b/src/config index bd3acbef..4a1cc5de 100755 --- a/src/config +++ b/src/config @@ -1,4 +1,4 @@ export DIST_NAME=OctoPi -export DIST_VERSION=0.18.0 +export DIST_VERSION=1.0.0 export MODULES="base(raspicam, network, disable-services(octopi), password-for-sudo)" From ca2840ced1dc6ae398e4c693927a4527514b042a Mon Sep 17 00:00:00 2001 From: Thomas Rose Date: Thu, 11 Feb 2021 15:59:32 +0100 Subject: [PATCH 304/352] Delete octopi-network.txt Remove unused long overdue legacy-file --- src/modules/octopi/filesystem/boot/octopi-network.txt | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 src/modules/octopi/filesystem/boot/octopi-network.txt diff --git a/src/modules/octopi/filesystem/boot/octopi-network.txt b/src/modules/octopi/filesystem/boot/octopi-network.txt deleted file mode 100644 index 85c4c0b1..00000000 --- a/src/modules/octopi/filesystem/boot/octopi-network.txt +++ /dev/null @@ -1,3 +0,0 @@ -# Using this file to configure your network connection is no longer supported. -# -# Please use octopi-wpa-supplicant.txt instead. From 61e0f4984f7ed1dabdca89cf1903674d4c5d0419 Mon Sep 17 00:00:00 2001 From: Thomas Rose Date: Thu, 11 Feb 2021 16:05:50 +0100 Subject: [PATCH 305/352] Small fixes for Ubuntu-Variant Make small changes to HAProxy and webcamd-config to make the Ubuntu-Variant start working - running with interface, normal webcam working (HLS not tested) --- .../filesystem/root/etc/haproxy/haproxy.cfg | 49 +++++++++++++++++++ .../root/etc/systemd/system/webcamd.service | 15 ++++++ 2 files changed, 64 insertions(+) create mode 100644 src/variants/ubuntu_arm64/filesystem/root/etc/haproxy/haproxy.cfg create mode 100644 src/variants/ubuntu_arm64/filesystem/root/etc/systemd/system/webcamd.service diff --git a/src/variants/ubuntu_arm64/filesystem/root/etc/haproxy/haproxy.cfg b/src/variants/ubuntu_arm64/filesystem/root/etc/haproxy/haproxy.cfg new file mode 100644 index 00000000..8ef4d164 --- /dev/null +++ b/src/variants/ubuntu_arm64/filesystem/root/etc/haproxy/haproxy.cfg @@ -0,0 +1,49 @@ +global + maxconn 4096 + user haproxy + group haproxy + log /dev/log local1 debug + tune.ssl.default-dh-param 2048 + +defaults + log global + mode http + compression algo gzip + option httplog + option dontlognull + retries 3 + option redispatch + option http-server-close + option forwardfor + maxconn 2000 + timeout connect 5s + timeout client 15min + timeout server 15min + +frontend public + bind :::80 v4v6 + bind :::443 v4v6 ssl crt /etc/ssl/snakeoil.pem + option forwardfor except 127.0.0.1 + use_backend webcam if { path_beg /webcam/ } + use_backend webcam_hls if { path_beg /hls/ } + use_backend webcam_hls if { path_beg /jpeg/ } + default_backend octoprint + +backend octoprint + acl needs_scheme req.hdr_cnt(X-Scheme) eq 0 + + http-request replace-path ^([^\ :]*)\ /(.*) \1\ /\2 + http-request add-header X-Scheme https if needs_scheme { ssl_fc } + http-request add-header X-Scheme http if needs_scheme !{ ssl_fc } + option forwardfor + server octoprint1 127.0.0.1:5000 + errorfile 503 /etc/haproxy/errors/503-no-octoprint.http + +backend webcam + http-request replace-path /webcam/(.*) /\1 + server webcam1 127.0.0.1:8080 + errorfile 503 /etc/haproxy/errors/503-no-webcam.http + +backend webcam_hls + server webcam_hls_1 127.0.0.1:28126 + errorfile 503 /etc/haproxy/errors/503-no-webcam-hls.http diff --git a/src/variants/ubuntu_arm64/filesystem/root/etc/systemd/system/webcamd.service b/src/variants/ubuntu_arm64/filesystem/root/etc/systemd/system/webcamd.service new file mode 100644 index 00000000..bd5feb53 --- /dev/null +++ b/src/variants/ubuntu_arm64/filesystem/root/etc/systemd/system/webcamd.service @@ -0,0 +1,15 @@ +[Unit] +Description=the OctoPi webcam daemon with the user specified config +# ConditionPathExists=/etc/octopi_streamer/mjpeg + +[Service] +WorkingDirectory=/root/bin +StandardOutput=append:/var/log/webcamd.log +StandardError=append:/var/log/webcamd.log +ExecStart=/root/bin/webcamd +Restart=always +Type=forking +RestartSec=1 + +[Install] +WantedBy=multi-user.target From 3214fe2cf5228a7ea2193726c3aefaa9e2dfe7e1 Mon Sep 17 00:00:00 2001 From: Thomas Rose Date: Thu, 11 Feb 2021 16:05:58 +0100 Subject: [PATCH 306/352] Revert "Delete octopi-network.txt" This reverts commit ca2840ced1dc6ae398e4c693927a4527514b042a. --- src/modules/octopi/filesystem/boot/octopi-network.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 src/modules/octopi/filesystem/boot/octopi-network.txt diff --git a/src/modules/octopi/filesystem/boot/octopi-network.txt b/src/modules/octopi/filesystem/boot/octopi-network.txt new file mode 100644 index 00000000..85c4c0b1 --- /dev/null +++ b/src/modules/octopi/filesystem/boot/octopi-network.txt @@ -0,0 +1,3 @@ +# Using this file to configure your network connection is no longer supported. +# +# Please use octopi-wpa-supplicant.txt instead. From 5d08be9d487834470d2d64a3e1b770d5466781f5 Mon Sep 17 00:00:00 2001 From: Thomas Rose Date: Thu, 11 Feb 2021 16:11:14 +0100 Subject: [PATCH 307/352] Update post_chroot_script Unpack filesystem changes for ubuntu --- src/variants/ubuntu_arm64/post_chroot_script | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/variants/ubuntu_arm64/post_chroot_script b/src/variants/ubuntu_arm64/post_chroot_script index ff0ed505..d699ad28 100644 --- a/src/variants/ubuntu_arm64/post_chroot_script +++ b/src/variants/ubuntu_arm64/post_chroot_script @@ -7,6 +7,8 @@ export LC_ALL=C source /common.sh install_cleanup_trap +# Unpack the filesystem changes for the variant +unpack /filesystem/root / # add-apt-repository ppa:ubuntu-raspi2/ppa -y apt-get update From d7e5121251b733878e4f52e31a8c9fe10c581b5e Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Mon, 22 Feb 2021 15:17:30 +0200 Subject: [PATCH 308/352] Add rpi.gpio-common https://github.com/guysoft/OctoPi/issues/711#issuecomment-783320975 --- src/variants/ubuntu_arm64/post_chroot_script | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/variants/ubuntu_arm64/post_chroot_script b/src/variants/ubuntu_arm64/post_chroot_script index d699ad28..918c8bc9 100644 --- a/src/variants/ubuntu_arm64/post_chroot_script +++ b/src/variants/ubuntu_arm64/post_chroot_script @@ -12,6 +12,6 @@ unpack /filesystem/root / # add-apt-repository ppa:ubuntu-raspi2/ppa -y apt-get update -apt-get -y --force-yes install libraspberrypi-bin +apt-get -y --force-yes install libraspberrypi-bin rpi.gpio-common apt-get clean apt-get autoremove -y From 8e9fa779ec7a9f82015281fa420773cc86f2fa8d Mon Sep 17 00:00:00 2001 From: Willmac16 Date: Sun, 28 Feb 2021 10:02:34 -0800 Subject: [PATCH 309/352] Compatibility for ws281x on Ubuntu 64 (#724) * Compatibility for ws281x on Ubuntu 64 * full paths for ws281x compatibility changes * remove the file touch --- .../filesystem/root/etc/udev/rules.d/50-spi.rules | 1 + src/variants/ubuntu_arm64/post_chroot_script | 5 +++++ 2 files changed, 6 insertions(+) create mode 100644 src/variants/ubuntu_arm64/filesystem/root/etc/udev/rules.d/50-spi.rules diff --git a/src/variants/ubuntu_arm64/filesystem/root/etc/udev/rules.d/50-spi.rules b/src/variants/ubuntu_arm64/filesystem/root/etc/udev/rules.d/50-spi.rules new file mode 100644 index 00000000..c7d5c8b1 --- /dev/null +++ b/src/variants/ubuntu_arm64/filesystem/root/etc/udev/rules.d/50-spi.rules @@ -0,0 +1 @@ +SUBSYSTEM=="spidev", GROUP="spi", MODE="0660" diff --git a/src/variants/ubuntu_arm64/post_chroot_script b/src/variants/ubuntu_arm64/post_chroot_script index 918c8bc9..b6c0ac89 100644 --- a/src/variants/ubuntu_arm64/post_chroot_script +++ b/src/variants/ubuntu_arm64/post_chroot_script @@ -15,3 +15,8 @@ apt-get update apt-get -y --force-yes install libraspberrypi-bin rpi.gpio-common apt-get clean apt-get autoremove -y + +# Compatibility for ws281x +sudo ln /boot/config-5.8.0-1006-raspi /boot/config.txt +sudo groupadd spi +sudo adduser pi spi From 8e02c9dca6fdba2f5fccf1676a2c158402bcb066 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Tue, 9 Mar 2021 12:08:53 +0200 Subject: [PATCH 310/352] Revert "Compatibility for ws281x on Ubuntu 64 (#724)" This reverts commit 8e9fa779ec7a9f82015281fa420773cc86f2fa8d. --- .../filesystem/root/etc/udev/rules.d/50-spi.rules | 1 - src/variants/ubuntu_arm64/post_chroot_script | 5 ----- 2 files changed, 6 deletions(-) delete mode 100644 src/variants/ubuntu_arm64/filesystem/root/etc/udev/rules.d/50-spi.rules diff --git a/src/variants/ubuntu_arm64/filesystem/root/etc/udev/rules.d/50-spi.rules b/src/variants/ubuntu_arm64/filesystem/root/etc/udev/rules.d/50-spi.rules deleted file mode 100644 index c7d5c8b1..00000000 --- a/src/variants/ubuntu_arm64/filesystem/root/etc/udev/rules.d/50-spi.rules +++ /dev/null @@ -1 +0,0 @@ -SUBSYSTEM=="spidev", GROUP="spi", MODE="0660" diff --git a/src/variants/ubuntu_arm64/post_chroot_script b/src/variants/ubuntu_arm64/post_chroot_script index b6c0ac89..918c8bc9 100644 --- a/src/variants/ubuntu_arm64/post_chroot_script +++ b/src/variants/ubuntu_arm64/post_chroot_script @@ -15,8 +15,3 @@ apt-get update apt-get -y --force-yes install libraspberrypi-bin rpi.gpio-common apt-get clean apt-get autoremove -y - -# Compatibility for ws281x -sudo ln /boot/config-5.8.0-1006-raspi /boot/config.txt -sudo groupadd spi -sudo adduser pi spi From ca3dbfb5758d6b85bb7d9c6ac9b8db4a81da949d Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Thu, 11 Mar 2021 12:08:37 +0200 Subject: [PATCH 311/352] Add rpi-imager compatible file https://github.com/raspberrypi/rpi-imager/issues/162 --- media/rpi-imager-OctoPi.png | Bin 0 -> 12860 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 media/rpi-imager-OctoPi.png diff --git a/media/rpi-imager-OctoPi.png b/media/rpi-imager-OctoPi.png new file mode 100644 index 0000000000000000000000000000000000000000..ac7388695cf586758462275abe325dfc5dc4567b GIT binary patch literal 12860 zcmV-CGQ-V@P) zaB^>EX>4U6ba`-PAZ2)IW&i+q+P$1-b|krSh5us}S^{hUSPtwt+JTm@@1n>yW1f+8 zG(FQKi&dEbBI23=a@_f^|Ge%$_^0P=E|=P@n|c1pJ@+{Hruol5{rw$$et*Az;`i^u z@2|Tbzlgk)_?kXH*75cJ!RzJc2Yy^<{{Fga?Z=%y7yA0e_XU&g9QkJdI!IoRpVveF zx==r#Z>+ca>riL>d|h8}d_(#A?|u)fe!l2u_v;I}vP!#fqZH#wA^G=r`-~vzzmNuB z6Mu&kcwgW(y<(0pC4Enc1^I1y-(S7|b%B0c4fmw z*U?hTtu$-3wbt9{u_rLFbnCUZ-uoEQ4Q@2J*5LhvS7w}P=2@oAI@|1XEYfG?RhF%~ z+UjfUxYGtEw(Yvx?t7fz4oGqGDaTGd?esG)xpvddw_LmRw%hOc5w)+V{^`%Z5w-9Y zwfG{X_thU!<5gGd_a%bhq$p-YEapJOt0F)`N5#yykaJYz6f@r=MNuMyEQ*cWK@lT_ z`Gi<*_z}CGk^7h8=1TjQ;uil|8nHzlhov&#f1+PZerSeWLpK{b>V& z93r*xzy13EccGgL;Mu6obb--&nM@Cb^kS9oA<8?DbGS>G>z{;qKS{`2}tS8w;n z)$L}-<@2nq%v^}UNxzLSrC$dB+i$`juk3!m^xqBqm$9*8#+Ab#R?JzuXXlYN*%0or z@D^$QT%@<|aqgH@O)m`oFTT3J`^8^=h5DA=xEjf5rClnUN-%44xK{RFGXn|pT=SGu z+h?S<+ARX@R;*LZHj`bZgd{k3PR~_fx}NUVU>Q9^E3CODbrTVg{0pKiR^${*TyW1l z<|1iM6!Fg)W;q0Px3jFWQZ*)JmxxUm(>6^Y6KeA7Z6Y+HhWkojb9VI3dNO8d-lcACtnQqBfPN(LhC3Auv9n3WIR_^)DS+ zxRRE?D+BKk$K@T5<#jec#nBUM)=5!vHW4|cR0!SRwPYhwS0t$J!r*FMSxdF|VQxf$ zx56h{TT+=xnJ0N~9o%eZlxVHDx?m}0N(?b-w)o*CC;^^mAS{QE6l@*-SJ!=j5 zhn*;iRG?g6Lyd#H7eyl*ZmB?z?o9vKuQRw zeSp_`$#FES;4J8-%%vhQ;x{bqOCIOof^b*7cT{v=8>}vtXd%!LZm4f0;AkKg*hnEw za2XxdU;{w{MVo{*Z8Ku7wpl~o!#L4%9lM0WM|wdEyYyb7q}ogg%%QF<1ptP%TqO`S zkN|9bqbFD4aak9tm@?gAw;AH@sqBfo9mUTB<{@AWCW6gbTT1xgvggSuP!CeC5NyBX z{sx=Ae)MBcM6H}8UneEz^KQ`99&2spKuieJOb(dL2K2-yYZxBvwKVg6VwlbIOWpbt zxx|=Sx+Diu`p!o6f=4-rbR0#NtS2oX6ow`Vnru7}uf6rF2+~3hgD7pFeMcy7W`H}Z zh#1Xibo1D(I1kzbUVd3ah>*Ff;Y3I1xMRo>b;O+}0FeQ2>nJ(mpt)4w4}=*zxm+zm zfN2$+EpTvf79=9e-xc|R3I+`bRz^S9c4`AxjaRQ;<%*q~<9AtX?DUIP5Gg@kaQemk zTRE?6C{Pwj)B|!fzC~Lc(y=WMLB*$@THdbQ#9dHhjCsusd)bpu48^!69=~J|0q!|V zufv)Mf0nBON|;3HD)eG-Unn4I|GOfOfD(VmS>TH61DrR(c))l;Ds?EcAD3^y)lwj^ z>_oHeLX1Cvg&tx-iKQ1YLNHhZ)l4Py1F%EV9V!fiGeF3*`2ebB7j6z4W@66LBNy}* z@Qk`cV)tei*1k{}s3PKr?kE%p=E9KC9HAM^q5Ju|T2>0U*jUeqDDz_>14_s%AiyeD zN{7T43<`RT567uQxlX2ry(0ORsizTPpg54}owYEN$I3ck#tnfr(`SyYV42Wyb zL270yGq=W&G*f}06ClF5IV$Wt5_s6%?AxUg6yV?h%sM@n4;4rI{rg)lNA&Q;TmZtgyJ0*m)P6E6nQ zRll2LiBDr9WecHfD7b|B1JQ16MhP5w$QW04gn{%T9X4tTl_&;6*pQ1;IYWKSn?KW# z5XwhGK^_8Vtl7R$`$bnA2N0up(G#eSgoCw$a*0ZUNrhJb*1HwJV$C!8RBHu2MnV!Y zZqOe8tm~rCx+<|rTc{zfCn-uMi{L z2(X)ke1gT)bt2J_bOqlqNh$_Sm4rwYVTlfz;j-8V{sbkZoVom}12t<1{DM&Pa6j{b znGdFbEJQQFGGqOXd1Y~K_H`(M_7pJNk7(pAYV`&2k`0W*Bgdn9KoS}ksSSz4W;;gH2v60Woidp zo-I-aTr;EiAy#03;sq|aW8I=l$OpNZfC}{ERNtc@a!4w>jJhw(G1US=n{HCt!iyP3 zdBL<`1nYI+M08jeT6GK&)%-~@MtT`}>j5Ek9pZreKz!v3mnE|JCU6R$I4xsx$?y(y zH6lW3^B!gV%m7C!l>1OUl~uO`v=E%4FG?GEWS(&+D2Zi7Y+EL4hX8Jujch2)q8R!G zR9R)~r*c@=>X1*^9XN~0;zEIm5G`N)=F9$tXdH;?El2qJH!Mvbg`^=VK*?_ToAj<~cnGifj0<=;tUKVjS3?DP zWJy%oUJNld*(LKTyTVjDx2)|Z)?+D05HXkA~4(eS!*?cIstY4~Y$3TRP0JMHfTw#%`skD?O zhAFus=Cw^g$cf$%{aD=z7J5?yMbOV6JGOuU;YhJaet08~NEg-wj0M?GV{w6YRKr2i zUXouX6a|9T2)VBtVI%4q!8VB#h6QX!Uk(1>q&X_AD=% z2l(#>Dv<+-WP(XCEG()u93<3xWJuG8`HScx%721+Sa)ObikP2EBP~~rSzSgJ{~8`O zApsQ;SOm=|Pl)G4DV^8BS6<~Pk%9;zroKK`s`LgZ=5A3Lj(XduOa|hC+5tEg;RMKC z&QDZnbmG)EI&}5s;uvAW zA*}VaR*t4O<;|S74Q8$fzAINjiW4=9iwAS)zBd?`cq>^;sZTMmkfgc!`te2N+IW}qY&tEAn#PF#I; z7X}~!bM|Qo?mM)My4ewL#P`e9Io<;o<-E2*LuvSb@}4uX`K!r-E|!0=2K zk!Qtgc*tEeB!UCP4S@JmZysW43B^VgzB(4E4fGKUh{NI?R2Ur4zpf|AL((Q)hBZK7 z*Cm-rsqNzNY=mNYF56xM!nzC4EI^Ao1Rfcxdct9-#z<$OjRxnDW6%(gj+tEuY$-C1%(pAf!iJHkyLF)b-FG8-UkDrnx9{ z8XpzTag~Ko>i81RB}qF!bowTS0v*<(icKHXww-Ot9Vn z_$dpC)W-E8`|_J_M&l3w-n&~@cA~aj!zz=W>3K1<6zF&~6|{!$P^;2&0340*6o8X* z2CqmkTy9Z;U^sf5)2UeojP6b5UrS~?G@;&1=t9`4%C!9)gds%=+H5P4BMlFQR8?SY@Df+wqK8w zd$JD5s-&JMkPO6ZQ#S#HoXBbqFNWf@k(9_0Bs`;ti4=fQ7|v{@al^?X({ULTt-y!O zOsIAO`<7!(48#&fxkJT`AlIl`lO{lONVlb?eYX3~MIdqZEpjEyPrZswiBStw9C}Y1 z!Ns8)zS^$qQWis!xMoHTA#p3L%@s**yrr5?#M6&Wkx`9@`}=~J*r8>I>91A&D{`9P zYYA-v6WryB7#`!G9OUSF72r)`9~V{|Z|5KIxv4|~9hZ8hzFke>+fuMW?Y(_Y=}-6;TY_&ls1t;tA^ z0RBy>*+allzEG$(>0nzN7Ndl3;SOyvq4af)hVAxd3HK4F4&6^}nEI2H4(@D=_?FT-2U=c*gj#3cX?p%PI z@eCEbUk|)1T)rM$+$ej5xPN=fOP!Vr5F(sg$Ri`1DQkdD5+%b?NGp#;OzN&^$12+U zIRH|Esg8nTeBK&~bn&=Rm__BScYDYCag?9d&09MRM|@!DSYm?9L~A{Hf~7bq9PCwYK^)SU%L*f;EhTg+#gv;^^=0?a4~dz*kt*U zjBa-!;jwh)*ciINdsTV6!cVyd`typuA)s&PXU7<`7_^Fg~P*Z}HT+x5{WG;qd& ztEn}OrN%WnKp&mQcvXvl0>rK@wn)AMOi4}lkFssZ2Rsuz3=vx)-(hY_9(y5koFtUn5q$%SX#_@e5G=7%F>v4NjoOVS z4~C<`0xcEwAqycH^w{FPKx~)8Os}zoMMK-LM)CQMg;2TmDVMj8nRKWDWV^7$>+PcK zH1mUy!I_kuQ!Iu5{+!b^}!>XUmrX-wv? zJrF!|2HUA@tP|-YB2o)|ACUKGpYv_SH*LlfKhkz#9<`^71$VIl7NZ0~@bwYgT@rSH zBnkrUKsvxsWRr&{yLL>X(u6VvIzi=B0NB@Wt0of_y$ z0lbznF<`Y`=(#glY-Ds@+Xc{nOf~b+dpMQcUv0K4>7#}gwMoo%!p<^cn5=4NJ)slu zh*iE1tq`61A`~$b;O;sDb~K4+{9)gBTmkKsIte`?CD1iXy5jek5P2uz1?^ml_B8^Z zWza_05Phr5fjL*QFR|J10DM|76LdpGAu8}e6uD{`#g5ch_*KOC$=qZnDO)q#VAh5d zhLe8*Sq6ae)n@7?;wB0Lw8zm|MBWEhxq3fP8r2i>+^fIl5-~4=QUsNRUH9UY^15qy zU%{u2=X}5!`VIH((=s=NL`0lZlO~lLG+arVr#y>+wd$;OBqCUQ$LEw!OL?dtd4i5r z?^wtbgdW;L-E)EP_Pzor1f^c>(@;Zeyo+5XuBSH>6KQoK9pkVF3FYqR+d#F>#-I7{ST{&<=M@ISp zkajQ}YQ$zw#I){x~^X@y3eayC8`sm zUGg|b>W$1vMyzE$qGW26z+K@TV}V3FmzNK&YrSE z5dlzK0ks0WRke`C*kmRMgnjJffZEVOee(30`?v)Uq@IYTr^+ZYG6;NwPX-CpwEM3e zxU~tG(k~PYfwt_S4`+OIm9EWioB zGSZx|tB+81bZ<+o%NoC%Soj=-T*G?3HIAi*P7}Zk?1>8vR zmJ|u#iTR12TtUF16he6$yOaxekm0mP8|Cr_TYB~v~JnYJ2PJ*fkyc$MNQq=smQ@{3<+}~{~{drHRXKf2Y;5rG3 zk>p||3WgPB)w0t7iaLhxNCrFzifWTt0)G!Ru%h;JOO7Wmjdyv{L?;z-x)1=c3ci%( zq~I&FE?uo#t%|k@gKu1c>R9NxcL8mG)*jFE7?7$x(YCamE-@M$^o6N-8z_uggcc?M zj*O&W33p2BYYABbd@fSKw~=0TrURQF^{W|Ob~5FZaCpXr5!d3^n9@T+x1y7q+V5OA z2Vj&Gz`{bLXpGN!A#6#m+}Z(za$g#0&>?EPMV?+eO-RPh7(C`QPVs40(@Q(t&p_xD zfldr1giZJ6JPKhbAOgG9SSTud7IpbA%dB#G$A@(6I!MlvqOUODSqLu~@lGhXu0sY| z8ZnMxL0K1cj8+Fnt8IAvg1Ycj_*~Q5Ni1!{L14P_jFQBvd8hMbVUfu!%Yp~+UTV7m ziRqn{gLVVF>$N$x$?ghdk^+8H44BegFd4Y0NsD9(k3?>QGrZ4@uHoB*ce-TnTjB1&MsAgsi&;~H$y5_ z9qD}MR6otD1-4Nr8ZBl_u+lDRXRYdh3HEc9^v)k$v<~kMzU$~Z<-RK7U;BdLyfb&Z zQSmDF*l|J>leV$cZ9_q}Yp;c+y(2($>HIh*9;DDlF5v!od~c}A;ukUyy!je8A}M^B zdV1#d#L;KB*6DNzco%jPilSA3G`uL&=vfa2sC_~G>*&aPaeckWY(EFrNZS6l=loHw zW*h1fsX~zy5{pX*)0Uh8 z@($<-P=!Zy_Kv{Sv2oZBXk7`+)s6syFzaa@u*&D4LvsAr;Or%RB(|-XvBHe~k%dkS7K;BJu82}669>0%-%!<-O&D(mW2t|w zeK$Rh_SN^YIWzsI!hx|ouSa? zxzoCTc80h5M4$(nuWMuc)AOHdwM-q}ozjO`0)h2sf3U}=A^B>{J@*n*RiCajNxqZ< z-WvU$6sEqxEvm77o~ijX!vZk9U>{O2DVZQR9rtJ$+^zFztkME(wN;hpl&i~HRO|q- zd34bA9@0iQ2t9y@S4)=hzO?`$60=d);(z%RF4)hGPOOJ6it%X!y)yWewRdtPQi&@W=LfNHY z@colAO7gN0`%7)jrK4D_4ee@A46_6=%ZYb{MCXr+){(c4^LBF1)reusgJmf`YyS^I z3LZn8(|yhBPeboeDj4ii^cc;%7j7a*S#>RT7mI%twVFIYot_keaM9?HVkhhchfFcm z-S{9P5zPzlurwb81IhI$%s)Gee@p*5K0g@yz4qB>mZGF2)%Un9xu1LA-#rnX`(7Ol zew)|PQ+eb2+8uM~U^JL>reWcddAws4u#y)6On3+pxvqNC83J=2ak&Qb5~R9_b?M zUQyoKIovozw5%R~(UT&lgsbNRN*_sMM6T-mhh!L06H#m(WC0JjY0`Gt6uqKoCiZd}VPrvxR_)Uh#xKDY>P4{R!)YUA1Mv!#jYMR#Y^KO3pD@$Vb6@H<0?B&PL9NJ~ zKMxZ&R#H2z1%Og#6fFn~gZg@U=kth85QlFadwzkaWj85wBot1IT6?F%{SrVOX@@O|l>h3?(>wC? zU0dtxp~j>}iHghBS6!yZ;O4t8F5$WSuVqCk< z^i?#8fQ)ixbs%&d0&7tRUC1{8(6H~W$-ElUBp_eniGj9-HHj-x zM5aeE^%&pQLv^5ULs$wZi}pBE1vNe#2X<0YamUmai(k zsHaZ8x~KK?$`|!-G8=gMcOS^3>{(eoB?UCp&u&e0UI*}5S)Ek`+jL+keNHIo{|I9* zE^6N_9fG}RRc&V1`gxFBl2Q%gXu%;3-V@k*isXA|DEr@chT=zvCLJ8muD-7yCHz?w zvhQ9NTTN(2eBp51@_vtbQ#6~B*HN;M6pnwI&*w7nO-RY&bO5LoZLPfr*!74+?gLMs zZ#+q@XjXbr#Rqyu25M^8tLrL_86;%&gv@e!j0l;mhY+=kW{{_pJpWFe+I@$+ch*v< z(d%Di`6TPw^JnttOa_VaXGD5hzNI%v{ofYe!1YAndwy&MJzZovwmXWRS$!)*9gAbr zS=z3w*PY+5^tq0f_8l`J+pkX)j<4_XI%M>TBXFr>G4BK=K;d118}-0|9yN=B{6;8Y zyD&Z&fzQI}B%6*r?^NDVk%FY}dRnx<$2_R&qUUK#dsF&OBKRQuXek7aXK%ftwECky>FA?%=C{h&3wMot$!zi`^q0}U5`c6~1 zxqt-uPB7J{^5$n=ew{UOpBRC{>Cg4^T|TN`tv%AmzZ}&dfFjI}_RwFsxc-j_{onZN z{-+=O*Dk~oqtU(lZ+&kKVjd|^MF0Q+glR)VP)S2WAaHVTW@&6?004NLeUUv#!$2Ix zUsFq^Rvhdg;*gR@vHgeDD1ii@M*T5#}VvFhOBtgC~oAP9bd zxVbqgx=4xtOA0MwJUH&hyL*qjcYx5WGS%!E2UN{6(#eFF&8>>TSNPF~5CVwF%+%*3 zDFx5*bq^n3@8Uem``n+SKVL8z;1h{wnQmCb8^qI_md<&fIKs+up7@-2%%BSrKXP4h z`HgeQVS#5xj7)l-I6^Fzx>)IARyI`PDdK2e)hJ)cx}4{{#aXS^S^J*+h2es>vdndw zBS>NqOOPN!K^+xTVIfYdMv93v?I%3^!;W7fmqM-z7&#VDg9_R4ga5(rZq4H4gqsvj z0D%|V{ul*yD=E0hc?#(3373 zvLpFv3dJJuen#Jv0|sw_(3;y@dmpC{K!&mKj!?e6X0GwuF<02AqQ zfjd5{X#fBK24YJ`L;(K){{a7>y{D4^000SaNLh0L01ejw01ejxLMWSf00007bV*G` z2jv3`3I;Zgi)x7g00`tsL_t(o!|j-Rj8xSf$3MSw@67DX&c3)iy9?|KDT;zSJq-rZL8vSo^S=n#Ps3wmw?5rj0E&B1!^{Ox3DTs1>BLEbI#G zgV~wgWq0R!?>(n~a9Lqd5yUo4_$HH?%$#$6-}#;2@g;*u0R>M2}2ph9W z3ZFVbC&iNKYR+Rf)Za2KYDHy5=2`Q`&}yyvuuTk&K_rjpnYd>qF19YOze>uw#3Px9 zM|SIfe>e`s zN{+3GSV9353I#nfGU5Z&S0t3eHt)xcg%hne0HdR$em8@7S?J`p5hI`+M)303JGs+_}Iu z;F-YYlfZ5#MQ1>Ke-=9_o&lCg9*;aeA#78HpiqDZT$xSs96;h}eo&ogy5mf9ww_ga zlG&o)R{t1Ti>bv%CPT)^DDD|GNfw39(%Z(~l`eaW%A|WA8u}WyAE*Yv3Lu0*%QyxX zk0_RjVFP~wmWq>N37Y5CF0_pC8n79-44Vc$3vHseJl~LBGJNWs5f1mDPE3gV5 z6)Xfe2e>)-d^Z+*Of5bkEL_OliZy-%72`J$$$b~wxCj=?)Zt^12JQ&^u6zVJV z=)IAi(4kh*GJ=o65J6!Onc$m4%Xs3juC)ELQl8MSfZb%u1Wrc6$XgiQ=vji6-!+tlIe z7J7hFvq{WRsTpS-5rm@T@l_9kk1`E-x(N%AxYTn&%@V3~J$^Wk?b%xL7z~&g;)i^t zMB!?e_4{6<*W0|`;3%%zMFH8>q`B89idFn?hX!zKLP^r=n#7U-B3=h^uQb zi|Wq_xg}BWdRwTdDGt(* zR)Kv%?Mm3jHgVrEPAOp;3(ZWAwn;^6NKKM67(p;%L_}m!^I~gerp0@AVvF?KT^8X( z^wTi#7;yJ7%Pnia>nnh&gJ>(1SXN`LRjx-F>!9l>iJ^EO+?0ilS@49}yvdagOOn9#PHum?&Dq_%mz?_{t}+g{CBy>Gfy8;<{FTB=`l zyCVbYO?NBl@(v+_F)@s(MhIaAHjbI#CMl6rU04_d8?C3Kzj(@0%g%+>;+GOuU8cbH zaDkKGX|x7nZLIT8rgqmJxv0=h-lT~~W`#aC`y{H)Yv=jyKX|$RAtfVN^keiKd{e<& zA6rp>0Dfp9d|uDuY+%$>Qi~87EcSD0c%F&3c%rMIRgF^4mI>9n$gqo3W6%?MqG3&> zMrdxnz*9=rs2NyhM0FS$S&_w|qNYmXLw|D<1d{iMBP3*O7*TlV_e_NGPm zCK{{XniY*U4)~Q$#GfG5-X4AT>L8FnGgmzrJ-~G zK38LH9Z1OVM50hARvXu=a9yv$E0yDBUv64)^PZ-%Qe!qieJ28(5~xHCymDNh%{VE( zkKrCQh$s8ljIi5_GynP-Z20NvGy(Ipj>JJJQH7j9?}OXuxu=&!6%+gm!wgf+XLS=6 ziuFj)i$2WOVW*+0uTDXs**9t`F^fjD@M6F7nY a6Z{80o*0GGKAEQg0000 Date: Sun, 14 Mar 2021 21:36:59 +0100 Subject: [PATCH 312/352] Add a network monitoring for wifi connections --- src/modules/octopi/filesystem/boot/octopi.txt | 10 +++++++ .../etc/systemd/system/networkcheck.service | 8 ++++++ .../etc/systemd/system/networkcheck.timer | 10 +++++++ .../root/usr/local/bin/networkcheck | 28 +++++++++++++++++++ src/modules/octopi/start_chroot_script | 4 +++ 5 files changed, 60 insertions(+) create mode 100644 src/modules/octopi/filesystem/root/etc/systemd/system/networkcheck.service create mode 100644 src/modules/octopi/filesystem/root/etc/systemd/system/networkcheck.timer create mode 100755 src/modules/octopi/filesystem/root/usr/local/bin/networkcheck diff --git a/src/modules/octopi/filesystem/boot/octopi.txt b/src/modules/octopi/filesystem/boot/octopi.txt index bc015399..c842c6b4 100644 --- a/src/modules/octopi/filesystem/boot/octopi.txt +++ b/src/modules/octopi/filesystem/boot/octopi.txt @@ -76,6 +76,16 @@ #camera_http_webroot="./www-octopi" #camera_http_options="-n" +# Configuration of network monitoring +# +# This enables network monitoring for wifi connections with a simple ping test. +# If connection terminates by variable reasons system tries to restart the wifi connection to reestablish a connection. +# The connection test is done every minute. +# By default it is disabled (0 = off / 1 = on) +# dstination_host can be an ip address or a hostname (for hostname ensure dns resosultion is working correctly) +enable_network_monitor=0 +destination_host=192.168.1.1 + ### EXPERIMENTAL # Support for different streamer types. # diff --git a/src/modules/octopi/filesystem/root/etc/systemd/system/networkcheck.service b/src/modules/octopi/filesystem/root/etc/systemd/system/networkcheck.service new file mode 100644 index 00000000..ec4a008e --- /dev/null +++ b/src/modules/octopi/filesystem/root/etc/systemd/system/networkcheck.service @@ -0,0 +1,8 @@ +[Unit] + Description=Network Monitor + ConditionPathExists=/usr/local/bin/networkcheck + +[Service] + User=root + Type=simple + ExecStart=/usr/local/bin/networkcheck & diff --git a/src/modules/octopi/filesystem/root/etc/systemd/system/networkcheck.timer b/src/modules/octopi/filesystem/root/etc/systemd/system/networkcheck.timer new file mode 100644 index 00000000..940694fe --- /dev/null +++ b/src/modules/octopi/filesystem/root/etc/systemd/system/networkcheck.timer @@ -0,0 +1,10 @@ +[Unit] + Description=Network Monitor Trigger (every 1 minutes) + After=network.target + +[Timer] + OnCalendar=*-*-* *:*:00 + AccuracySec=1s + +[Install] + WantedBy=timers.target diff --git a/src/modules/octopi/filesystem/root/usr/local/bin/networkcheck b/src/modules/octopi/filesystem/root/usr/local/bin/networkcheck new file mode 100755 index 00000000..0ab1f406 --- /dev/null +++ b/src/modules/octopi/filesystem/root/usr/local/bin/networkcheck @@ -0,0 +1,28 @@ +#!/bin/bash + +source /boot/octopi.txt + +if [ $enable_network_monitor == 1 ] && [ "$destination_host" != "" ]; then + + if [ -f /boot/octopi-wpa-supplicant.txt ]; then # check if config file exists + input="/boot/octopi-wpa-supplicant.txt" + while IFS= read -r line; do # read config file line by line + if [[ $line =~ ^network=.* ]]; then # check if we have a network config if a line starts with "network=" + echo "network config found..." + ping -c4 $destination_host > /dev/null # check if destination is reachable - possible by default the router + if [ $? != 0 ]; then + echo "Destination not reachable - reconfigure interface..." + sudo wpa_cli -i wlan0 reconfigure # reconfigure network to trigger reconnect + sudo dhclient -v # ensure connection will be established by refresh dhcp lease + echo "Reconnect done." + exit 0 # if we detect multiple network configs exit after 1st one - one reconnect is enough :-) + else + echo "Destination reachable - no action needed." + exit 0 # destination reached - exit loop + fi + fi + done < "$input" + fi +else + echo "Network monitoring not enabled." +fi diff --git a/src/modules/octopi/start_chroot_script b/src/modules/octopi/start_chroot_script index 6398aea4..915f13d1 100755 --- a/src/modules/octopi/start_chroot_script +++ b/src/modules/octopi/start_chroot_script @@ -258,6 +258,10 @@ fi systemctl_if_exists enable ffmpeg_hls.service +### Network monitoring + +systemctl_if_exists enable networkcheck.timer + #cleanup apt-get clean apt-get autoremove -y From ba1750c1d560749d3e997b194f3609cf6ddb5f62 Mon Sep 17 00:00:00 2001 From: hawkeyexp Date: Tue, 16 Mar 2021 03:52:10 +0100 Subject: [PATCH 313/352] Add avrdude for firmware flashing --- src/modules/octopi/start_chroot_script | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/modules/octopi/start_chroot_script b/src/modules/octopi/start_chroot_script index 915f13d1..eed1e5e5 100755 --- a/src/modules/octopi/start_chroot_script +++ b/src/modules/octopi/start_chroot_script @@ -262,6 +262,11 @@ systemctl_if_exists enable ffmpeg_hls.service systemctl_if_exists enable networkcheck.timer +### Firmare flashing + +echo "--- Installing avrdude" +apt-get -y install avrdude + #cleanup apt-get clean apt-get autoremove -y From 4e64f6886953382b336043b46541f6e3dc8971f2 Mon Sep 17 00:00:00 2001 From: Jamie Date: Sun, 21 Mar 2021 18:18:46 -0500 Subject: [PATCH 314/352] Fix problem where cmake fails to detect compiler Found this fix while examining why v1pi was failing to build. Apparently current cmake (3.16) fails with the GLOB operation and it sounds like it's related to this issue https://gitlab.kitware.com/cmake/cmake/-/issues/20568 According to that thread, this is a consequence of an update within 3.15, and (probably) fixed sometime before 3.19. --- src/modules/octopi/start_chroot_script | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/octopi/start_chroot_script b/src/modules/octopi/start_chroot_script index eed1e5e5..c9037645 100755 --- a/src/modules/octopi/start_chroot_script +++ b/src/modules/octopi/start_chroot_script @@ -33,7 +33,7 @@ echo "removing:" $remove_extra apt-get remove -y --purge $remove_extra apt-get autoremove -y -apt-get -y --force-yes install python3 python3-virtualenv python3-dev git screen subversion cmake avahi-daemon libavahi-compat-libdnssd1 libffi-dev libssl-dev libatlas3-base +apt-get -y --force-yes install python3 python3-virtualenv python3-dev git screen subversion cmake=3.13.4-1 cmake-data=3.13.4-1 avahi-daemon libavahi-compat-libdnssd1 libffi-dev libssl-dev libatlas3-base echo " - Reinstall iputils-ping" apt-get install --reinstall iputils-ping From 73735b8f12eafd0e7de8f1de5aef4b7551e6bf2b Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Sun, 4 Apr 2021 13:39:53 +0300 Subject: [PATCH 315/352] Fix build on Ubuntu arm64 #731 --- src/modules/octopi/start_chroot_script | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/modules/octopi/start_chroot_script b/src/modules/octopi/start_chroot_script index c9037645..38d3f69e 100755 --- a/src/modules/octopi/start_chroot_script +++ b/src/modules/octopi/start_chroot_script @@ -33,7 +33,12 @@ echo "removing:" $remove_extra apt-get remove -y --purge $remove_extra apt-get autoremove -y -apt-get -y --force-yes install python3 python3-virtualenv python3-dev git screen subversion cmake=3.13.4-1 cmake-data=3.13.4-1 avahi-daemon libavahi-compat-libdnssd1 libffi-dev libssl-dev libatlas3-base +if [ "${BASE_DISTRO}" == "ubuntu" ]; then + apt-get -y --force-yes install python3 python3-virtualenv python3-dev git screen subversion cmake cmake-data avahi-daemon libavahi-compat-libdnssd1 libffi-dev libssl-dev libatlas3-base +else + apt-get -y --force-yes install python3 python3-virtualenv python3-dev git screen subversion cmake=3.13.4-1 cmake-data=3.13.4-1 avahi-daemon libavahi-compat-libdnssd1 libffi-dev libssl-dev libatlas3-base +fi + echo " - Reinstall iputils-ping" apt-get install --reinstall iputils-ping From 3595898c11c6bd8a017202434ba5c9651e37dea2 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Thu, 17 Jun 2021 13:46:15 +0300 Subject: [PATCH 316/352] Enlarge build root so there is enough space --- src/config | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/config b/src/config index 4a1cc5de..60299236 100755 --- a/src/config +++ b/src/config @@ -2,3 +2,5 @@ export DIST_NAME=OctoPi export DIST_VERSION=1.0.0 export MODULES="base(raspicam, network, disable-services(octopi), password-for-sudo)" +export BASE_IMAGE_ENLARGEROOT=2000 +export BASE_IMAGE_RESIZEROOT=200 From 1a00e6ec9b586760080f456c5ff4692749581b40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 29 Jun 2021 14:38:12 +0200 Subject: [PATCH 317/352] =?UTF-8?q?=F0=9F=90=9B=20Restore=20120s=20daemon?= =?UTF-8?q?=20loop=20behaviour?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We wait for our child processes to complete, reset our "currently run cameras" array, then wait 2min and loop. Closes #740 --- .../octopi/filesystem/home/root/bin/webcamd | 30 ++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/src/modules/octopi/filesystem/home/root/bin/webcamd b/src/modules/octopi/filesystem/home/root/bin/webcamd index effdfbe2..c372e142 100755 --- a/src/modules/octopi/filesystem/home/root/bin/webcamd +++ b/src/modules/octopi/filesystem/home/root/bin/webcamd @@ -104,6 +104,14 @@ function cleanup() { exit 0 } +# waits for our child processes +function awaitChildren() { + local pids=$(jobs -pr) + for pid in $pids; do + wait $pid + done +} + # says goodbye when the script shuts down function goodbye() { # say goodbye @@ -237,6 +245,7 @@ while true; do camera_http_webroot="${array_camera_http_webroot[${i}]}" camera_http_options="${array_camera_http_options[${i}]}" brokenfps_usb_devices="${array_camera_brokenfps_usb_devices[${i}]}" + if [[ ${camera_usb_device} ]] && { [[ "usb" == ${scan_mode} ]] || [[ "auto" == ${scan_mode} ]]; }; then # usb device is explicitly set in options usb_device_path=`readlink -f ${camera_usb_device}` @@ -253,6 +262,7 @@ while true; do startUsb "$usb_device_path" continue fi + elif [[ -z ${camera_usb_device} ]] && { [[ "usb-auto" == ${scan_mode} ]] || [[ "auto" == ${scan_mode} ]]; }; then for video_device in "${video_devices[@]}"; do if [[ "raspi" != "$video_device" ]]; then @@ -271,6 +281,7 @@ while true; do continue fi fi + if [[ "raspi" == ${scan_mode} ]] || [[ "auto" == ${scan_mode} ]]; then video_device="raspi" if containsString "$video_device" "${array_camera_device[@]}"; then @@ -290,14 +301,19 @@ while true; do fi done done + array_assigned_device=( ${array_camera_device[*]} ) if [[ ${#array_camera[@]} -eq ${#array_assigned_device[@]} ]]; then - echo "Done bring up all configured video device" - exit 0 - else - echo "Scan again in two minutes" - sleep 120 & - sleep_pid=$! - wait ${sleep_pid} + echo "Done bringing up all configured video devices" + awaitChildren + + # reset array_camera_device to empty + array_camera_device=() + for cam in ${array_camera[@]}; do + array_camera_device+=("") + done fi + + echo "Scanning again in two minutes" + sleep 120 done From 3dc1381937922f59fe46c9ddd75d1a6278841b55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 29 Jun 2021 14:38:43 +0200 Subject: [PATCH 318/352] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20Fix=20some=20typos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/octopi/filesystem/home/root/bin/webcamd | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/modules/octopi/filesystem/home/root/bin/webcamd b/src/modules/octopi/filesystem/home/root/bin/webcamd index c372e142..2af5a790 100755 --- a/src/modules/octopi/filesystem/home/root/bin/webcamd +++ b/src/modules/octopi/filesystem/home/root/bin/webcamd @@ -73,7 +73,7 @@ for cfg_file in ${cfg_files[@]}; do echo "raspi options: $camera_raspi_options" echo "http options: -w $camera_http_webroot $camera_http_options" echo "" - echo "Explicitly USB device: $extracted_device" + echo "Explicitly set USB device: $extracted_device" echo "-----------------------------------------------" echo "" @@ -251,7 +251,7 @@ while true; do usb_device_path=`readlink -f ${camera_usb_device}` if containsString "$usb_device_path" "${array_camera_device[@]}"; then if [[ "auto" != ${scan_mode} ]]; then - array_camera_device[${i}]="alredy_in_use" + array_camera_device[${i}]="already_in_use" echo "config file='$camera_config':Video device already in use." continue fi @@ -286,7 +286,7 @@ while true; do video_device="raspi" if containsString "$video_device" "${array_camera_device[@]}"; then if [[ "auto" != ${scan_mode} ]]; then - array_camera_device[${i}]="alredy_in_use" + array_camera_device[${i}]="already_in_use" echo "config file='$camera_config':RasPiCam device already in use." fi elif containsString "$video_device" "${video_devices[@]}"; then From 8d1e000b549ee8aaba2aa4a6af6ef4ed87d56f49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 29 Jun 2021 14:39:29 +0200 Subject: [PATCH 319/352] =?UTF-8?q?=F0=9F=90=9B=20Fix=20handling=20of=20no?= =?UTF-8?q?n-usb=20v4l2=20devices?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit They don't have a vid and pid, so don't try to format those as hex. --- .../octopi/filesystem/home/root/bin/webcamd | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/modules/octopi/filesystem/home/root/bin/webcamd b/src/modules/octopi/filesystem/home/root/bin/webcamd index 2af5a790..4aded2e0 100755 --- a/src/modules/octopi/filesystem/home/root/bin/webcamd +++ b/src/modules/octopi/filesystem/home/root/bin/webcamd @@ -189,19 +189,22 @@ function startUsb { product=`cat $uevent_file | grep PRODUCT | cut -d"=" -f2` vid=`echo $product | cut -d"/" -f1` pid=`echo $product | cut -d"/" -f2` - vidpid=`printf "%04x:%04x" "0x$vid" "0x$pid"` - - # ... then look if it is in our list of known broken-fps-devices and if so remove - # the -f parameter from the options (if it's in there, else that's just a no-op) - for identifier in ${brokenfps_usb_devices[@]}; - do - if [ "$vidpid" = "$identifier" ]; then - echo - echo "Camera model $vidpid is known to not work with -f parameter, stripping it out" - echo - options=`echo $options | sed -e "s/\(\s\+\|^\)-f\s\+[0-9]\+//g"` - fi - done + + if [[ -n "$vid" && -n "$pid" ]]; then + vidpid=`printf "%04x:%04x" "0x$vid" "0x$pid"` + + # ... then look if it is in our list of known broken-fps-devices and if so remove + # the -f parameter from the options (if it's in there, else that's just a no-op) + for identifier in ${brokenfps_usb_devices[@]}; + do + if [ "$vidpid" = "$identifier" ]; then + echo + echo "Camera model $vidpid is known to not work with -f parameter, stripping it out" + echo + options=`echo $options | sed -e "s/\(\s\+\|^\)-f\s\+[0-9]\+//g"` + fi + done + fi fi logger -s "Starting USB webcam" From edfa3653d8a18de9bf4dc5dffecb4a92ff96bace Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 29 Jun 2021 14:42:33 +0200 Subject: [PATCH 320/352] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20Fix=20more=20typos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/octopi/filesystem/home/root/bin/webcamd | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/modules/octopi/filesystem/home/root/bin/webcamd b/src/modules/octopi/filesystem/home/root/bin/webcamd index 4aded2e0..8a01a40f 100755 --- a/src/modules/octopi/filesystem/home/root/bin/webcamd +++ b/src/modules/octopi/filesystem/home/root/bin/webcamd @@ -261,7 +261,7 @@ while true; do elif containsString "$usb_device_path" "${video_devices[@]}"; then array_camera_device[${i}]="$usb_device_path" # explicitly set usb device was found in video_devices array, start usb with the found device - echo "config file='$camera_config':USB device was set in options and found in devices, start MJPG-streamer with the configured USB video device: $usb_device_path" + echo "config file='$camera_config':USB device was set in options and found in devices, starting MJPG-streamer with the configured USB video device: $usb_device_path" startUsb "$usb_device_path" continue fi @@ -274,7 +274,7 @@ while true; do else array_camera_device[${i}]="$video_device" # device is not set explicitly in options, start usb with first found usb camera as the device - echo "config file='$camera_config':USB device was not set in options, start MJPG-streamer with the first found video device: ${video_device}" + echo "config file='$camera_config':USB device was not set in options, starting MJPG-streamer with the first found video device: ${video_device}" startUsb "${video_device}" break fi @@ -294,7 +294,7 @@ while true; do fi elif containsString "$video_device" "${video_devices[@]}"; then array_camera_device[${i}]="$video_device" - echo "config file='$camera_config':Start MJPG-streamer with video device: ${video_device}" + echo "config file='$camera_config':Starting MJPG-streamer with video device: ${video_device}" startRaspi sleep 30 & sleep_pid=$! From 8c9bd970e93064bfe49aae1e9fa72c112d4738ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 29 Jun 2021 15:42:17 +0200 Subject: [PATCH 321/352] =?UTF-8?q?=F0=9F=90=9B=20Add=20haproxy.cfg=20for?= =?UTF-8?q?=202.x=20versions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Build will check which one is installed and only enable the correct one. See also #711 --- .../haproxy/{haproxy.cfg => haproxy.1.x.cfg} | 0 .../root/etc/haproxy/haproxy.2.x.cfg | 49 +++++++++++++++++++ src/modules/octopi/start_chroot_script | 9 ++++ 3 files changed, 58 insertions(+) rename src/modules/octopi/filesystem/root/etc/haproxy/{haproxy.cfg => haproxy.1.x.cfg} (100%) create mode 100644 src/modules/octopi/filesystem/root/etc/haproxy/haproxy.2.x.cfg diff --git a/src/modules/octopi/filesystem/root/etc/haproxy/haproxy.cfg b/src/modules/octopi/filesystem/root/etc/haproxy/haproxy.1.x.cfg similarity index 100% rename from src/modules/octopi/filesystem/root/etc/haproxy/haproxy.cfg rename to src/modules/octopi/filesystem/root/etc/haproxy/haproxy.1.x.cfg diff --git a/src/modules/octopi/filesystem/root/etc/haproxy/haproxy.2.x.cfg b/src/modules/octopi/filesystem/root/etc/haproxy/haproxy.2.x.cfg new file mode 100644 index 00000000..8ef4d164 --- /dev/null +++ b/src/modules/octopi/filesystem/root/etc/haproxy/haproxy.2.x.cfg @@ -0,0 +1,49 @@ +global + maxconn 4096 + user haproxy + group haproxy + log /dev/log local1 debug + tune.ssl.default-dh-param 2048 + +defaults + log global + mode http + compression algo gzip + option httplog + option dontlognull + retries 3 + option redispatch + option http-server-close + option forwardfor + maxconn 2000 + timeout connect 5s + timeout client 15min + timeout server 15min + +frontend public + bind :::80 v4v6 + bind :::443 v4v6 ssl crt /etc/ssl/snakeoil.pem + option forwardfor except 127.0.0.1 + use_backend webcam if { path_beg /webcam/ } + use_backend webcam_hls if { path_beg /hls/ } + use_backend webcam_hls if { path_beg /jpeg/ } + default_backend octoprint + +backend octoprint + acl needs_scheme req.hdr_cnt(X-Scheme) eq 0 + + http-request replace-path ^([^\ :]*)\ /(.*) \1\ /\2 + http-request add-header X-Scheme https if needs_scheme { ssl_fc } + http-request add-header X-Scheme http if needs_scheme !{ ssl_fc } + option forwardfor + server octoprint1 127.0.0.1:5000 + errorfile 503 /etc/haproxy/errors/503-no-octoprint.http + +backend webcam + http-request replace-path /webcam/(.*) /\1 + server webcam1 127.0.0.1:8080 + errorfile 503 /etc/haproxy/errors/503-no-webcam.http + +backend webcam_hls + server webcam_hls_1 127.0.0.1:28126 + errorfile 503 /etc/haproxy/errors/503-no-webcam-hls.http diff --git a/src/modules/octopi/start_chroot_script b/src/modules/octopi/start_chroot_script index 38d3f69e..1b905a8e 100755 --- a/src/modules/octopi/start_chroot_script +++ b/src/modules/octopi/start_chroot_script @@ -227,6 +227,15 @@ fi if [ "$OCTOPI_INCLUDE_HAPROXY" == "yes" ] then systemctl_if_exists enable gencert.service + + haproxy_version=$(dpkg -s haproxy | grep '^Version:' | awk '{print $2}') + if [[ $haproxy_version = 2.* ]]; then + mv /etc/haproxy/haproxy.2.x.cfg /etc/haproxy/haproxy.cfg + rm /etc/haproxy/haproxy.1.x.cfg + else + mv /etc/haproxy/haproxy.1.x.cfg /etc/haproxy/haproxy.cfg + rm /etc/haproxy/haproxy.2.x.cfg + fi else # let's remove the configs for system services we don't need rm /etc/systemd/system/gencert.service From 9e473f14ad5e04c9dd6e5f4f4373860a26d25e46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Fri, 2 Jul 2021 18:02:23 +0200 Subject: [PATCH 322/352] =?UTF-8?q?=F0=9F=90=9B=20Remove=20mjpg-streamer?= =?UTF-8?q?=20from=20pi=20home?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It's executed as root so it shouldn't live in a user directory (potential for abuse w/ image access). Move it to /opt/mjpg-streamer, include symlink at old location for backwards compatibility. --- src/modules/octopi/config | 5 +-- .../octopi/filesystem/home/root/bin/webcamd | 2 +- src/modules/octopi/start_chroot_script | 42 ++++++++++++------- 3 files changed, 30 insertions(+), 19 deletions(-) diff --git a/src/modules/octopi/config b/src/modules/octopi/config index e9f3d064..43871615 100755 --- a/src/modules/octopi/config +++ b/src/modules/octopi/config @@ -12,10 +12,7 @@ [ -n "$OCTOPI_INCLUDE_CURAENGINE" ] || OCTOPI_INCLUDE_CURAENGINE=no # mjpg streamer -[ -n "$OCTOPI_MJPGSTREAMER_REPO_SHIP" ] || OCTOPI_MJPGSTREAMER_REPO_SHIP=https://github.com/jacksonliam/mjpg-streamer.git -[ -n "$OCTOPI_MJPGSTREAMER_REPO_BUILD" ] || OCTOPI_MJPGSTREAMER_REPO_BUILD= -[ -n "$OCTOPI_MJPGSTREAMER_REPO_BRANCH" ] || OCTOPI_MJPGSTREAMER_REPO_BRANCH=master -[ -n "$OCTOPI_MJPGSTREAMER_REPO_DEPTH" ] || OCTOPI_MJPGSTREAMER_REPO_DEPTH=1 +[ -n "$OCTOPI_MJPGSTREAMER_ARCHIVE" ] || OCTOPI_MJPGSTREAMER_ARCHIVE=https://github.com/jacksonliam/mjpg-streamer/archive/master.zip [ -n "$OCTOPI_INCLUDE_MJPGSTREAMER" ] || OCTOPI_INCLUDE_MJPGSTREAMER=yes # FFMPEG HLS diff --git a/src/modules/octopi/filesystem/home/root/bin/webcamd b/src/modules/octopi/filesystem/home/root/bin/webcamd index 8a01a40f..f2c6dfb1 100755 --- a/src/modules/octopi/filesystem/home/root/bin/webcamd +++ b/src/modules/octopi/filesystem/home/root/bin/webcamd @@ -11,7 +11,7 @@ ### computer. ### ######################################################################## -MJPGSTREAMER_HOME=/home/pi/mjpg-streamer +MJPGSTREAMER_HOME=/opt/mjpg-streamer MJPGSTREAMER_INPUT_USB="input_uvc.so" MJPGSTREAMER_INPUT_RASPICAM="input_raspicam.so" diff --git a/src/modules/octopi/start_chroot_script b/src/modules/octopi/start_chroot_script index 1b905a8e..e57442aa 100755 --- a/src/modules/octopi/start_chroot_script +++ b/src/modules/octopi/start_chroot_script @@ -59,7 +59,8 @@ pushd /home/"${BASE_USER}" #mjpg-streamer if [ "$OCTOPI_INCLUDE_MJPGSTREAMER" == "yes" ] then - echo "--- Installing mjpg-streamer" + install_dir=/opt/mjpg-streamer + echo "--- Installing mjpg-streamer to $install_dir" if [ $( is_in_apt libjpeg62-turbo-dev ) -eq 1 ]; then apt-get -y --force-yes install libjpeg62-turbo-dev elif [ $( is_in_apt libjpeg8-dev ) -eq 1 ]; then @@ -67,26 +68,35 @@ pushd /home/"${BASE_USER}" fi apt-get -y --force-yes --no-install-recommends install imagemagick ffmpeg libv4l-dev - gitclone OCTOPI_MJPGSTREAMER_REPO mjpg-streamer - pushd mjpg-streamer - mv mjpg-streamer-experimental/* . + wget $OCTOPI_MJPGSTREAMER_ARCHIVE -O mjpg-streamer.zip + unzip mjpg-streamer.zip + rm mjpg-streamer.zip + + pushd mjpg-streamer-master/mjpg-streamer-experimental # As said in Makefile, it is just a wrapper around CMake. # To apply -j option, we have to unwrap it. - MJPG_STREAMER_BUILD_DIR=_build - [ -d ${MJPG_STREAMER_BUILD_DIR} ] || (mkdir ${MJPG_STREAMER_BUILD_DIR} && \ - chown "${BASE_USER}:${BASE_USER}" ${MJPG_STREAMER_BUILD_DIR}) - [ -f ${MJPG_STREAMER_BUILD_DIR}/Makefile ] || (cd ${MJPG_STREAMER_BUILD_DIR} && \ - sudo -u "${BASE_USER}" cmake -DCMAKE${MJPG_STREAMER_BUILD_DIR}_TYPE=Release ..) + build_dir=_build + mkdir -p $build_dir + pushd $build_dir + cmake -DCMAKE_BUILD_TYPE=Release .. + popd + + make -j $(nproc) -C $build_dir - sudo -u "${BASE_USER}" make -j $(nproc) -C ${MJPG_STREAMER_BUILD_DIR} + mkdir -p $install_dir - sudo -u "${BASE_USER}" cp ${MJPG_STREAMER_BUILD_DIR}/mjpg_streamer . - sudo -u "${BASE_USER}" find ${MJPG_STREAMER_BUILD_DIR} -name "*.so" -type f -exec cp {} . \; + install -m 755 $build_dir/mjpg_streamer $install_dir + find $build_dir -name "*.so" -type f -exec install -m 644 {} $install_dir \; + + # copy bundled web folder + cp -a -r ./www $install_dir + chmod 755 $install_dir/www + chmod -R 644 $install_dir/www # create our custom web folder and add a minimal index.html to it - sudo -u "${BASE_USER}" mkdir www-octopi - pushd www-octopi + mkdir $install_dir/www-octopi + pushd $install_dir/www-octopi cat <> index.html mjpg_streamer test page @@ -101,6 +111,10 @@ pushd /home/"${BASE_USER}" EOT popd popd + rm -rf mjpg-streamer-master + + # symlink for backwards compatibility + sudo -u "${BASE_USER}" ln -s $install_dir /home/"${BASE_USER}"/mjpg-streamer fi # FFMPEG HLS From d36f1599cabca70d3aa21f6d0e481a0630f01d5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Fri, 2 Jul 2021 18:12:25 +0200 Subject: [PATCH 323/352] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Install=20OctoPrin?= =?UTF-8?q?t=20from=20PyPI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/octopi/config | 3 +-- src/modules/octopi/start_chroot_script | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/modules/octopi/config b/src/modules/octopi/config index e9f3d064..c9474d1f 100755 --- a/src/modules/octopi/config +++ b/src/modules/octopi/config @@ -2,8 +2,7 @@ # All our config settings must start with OCTOPI_ # OctoPrint archive -[ -n "$OCTOPI_OCTOPRINT_ARCHIVE" ] || OCTOPI_OCTOPRINT_ARCHIVE=$(wget -q -O - https://api.github.com/repos/foosel/OctoPrint/releases/latest | grep "zipball_url" | cut -d : -f 2,3 | tr -d \" | tr -d ,) -[ -n "$OCTOPI_OCTOPRINT_REPO_SHIP" ] || OCTOPI_OCTOPRINT_REPO_SHIP=https://github.com/foosel/OctoPrint.git +[ -n "$OCTOPI_OCTOPRINT_PACKAGE" ] || OCTOPI_OCTOPRINT_PACKAGE="OctoPrint" [ -n "$OCTOPI_INCLUDE_OCTOPRINT" ] || OCTOPI_INCLUDE_OCTOPRINT=yes # CuraEngine archive & version diff --git a/src/modules/octopi/start_chroot_script b/src/modules/octopi/start_chroot_script index 1b905a8e..bed1ed93 100755 --- a/src/modules/octopi/start_chroot_script +++ b/src/modules/octopi/start_chroot_script @@ -53,7 +53,7 @@ pushd /home/"${BASE_USER}" if [ "$OCTOPI_INCLUDE_OCTOPRINT" == "yes" ] then echo "--- Installing OctoPrint" - PIP_DEFAULT_TIMEOUT=60 sudo -u "${BASE_USER}" /home/"${BASE_USER}"/oprint/bin/pip install $OCTOPI_OCTOPRINT_ARCHIVE + PIP_DEFAULT_TIMEOUT=60 sudo -u "${BASE_USER}" /home/"${BASE_USER}"/oprint/bin/pip install $OCTOPI_OCTOPRINT_PACKAGE fi #mjpg-streamer From ccda0a601b5dc4e53e320f9ca383c389d229392c Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Sun, 18 Jul 2021 15:30:31 +0300 Subject: [PATCH 324/352] Add another mirror --- README.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.rst b/README.rst index 6091ecc9..36afc154 100644 --- a/README.rst +++ b/README.rst @@ -19,6 +19,8 @@ Download the latest stable build via this button: Official mirror is `here `_ +Second mirror is `here `_ + Nightly builds are available `here `_ 64bit Nightly builds are available `here `_ From 6deaa22a71bc1b648652b50c3be2f4d743b27e54 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Sun, 18 Jul 2021 15:31:05 +0300 Subject: [PATCH 325/352] Update url --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 36afc154..790ae3bf 100644 --- a/README.rst +++ b/README.rst @@ -19,7 +19,7 @@ Download the latest stable build via this button: Official mirror is `here `_ -Second mirror is `here `_ +Second mirror is `here `_ Nightly builds are available `here `_ From 55228f05d288e6f307cf5abda323dd918e2b148a Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Mon, 19 Jul 2021 19:05:54 +0300 Subject: [PATCH 326/352] Add missing unzip for ubuntu needed by #743 --- src/modules/octopi/start_chroot_script | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/octopi/start_chroot_script b/src/modules/octopi/start_chroot_script index ac6ca0dd..647eac6f 100755 --- a/src/modules/octopi/start_chroot_script +++ b/src/modules/octopi/start_chroot_script @@ -34,7 +34,7 @@ apt-get remove -y --purge $remove_extra apt-get autoremove -y if [ "${BASE_DISTRO}" == "ubuntu" ]; then - apt-get -y --force-yes install python3 python3-virtualenv python3-dev git screen subversion cmake cmake-data avahi-daemon libavahi-compat-libdnssd1 libffi-dev libssl-dev libatlas3-base + apt-get -y --force-yes install python3 python3-virtualenv python3-dev git screen subversion cmake cmake-data avahi-daemon libavahi-compat-libdnssd1 libffi-dev libssl-dev libatlas3-base unzip else apt-get -y --force-yes install python3 python3-virtualenv python3-dev git screen subversion cmake=3.13.4-1 cmake-data=3.13.4-1 avahi-daemon libavahi-compat-libdnssd1 libffi-dev libssl-dev libatlas3-base fi From 9bec6e6ad9dc61fe188c0e3d842d3d30ad656584 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Mon, 26 Jul 2021 12:59:04 +0300 Subject: [PATCH 327/352] Fix build for Ubuntu 20.04 64bit, use libjpeg8-dev --- src/modules/octopi/start_chroot_script | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/modules/octopi/start_chroot_script b/src/modules/octopi/start_chroot_script index 647eac6f..65eb08e7 100755 --- a/src/modules/octopi/start_chroot_script +++ b/src/modules/octopi/start_chroot_script @@ -61,10 +61,14 @@ pushd /home/"${BASE_USER}" then install_dir=/opt/mjpg-streamer echo "--- Installing mjpg-streamer to $install_dir" - if [ $( is_in_apt libjpeg62-turbo-dev ) -eq 1 ]; then - apt-get -y --force-yes install libjpeg62-turbo-dev - elif [ $( is_in_apt libjpeg8-dev ) -eq 1 ]; then - apt-get -y --force-yes install libjpeg8-dev + if [ "${BASE_DISTRO}" == "ubuntu" ]; then + apt-get -y --allow-downgrades --allow-remove-essential --allow-change-held-packages install libjpeg8-dev + else + if [ $( is_in_apt libjpeg62-turbo-dev ) -eq 1 ]; then + apt-get -y --force-yes install libjpeg62-turbo-dev + elif [ $( is_in_apt libjpeg8-dev ) -eq 1 ]; then + apt-get -y --force-yes install libjpeg8-dev + fi fi apt-get -y --force-yes --no-install-recommends install imagemagick ffmpeg libv4l-dev From 55344968198c4ebcf22599835069837feb82c659 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Tue, 27 Jul 2021 00:25:59 +0300 Subject: [PATCH 328/352] Fixes #746 --- src/modules/octopi/start_chroot_script | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/modules/octopi/start_chroot_script b/src/modules/octopi/start_chroot_script index 65eb08e7..4d37aa25 100755 --- a/src/modules/octopi/start_chroot_script +++ b/src/modules/octopi/start_chroot_script @@ -25,6 +25,11 @@ WEBCAM_USER=webcam unpack /filesystem/home/pi /home/"${BASE_USER}" "${BASE_USER}" unpack /filesystem/home/root /root root unpack /filesystem/boot /boot + +if [ "${BASE_DISTRO}" == "ubuntu" ]; then + ln -s /boot/firmware/octopi.txt /boot/octopi.txt +fi + apt-get update # in case we are building from a regular raspbian image instead of the lite one... From 64c7f714f207e84d5011b365464d25c91ccac30e Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Mon, 9 Aug 2021 14:11:38 +0300 Subject: [PATCH 329/352] Revert fix for https://github.com/guysoft/OctoPi/issues/746#issuecomment-894783149 --- src/modules/octopi/start_chroot_script | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/modules/octopi/start_chroot_script b/src/modules/octopi/start_chroot_script index 4d37aa25..7c07a273 100755 --- a/src/modules/octopi/start_chroot_script +++ b/src/modules/octopi/start_chroot_script @@ -26,10 +26,6 @@ unpack /filesystem/home/pi /home/"${BASE_USER}" "${BASE_USER}" unpack /filesystem/home/root /root root unpack /filesystem/boot /boot -if [ "${BASE_DISTRO}" == "ubuntu" ]; then - ln -s /boot/firmware/octopi.txt /boot/octopi.txt -fi - apt-get update # in case we are building from a regular raspbian image instead of the lite one... From 1249100b5cf4b205426d509182efbd602c577145 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Thu, 9 Sep 2021 02:49:15 +0300 Subject: [PATCH 330/352] Add fix for #508 https://github.com/guysoft/OctoPi/issues/508#issuecomment-914501732 --- .../root/etc/network/if-up.d/powersave_off | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 src/modules/octopi/filesystem/root/etc/network/if-up.d/powersave_off diff --git a/src/modules/octopi/filesystem/root/etc/network/if-up.d/powersave_off b/src/modules/octopi/filesystem/root/etc/network/if-up.d/powersave_off new file mode 100755 index 00000000..9801cf33 --- /dev/null +++ b/src/modules/octopi/filesystem/root/etc/network/if-up.d/powersave_off @@ -0,0 +1,23 @@ +#!/bin/sh + +set -e + +# Don't bother for loopback +if [ "$IFACE" = lo ]; then + exit 0 +fi + +# Only run from ifup. +if [ "$MODE" != start ]; then + exit 0 +fi + +# Only run once +if [ "$ADDRFAM" != meta ]; then + exit 0 +fi + +/usr/sbin/iw dev wlan0 set power_save off + +exit 0 + From 588373dbb3a2c2ca554041e37152c5282f4cce57 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Thu, 23 Sep 2021 12:50:03 +0300 Subject: [PATCH 331/352] Remove request for HTTPS mirror, we got one donated :) --- README.rst | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.rst b/README.rst index 790ae3bf..d3d46c6e 100644 --- a/README.rst +++ b/README.rst @@ -25,8 +25,6 @@ Nightly builds are available `here `_ -We recently had to move to building location, donations for somewhere with HTTPS would be great. - How to use it? -------------- From b1f84495640c76cd23a633ed4e7a359b1c3faf2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Stra=C3=9Fburger?= Date: Sun, 7 Nov 2021 22:15:01 +0100 Subject: [PATCH 332/352] :zap: when using hls camera streamer, generate frame snapshot only once a second --- .../filesystem/root/etc/systemd/system/ffmpeg_hls.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/octopi/filesystem/root/etc/systemd/system/ffmpeg_hls.service b/src/modules/octopi/filesystem/root/etc/systemd/system/ffmpeg_hls.service index 15a8da25..2b15d8d8 100644 --- a/src/modules/octopi/filesystem/root/etc/systemd/system/ffmpeg_hls.service +++ b/src/modules/octopi/filesystem/root/etc/systemd/system/ffmpeg_hls.service @@ -25,7 +25,7 @@ ExecStart=/usr/bin/sudo -u webcam \ -pix_fmt yuv420p \ \ -c:v mjpeg -q:v 0 \ - -f image2 -update 1 -atomic_writing 1 \ + -f image2 -r 1 -update 1 -atomic_writing 1 \ /run/webcam/jpeg/frame.jpg \ \ -c:v h264_omx -profile:v high \ From 24be793acac49682a4f9ed81315f5840ae20abac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 9 Nov 2021 22:05:28 +0100 Subject: [PATCH 333/352] cmake-3.13.4 is no more --- src/modules/octopi/start_chroot_script | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/modules/octopi/start_chroot_script b/src/modules/octopi/start_chroot_script index 7c07a273..0e01800c 100755 --- a/src/modules/octopi/start_chroot_script +++ b/src/modules/octopi/start_chroot_script @@ -34,12 +34,7 @@ echo "removing:" $remove_extra apt-get remove -y --purge $remove_extra apt-get autoremove -y -if [ "${BASE_DISTRO}" == "ubuntu" ]; then - apt-get -y --force-yes install python3 python3-virtualenv python3-dev git screen subversion cmake cmake-data avahi-daemon libavahi-compat-libdnssd1 libffi-dev libssl-dev libatlas3-base unzip -else - apt-get -y --force-yes install python3 python3-virtualenv python3-dev git screen subversion cmake=3.13.4-1 cmake-data=3.13.4-1 avahi-daemon libavahi-compat-libdnssd1 libffi-dev libssl-dev libatlas3-base -fi - +apt-get -y --force-yes install python3 python3-virtualenv python3-dev git screen subversion cmake cmake-data avahi-daemon libavahi-compat-libdnssd1 libffi-dev libssl-dev libatlas3-base unzip echo " - Reinstall iputils-ping" apt-get install --reinstall iputils-ping From 4a4c353d661a86a447665ce172a31857ec320905 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 9 Nov 2021 22:06:29 +0100 Subject: [PATCH 334/352] wiringpi is no more --- src/modules/octopi/config | 3 --- src/modules/octopi/start_chroot_script | 6 ------ 2 files changed, 9 deletions(-) diff --git a/src/modules/octopi/config b/src/modules/octopi/config index 5064055e..b39f19a3 100755 --- a/src/modules/octopi/config +++ b/src/modules/octopi/config @@ -20,9 +20,6 @@ # HAProxy [ -n "$OCTOPI_INCLUDE_HAPROXY" ] || OCTOPI_INCLUDE_HAPROXY=yes -# WiringPi -[ -n "$OCTOPI_INCLUDE_WIRINGPI" ] || OCTOPI_INCLUDE_WIRINGPI=yes - # yq [ -n "$OCTOPI_YQ_DOWNLOAD" ] || OCTOPI_YQ_DOWNLOAD=$(wget -q -O - https://api.github.com/repos/mikefarah/yq/releases/latest | grep "browser_download_url" | grep "yq_linux_arm" | cut -d : -f 2,3 | tr -d \" | tr -d ,) diff --git a/src/modules/octopi/start_chroot_script b/src/modules/octopi/start_chroot_script index 0e01800c..11b981bc 100755 --- a/src/modules/octopi/start_chroot_script +++ b/src/modules/octopi/start_chroot_script @@ -149,12 +149,6 @@ EOT rm /etc/ssl/private/ssl-cert-snakeoil.key /etc/ssl/certs/ssl-cert-snakeoil.pem fi - if [ "$OCTOPI_INCLUDE_WIRINGPI" == "yes" ] - then - echo "--- Installing WiringPi" - apt-get -y install wiringpi - fi - # fetch current yq build and install to /usr/local/bin wget -O yq $OCTOPI_YQ_DOWNLOAD && chmod +x yq && mv yq /usr/local/bin From df10e6d33c3ea0d122065a030fbea2dcb78be0aa Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Mon, 17 Jan 2022 18:02:47 +0200 Subject: [PATCH 335/352] Add repository_dispatch option --- .github/workflows/build.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 09781709..97238fb2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,6 +1,7 @@ name: Build Image -on: +on: + repository_dispatch: push: schedule: - cron: '0 0 * * *' @@ -62,4 +63,4 @@ jobs: if: github.event_name == 'schedule' with: name: ${{ steps.copy.outputs.image }} - path: ${{ steps.copy.outputs.image }}.img \ No newline at end of file + path: ${{ steps.copy.outputs.image }}.img From 7e151c0f47d4b9720f9a2973040cd8ebc1e33da5 Mon Sep 17 00:00:00 2001 From: PowerWiesel <11167590+PowerWiesel@users.noreply.github.com> Date: Wed, 26 Jan 2022 11:51:50 +0100 Subject: [PATCH 336/352] picam-bullseye-fix mjpg-streamer doesn't work anymore with the new picam stack on bullseye based images - using the old stack for now. --- src/modules/octopi/start_chroot_script | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/modules/octopi/start_chroot_script b/src/modules/octopi/start_chroot_script index 11b981bc..6247a7ba 100755 --- a/src/modules/octopi/start_chroot_script +++ b/src/modules/octopi/start_chroot_script @@ -270,6 +270,11 @@ systemctl_if_exists enable streamer_select.service if [ "$OCTOPI_INCLUDE_MJPGSTREAMER" == "yes" ] then systemctl_if_exists enable webcamd.service +### use legacy camera stack on bullseye for now + if grep "camera_auto_detect=1" /boot/config.txt + then + sed -i "s/camera_auto_detect=1/camera_auto_detect=0/g" /boot/config.txt + fi else rm /etc/logrotate.d/webcamd rm /etc/systemd/system/webcamd.service From 70d256b24985cbf3c9adf8f4141a572cd9f15a8c Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Fri, 4 Feb 2022 13:36:13 +0200 Subject: [PATCH 337/352] Add rpi-imager values --- src/config | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/config b/src/config index 60299236..506f300e 100755 --- a/src/config +++ b/src/config @@ -2,5 +2,10 @@ export DIST_NAME=OctoPi export DIST_VERSION=1.0.0 export MODULES="base(raspicam, network, disable-services(octopi), password-for-sudo)" +export RPI_IMAGER_NAME="${DIST_NAME} version ${DIST_VERSION}" +export RPI_IMAGER_DESCRIPTION="A Raspberry Pi distribution for 3D printers. Ships OctoPrint out-of-the-box." +export RPI_IMAGER_ICON="https://raw.githubusercontent.com/guysoft/OctoPi/devel/media/rpi-imager-OctoPi.png" + + export BASE_IMAGE_ENLARGEROOT=2000 export BASE_IMAGE_RESIZEROOT=200 From aeca7ca63c91644615a3e72e58e1bb74d12a0df3 Mon Sep 17 00:00:00 2001 From: Flip Date: Tue, 8 Feb 2022 21:48:18 +0100 Subject: [PATCH 338/352] Set systemd Type to simple instead of forking --- .../octopi/filesystem/root/etc/systemd/system/webcamd.service | 2 +- .../filesystem/root/etc/systemd/system/webcamd.service | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/octopi/filesystem/root/etc/systemd/system/webcamd.service b/src/modules/octopi/filesystem/root/etc/systemd/system/webcamd.service index ea494e40..451d2377 100644 --- a/src/modules/octopi/filesystem/root/etc/systemd/system/webcamd.service +++ b/src/modules/octopi/filesystem/root/etc/systemd/system/webcamd.service @@ -8,7 +8,7 @@ StandardOutput=append:/var/log/webcamd.log StandardError=append:/var/log/webcamd.log ExecStart=/root/bin/webcamd Restart=always -Type=forking +Type=simple RestartSec=1 [Install] diff --git a/src/variants/ubuntu_arm64/filesystem/root/etc/systemd/system/webcamd.service b/src/variants/ubuntu_arm64/filesystem/root/etc/systemd/system/webcamd.service index bd5feb53..5154d6e8 100644 --- a/src/variants/ubuntu_arm64/filesystem/root/etc/systemd/system/webcamd.service +++ b/src/variants/ubuntu_arm64/filesystem/root/etc/systemd/system/webcamd.service @@ -8,7 +8,7 @@ StandardOutput=append:/var/log/webcamd.log StandardError=append:/var/log/webcamd.log ExecStart=/root/bin/webcamd Restart=always -Type=forking +Type=simple RestartSec=1 [Install] From 1843700621516a2fcb9e6c45971ff5f3539b35b1 Mon Sep 17 00:00:00 2001 From: Sadetdin EYILI Date: Fri, 25 Feb 2022 23:55:12 +0100 Subject: [PATCH 339/352] Fix typo in octopi.txt --- src/modules/octopi/filesystem/boot/octopi.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/octopi/filesystem/boot/octopi.txt b/src/modules/octopi/filesystem/boot/octopi.txt index c842c6b4..24cc430e 100644 --- a/src/modules/octopi/filesystem/boot/octopi.txt +++ b/src/modules/octopi/filesystem/boot/octopi.txt @@ -82,7 +82,7 @@ # If connection terminates by variable reasons system tries to restart the wifi connection to reestablish a connection. # The connection test is done every minute. # By default it is disabled (0 = off / 1 = on) -# dstination_host can be an ip address or a hostname (for hostname ensure dns resosultion is working correctly) +# destination_host can be an ip address or a hostname (for hostname ensure dns resosultion is working correctly) enable_network_monitor=0 destination_host=192.168.1.1 From 9bee5f088ea46d30d7a21859844598bc5ad24de3 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Sun, 27 Feb 2022 13:50:43 +0200 Subject: [PATCH 340/352] Add rpi imager 64bit to title on 64bit builds --- src/variants/ubuntu_arm64/config | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/variants/ubuntu_arm64/config b/src/variants/ubuntu_arm64/config index 5fa90462..1f54aa96 100755 --- a/src/variants/ubuntu_arm64/config +++ b/src/variants/ubuntu_arm64/config @@ -6,3 +6,5 @@ export BASE_ZIP_IMG=`ls -t $BASE_IMAGE_PATH/*-{ubuntu}-*-arm64-*.xz | head -n 1` export BASE_IGNORE_VARIANT_NAME=yes export BASE_USER=pi export BASE_USER_PASSWORD=raspberry +export RPI_IMAGER_NAME="${DIST_NAME} version ${DIST_VERSION} 64bit" + From 017b75869185fc71030100e2fef0ffd9fbe28633 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Wed, 2 Mar 2022 19:01:02 +0100 Subject: [PATCH 341/352] Install vcgencmd and fix user permission on Ubuntu The 64bit images are currently lacking vcgencmd, meaning that the PiSupport plugin can't check for undervoltage and overheat situations and will complain about this in the latest version as well, see feedback in #770. This should fix it by installing the package containing vcgencmd and making sure the base user is added to the video group as well. I was not able to test this in a build since I could not find documentation on which base image exactly to use and how to precisely run the 64bit build, but based on user feedback it should hopefully work. Still, please test in a build before merging. --- src/modules/octopi/start_chroot_script | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/modules/octopi/start_chroot_script b/src/modules/octopi/start_chroot_script index 11b981bc..4a2438c6 100755 --- a/src/modules/octopi/start_chroot_script +++ b/src/modules/octopi/start_chroot_script @@ -158,6 +158,12 @@ popd usermod -a -G tty "${BASE_USER}" usermod -a -G dialout "${BASE_USER}" +# If building against Ubuntu, make sure vcgencmd is available and pi has the rights to use it +if [ "${BASE_DISTRO}" == "ubuntu" ]; then + apt-get -y --force-yes install libraspberrypi-bin + usermod -a -G video "${BASE_USER}" +fi + # store octopi commit used to build this image echo "$OCTOPI_COMMIT" > /etc/octopi_commit From 6fd716b415f53036cc36f9d40c816c7470534c18 Mon Sep 17 00:00:00 2001 From: Willem Date: Mon, 28 Mar 2022 18:37:35 +0000 Subject: [PATCH 342/352] Fix HAProxy warning on wrong timeout abrreviation --- .../octopi/filesystem/root/etc/haproxy/haproxy.2.x.cfg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/octopi/filesystem/root/etc/haproxy/haproxy.2.x.cfg b/src/modules/octopi/filesystem/root/etc/haproxy/haproxy.2.x.cfg index 8ef4d164..b9c30185 100644 --- a/src/modules/octopi/filesystem/root/etc/haproxy/haproxy.2.x.cfg +++ b/src/modules/octopi/filesystem/root/etc/haproxy/haproxy.2.x.cfg @@ -17,8 +17,8 @@ defaults option forwardfor maxconn 2000 timeout connect 5s - timeout client 15min - timeout server 15min + timeout client 15m + timeout server 15m frontend public bind :::80 v4v6 From c8045f46959aefe27e43a2ac6a46ad32b8fefec2 Mon Sep 17 00:00:00 2001 From: Timofei Korostelev Date: Sun, 10 Jul 2022 23:07:16 -0700 Subject: [PATCH 343/352] Building FFmpeg from source for HLS. Using V4L2 M2M encoder. --- .../etc/systemd/system/ffmpeg_hls.service | 6 +-- src/modules/octopi/start_chroot_script | 41 +++++++++++++++---- 2 files changed, 35 insertions(+), 12 deletions(-) diff --git a/src/modules/octopi/filesystem/root/etc/systemd/system/ffmpeg_hls.service b/src/modules/octopi/filesystem/root/etc/systemd/system/ffmpeg_hls.service index 2b15d8d8..3a1f463b 100644 --- a/src/modules/octopi/filesystem/root/etc/systemd/system/ffmpeg_hls.service +++ b/src/modules/octopi/filesystem/root/etc/systemd/system/ffmpeg_hls.service @@ -18,7 +18,7 @@ ExecStartPre=/bin/chown -R webcam:webcam /run/webcam ExecStartPre=/bin/chmod -R 0755 /run/webcam ExecStart=/usr/bin/sudo -u webcam \ - /usr/bin/ffmpeg \ + /opt/ffmpeg-hls/ffmpeg \ \ -framerate 30 -video_size 640x480 \ -i /dev/video0 \ @@ -28,7 +28,7 @@ ExecStart=/usr/bin/sudo -u webcam \ -f image2 -r 1 -update 1 -atomic_writing 1 \ /run/webcam/jpeg/frame.jpg \ \ - -c:v h264_omx -profile:v high \ + -c:v h264_v4l2m2m -level:v 4.0 \ -b:v 1264k -flags +cgop \ -g 30 -keyint_min 30 \ \ @@ -40,7 +40,7 @@ ExecStart=/usr/bin/sudo -u webcam \ \ -vf scale=-1:240 \ \ - -c:v h264_omx -profile:v high \ + -c:v h264_v4l2m2m -level:v 4.0 \ -b:v 240k -flags +cgop \ -g 30 -keyint_min 30 \ \ diff --git a/src/modules/octopi/start_chroot_script b/src/modules/octopi/start_chroot_script index 7c3b03f6..91e08e98 100755 --- a/src/modules/octopi/start_chroot_script +++ b/src/modules/octopi/start_chroot_script @@ -11,7 +11,7 @@ export LC_ALL=C source /common.sh -if [ -n "$OCTOPI_APTMIRROR" ]; +if [ -n "$OCTOPI_APTMIRROR" ]; then echo "Switching apt mirror in /etc/apt/sources.list to $OCTOPI_APTMIRROR" cp /etc/apt/sources.list /etc/apt/sources.list.backup @@ -19,6 +19,8 @@ then fi WEBCAM_USER=webcam +FFMPEG_HLS_COMMIT=c6fdbe26ef30fff817581e5ed6e078d96111248a +FFMPEG_HLS_DIR=/opt/ffmpeg-hls ### Script #### @@ -66,7 +68,7 @@ pushd /home/"${BASE_USER}" apt-get -y --force-yes install libjpeg8-dev fi fi - + apt-get -y --force-yes --no-install-recommends install imagemagick ffmpeg libv4l-dev wget $OCTOPI_MJPGSTREAMER_ARCHIVE -O mjpg-streamer.zip @@ -120,11 +122,32 @@ EOT # FFMPEG HLS if [ "$OCTOPI_INCLUDE_FFMPEG_HLS" == "yes" ] then - apt-get install -y --force-yes --no-install-recommends ffmpeg nginx + apt-get install -y --force-yes --no-install-recommends nginx + + FFMPEG_BUILD_DIR=$(mktemp -d) + pushd ${FFMPEG_BUILD_DIR} + FFMPEG_ARCHIVE=ffmpeg.tar.gz + wget https://api.github.com/repos/FFmpeg/FFmpeg/tarball/${FFMPEG_COMMIT} -O ${FFMPEG_ARCHIVE} + tar xvzf ${FFMPEG_ARCHIVE} + cd FFmpeg* + ./configure \ + --disable-doc \ + --disable-htmlpages \ + --disable-manpages \ + --disable-podpages \ + --disable-txtpages \ + --disable-ffplay \ + --disable-ffprobe + make -j$(nproc) + mkdir -p ${FFMPEG_HLS_DIR} + cp ffmpeg ${FFMPEG_HLS_DIR} + popd + rm -r ${FFMPEG_BUILD_DIR} + useradd ${WEBCAM_USER} usermod -aG video ${WEBCAM_USER} fi - + #CuraEngine if [ "$OCTOPI_INCLUDE_CURAENGINE" == "yes" ] then @@ -151,7 +174,7 @@ EOT # fetch current yq build and install to /usr/local/bin wget -O yq $OCTOPI_YQ_DOWNLOAD && chmod +x yq && mv yq /usr/local/bin - + popd #Make sure user pi / ${BASE_USER} has access to serial ports @@ -197,13 +220,13 @@ do done for ip in $(hostname -I); -do +do echo " http://$ip" done echo echo "https is also available, with a self-signed certificate." -echo +echo echo "------------------------------------------------------------" echo EOT @@ -276,7 +299,7 @@ systemctl_if_exists enable streamer_select.service if [ "$OCTOPI_INCLUDE_MJPGSTREAMER" == "yes" ] then systemctl_if_exists enable webcamd.service -### use legacy camera stack on bullseye for now +### use legacy camera stack on bullseye for now if grep "camera_auto_detect=1" /boot/config.txt then sed -i "s/camera_auto_detect=1/camera_auto_detect=0/g" /boot/config.txt @@ -304,7 +327,7 @@ apt-get -y install avrdude apt-get clean apt-get autoremove -y -if [ -n "$OCTOPI_APTMIRROR" ]; +if [ -n "$OCTOPI_APTMIRROR" ]; then echo "Reverting /etc/apt/sources.list" mv /etc/apt/sources.list.backup /etc/apt/sources.list From 7d57995e41fa2f1bb5e637cb7431578c69650397 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Fri, 15 Jul 2022 13:48:51 +0300 Subject: [PATCH 344/352] Add raspios_arm64 variant #785 --- src/variants/rpios_arm64/config | 7 +++ .../filesystem/root/etc/haproxy/haproxy.cfg | 49 +++++++++++++++++++ .../root/etc/systemd/system/webcamd.service | 15 ++++++ src/variants/rpios_arm64/post_chroot_script | 17 +++++++ 4 files changed, 88 insertions(+) create mode 100755 src/variants/rpios_arm64/config create mode 100644 src/variants/rpios_arm64/filesystem/root/etc/haproxy/haproxy.cfg create mode 100644 src/variants/rpios_arm64/filesystem/root/etc/systemd/system/webcamd.service create mode 100644 src/variants/rpios_arm64/post_chroot_script diff --git a/src/variants/rpios_arm64/config b/src/variants/rpios_arm64/config new file mode 100755 index 00000000..bbc234f2 --- /dev/null +++ b/src/variants/rpios_arm64/config @@ -0,0 +1,7 @@ +export BASE_ARCH=aarch64 +export BASE_DISTRO=raspios64 +export BASE_IMAGE_PATH=${DIST_PATH}/image-rpios_arm64 +# export BASE_ZIP_IMG=`ls -t $BASE_IMAGE_PATH/*-{ubuntu}-*-arm64-*.xz | head -n 1` +export BASE_IGNORE_VARIANT_NAME=yes +export BASE_USER=pi +export BASE_USER_PASSWORD=raspberry diff --git a/src/variants/rpios_arm64/filesystem/root/etc/haproxy/haproxy.cfg b/src/variants/rpios_arm64/filesystem/root/etc/haproxy/haproxy.cfg new file mode 100644 index 00000000..8ef4d164 --- /dev/null +++ b/src/variants/rpios_arm64/filesystem/root/etc/haproxy/haproxy.cfg @@ -0,0 +1,49 @@ +global + maxconn 4096 + user haproxy + group haproxy + log /dev/log local1 debug + tune.ssl.default-dh-param 2048 + +defaults + log global + mode http + compression algo gzip + option httplog + option dontlognull + retries 3 + option redispatch + option http-server-close + option forwardfor + maxconn 2000 + timeout connect 5s + timeout client 15min + timeout server 15min + +frontend public + bind :::80 v4v6 + bind :::443 v4v6 ssl crt /etc/ssl/snakeoil.pem + option forwardfor except 127.0.0.1 + use_backend webcam if { path_beg /webcam/ } + use_backend webcam_hls if { path_beg /hls/ } + use_backend webcam_hls if { path_beg /jpeg/ } + default_backend octoprint + +backend octoprint + acl needs_scheme req.hdr_cnt(X-Scheme) eq 0 + + http-request replace-path ^([^\ :]*)\ /(.*) \1\ /\2 + http-request add-header X-Scheme https if needs_scheme { ssl_fc } + http-request add-header X-Scheme http if needs_scheme !{ ssl_fc } + option forwardfor + server octoprint1 127.0.0.1:5000 + errorfile 503 /etc/haproxy/errors/503-no-octoprint.http + +backend webcam + http-request replace-path /webcam/(.*) /\1 + server webcam1 127.0.0.1:8080 + errorfile 503 /etc/haproxy/errors/503-no-webcam.http + +backend webcam_hls + server webcam_hls_1 127.0.0.1:28126 + errorfile 503 /etc/haproxy/errors/503-no-webcam-hls.http diff --git a/src/variants/rpios_arm64/filesystem/root/etc/systemd/system/webcamd.service b/src/variants/rpios_arm64/filesystem/root/etc/systemd/system/webcamd.service new file mode 100644 index 00000000..bd5feb53 --- /dev/null +++ b/src/variants/rpios_arm64/filesystem/root/etc/systemd/system/webcamd.service @@ -0,0 +1,15 @@ +[Unit] +Description=the OctoPi webcam daemon with the user specified config +# ConditionPathExists=/etc/octopi_streamer/mjpeg + +[Service] +WorkingDirectory=/root/bin +StandardOutput=append:/var/log/webcamd.log +StandardError=append:/var/log/webcamd.log +ExecStart=/root/bin/webcamd +Restart=always +Type=forking +RestartSec=1 + +[Install] +WantedBy=multi-user.target diff --git a/src/variants/rpios_arm64/post_chroot_script b/src/variants/rpios_arm64/post_chroot_script new file mode 100644 index 00000000..918c8bc9 --- /dev/null +++ b/src/variants/rpios_arm64/post_chroot_script @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +set -x +set -e + +export LC_ALL=C + +source /common.sh +install_cleanup_trap + +# Unpack the filesystem changes for the variant +unpack /filesystem/root / + +# add-apt-repository ppa:ubuntu-raspi2/ppa -y +apt-get update +apt-get -y --force-yes install libraspberrypi-bin rpi.gpio-common +apt-get clean +apt-get autoremove -y From 86f398c133e78e8023047a94ea343379ea4b1549 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Sun, 17 Jul 2022 01:28:28 +0300 Subject: [PATCH 345/352] Update README, add README for rpios_arm64 variant image location #785 --- src/image-rpios_arm64/README | 5 +++++ src/image/README | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 src/image-rpios_arm64/README diff --git a/src/image-rpios_arm64/README b/src/image-rpios_arm64/README new file mode 100644 index 00000000..63a2c46b --- /dev/null +++ b/src/image-rpios_arm64/README @@ -0,0 +1,5 @@ +Place zipped Raspberry Pi OS image here for the arm64 variant. Or any other variant you want to build/ + +If not otherwise specified, the build script will always use the most +recent zip file matching the file name pattern "*-raspbian.zip" or "*-rpios.zip" or "*-rpios.xz" located +here. diff --git a/src/image/README b/src/image/README index a536aca2..4203497c 100644 --- a/src/image/README +++ b/src/image/README @@ -1,5 +1,5 @@ Place zipped Raspberry Pi OS image here. Or any other variant you want to build/ If not otherwise specified, the build script will always use the most -recent zip file matching the file name pattern "*-raspbian.zip" or "*-rpios.zip" located +recent zip file matching the file name pattern "*-raspbian.zip" or "*-rpios.zip" or "*-rpios.xz" located here. From ec90e9a892710ee59652970c68b9aea14029e77e Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Sun, 17 Jul 2022 10:31:39 +0300 Subject: [PATCH 346/352] Fix building for armv7 on a arm64 kernel adn 32bit userspace #784 Fixes #787 --- src/modules/octopi/start_chroot_script | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/modules/octopi/start_chroot_script b/src/modules/octopi/start_chroot_script index 91e08e98..87bb5151 100755 --- a/src/modules/octopi/start_chroot_script +++ b/src/modules/octopi/start_chroot_script @@ -124,6 +124,11 @@ EOT then apt-get install -y --force-yes --no-install-recommends nginx + ARCH=arm + if [ "${BASE_ARCH}" == "aarch64"]; then + ARCH=aarch64 + fi + FFMPEG_BUILD_DIR=$(mktemp -d) pushd ${FFMPEG_BUILD_DIR} FFMPEG_ARCHIVE=ffmpeg.tar.gz @@ -131,6 +136,7 @@ EOT tar xvzf ${FFMPEG_ARCHIVE} cd FFmpeg* ./configure \ + --arch="${ARCH}" \ --disable-doc \ --disable-htmlpages \ --disable-manpages \ From 1d6d81f75f4384708e49ca67c0a3097d5bc28583 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Wed, 27 Jul 2022 00:02:23 +0300 Subject: [PATCH 347/352] Export ffmpeg HLS so we can place it as a pre-built binary later on #784 --- src/modules/octopi/start_chroot_script | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/octopi/start_chroot_script b/src/modules/octopi/start_chroot_script index 87bb5151..db72e43d 100755 --- a/src/modules/octopi/start_chroot_script +++ b/src/modules/octopi/start_chroot_script @@ -146,7 +146,7 @@ EOT --disable-ffprobe make -j$(nproc) mkdir -p ${FFMPEG_HLS_DIR} - cp ffmpeg ${FFMPEG_HLS_DIR} + copy_and_export ffmpeg-hls-"${ARCH}" ffmpeg "${FFMPEG_HLS_DIR}" popd rm -r ${FFMPEG_BUILD_DIR} From 1e5e8eaa61e0360954a0a3d709592ce20f9e6762 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Wed, 3 Aug 2022 15:26:57 +0300 Subject: [PATCH 348/352] Fix typo --- src/modules/octopi/start_chroot_script | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/octopi/start_chroot_script b/src/modules/octopi/start_chroot_script index db72e43d..56f43b60 100755 --- a/src/modules/octopi/start_chroot_script +++ b/src/modules/octopi/start_chroot_script @@ -125,7 +125,7 @@ EOT apt-get install -y --force-yes --no-install-recommends nginx ARCH=arm - if [ "${BASE_ARCH}" == "aarch64"]; then + if [ "${BASE_ARCH}" == "aarch64" ]; then ARCH=aarch64 fi From 9105292c71d52121f3b76148c09b31ca2ceee668 Mon Sep 17 00:00:00 2001 From: Charlie Powell <31997505+cp2004@users.noreply.github.com> Date: Sun, 14 Aug 2022 17:32:20 +0100 Subject: [PATCH 349/352] Ensure webcamd service type is simple, not forking See #788 --- .../filesystem/root/etc/systemd/system/webcamd.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/variants/rpios_arm64/filesystem/root/etc/systemd/system/webcamd.service b/src/variants/rpios_arm64/filesystem/root/etc/systemd/system/webcamd.service index bd5feb53..5154d6e8 100644 --- a/src/variants/rpios_arm64/filesystem/root/etc/systemd/system/webcamd.service +++ b/src/variants/rpios_arm64/filesystem/root/etc/systemd/system/webcamd.service @@ -8,7 +8,7 @@ StandardOutput=append:/var/log/webcamd.log StandardError=append:/var/log/webcamd.log ExecStart=/root/bin/webcamd Restart=always -Type=forking +Type=simple RestartSec=1 [Install] From fc82f1202f5c818f855a4cdb22a7bb2ec3a1f95e Mon Sep 17 00:00:00 2001 From: Charlie Powell <31997505+cp2004@users.noreply.github.com> Date: Sun, 14 Aug 2022 17:43:49 +0100 Subject: [PATCH 350/352] Fix vcgencmd get_camera output matching with libcamera --- src/modules/octopi/filesystem/home/root/bin/webcamd | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/modules/octopi/filesystem/home/root/bin/webcamd b/src/modules/octopi/filesystem/home/root/bin/webcamd index f2c6dfb1..89d5d96a 100755 --- a/src/modules/octopi/filesystem/home/root/bin/webcamd +++ b/src/modules/octopi/filesystem/home/root/bin/webcamd @@ -227,7 +227,9 @@ while true; do video_devices=($(find /dev -regextype sed -regex '\/dev/video[0-9]\+' | sort 2> /dev/null)) # add list of raspi camera into an array - if [ "`vcgencmd get_camera`" = "supported=1 detected=1" ]; then + vcgencmd_regex="supported=1 detected=1.*" + # Example output matching: supported=1 detected=1, libcamera interfaces=0 + if [[ "`vcgencmd get_camera`" =~ $vcgencmd_regex ]]; then video_devices+=( "raspi" ) fi From e5fc9bfb10a5de518459a16f3b7bfb23778c3b5e Mon Sep 17 00:00:00 2001 From: Charlie Powell <31997505+cp2004@users.noreply.github.com> Date: Sun, 14 Aug 2022 18:29:41 +0100 Subject: [PATCH 351/352] Add userfix script to allow changing usernames --- .../octopi/filesystem/home/root/bin/user-fix | 53 +++++++++++++++++++ .../root/etc/systemd/system/user-fix.service | 18 +++++++ src/modules/octopi/start_chroot_script | 9 ++++ 3 files changed, 80 insertions(+) create mode 100755 src/modules/octopi/filesystem/home/root/bin/user-fix create mode 100644 src/modules/octopi/filesystem/root/etc/systemd/system/user-fix.service diff --git a/src/modules/octopi/filesystem/home/root/bin/user-fix b/src/modules/octopi/filesystem/home/root/bin/user-fix new file mode 100755 index 00000000..09735c9e --- /dev/null +++ b/src/modules/octopi/filesystem/home/root/bin/user-fix @@ -0,0 +1,53 @@ +#!/usr/bin/env bash +# Written by Gina Häußge originally at https://github.com/OctoPrint/OctoPi-UpToDate/blob/e70ccdaf0cd4ef4adfaa3f9b6b288fb6bfda116a/scripts/files/user-fix + +set -e + +USERID=1000 +FIRSTUSER=`getent passwd $USERID | cut -d: -f1` +FIRSTUSERHOME=`getent passwd $USERID | cut -d: -f6` + +CURRENT=`grep User= /etc/systemd/system/octoprint.service | cut -d= -f2` + +if [ "$CURRENT" = "pi" -a "$FIRSTUSER" != "pi" ]; then + # if we get here it means that the first user was renamed but we haven't yet + # updated all of OctoPi's files that depend on that name, so let's do that now + + # first we need to figure out if we can use the new user name in systemd files + # directly or if we need to use the UID - we do that by checking if the + # escaped name differes from the plain name, if so something is non ASCII + # and the UID is the safer bet + FIRSTUSERESC=`systemd-escape "$FIRSTUSER"` + if [ "$FIRSTUSER" != "$FIRSTUSERESC" ]; then + SERVICEUSER=$USERID + else + SERVICEUSER=$FIRSTUSER + fi + + # fix OctoPrint service file + echo "Fixing service file" + sed -i "s!User=pi!User=$SERVICEUSER!g" /etc/systemd/system/octoprint.service + sed -i "s!ExecStart=/home/pi/!ExecStart=$FIRSTUSERHOME/!g" /etc/systemd/system/octoprint.service + systemctl daemon-reload + + # fix sudoers files + echo "Fixing sudoers" + sed -i "s!^pi!$FIRSTUSER!g" /etc/sudoers.d/octoprint-service + sed -i "s!^pi!$FIRSTUSER!g" /etc/sudoers.d/octoprint-shutdown + + # fix scripts + echo "Fixing scripts" + sed -i "s!/home/pi/!$FIRSTUSERHOME/!g" $FIRSTUSERHOME/scripts/add-octoprint-checkout + sed -i "s!/home/pi/!$FIRSTUSERHOME/!g" $FIRSTUSERHOME/scripts/welcome + sed -i "s!/home/pi/!$FIRSTUSERHOME/!g" $FIRSTUSERHOME/.bashrc + sed -i "s!/home/pi/!$FIRSTUSERHOME/!g" /root/bin/webcamd + + # fix virtualenv + echo "Fixing paths in virtual environment" + cd $FIRSTUSERHOME/oprint + sudo -u $FIRSTUSER $FIRSTUSERHOME/.local/bin/virtualenv-tools --update-path $FIRSTUSERHOME/oprint + + # finally, reboot for all of this to actually take affect + echo "Adjusted scripts to new user, restarting services..." + systemctl reboot +fi \ No newline at end of file diff --git a/src/modules/octopi/filesystem/root/etc/systemd/system/user-fix.service b/src/modules/octopi/filesystem/root/etc/systemd/system/user-fix.service new file mode 100644 index 00000000..b95981ca --- /dev/null +++ b/src/modules/octopi/filesystem/root/etc/systemd/system/user-fix.service @@ -0,0 +1,18 @@ +# Written by Gina Häußge originally at https://github.com/OctoPrint/OctoPi-UpToDate/blob/e70ccdaf0cd4ef4adfaa3f9b6b288fb6bfda116a/scripts/files/user-fix.service +[Unit] +Description=Ensure that user name changes are applied as needed + +DefaultDependencies=no + +Before=network-pre.target +Wants=network-pre.target + +After=local-fs.target +Wants=local-fs.target + +[Service] +Type=oneshot +ExecStart=/root/bin/user-fix + +[Install] +WantedBy=multi-user.target diff --git a/src/modules/octopi/start_chroot_script b/src/modules/octopi/start_chroot_script index 56f43b60..d78f49e6 100755 --- a/src/modules/octopi/start_chroot_script +++ b/src/modules/octopi/start_chroot_script @@ -329,6 +329,15 @@ systemctl_if_exists enable networkcheck.timer echo "--- Installing avrdude" apt-get -y install avrdude +### User-fixing +# Users can change their username easily via the Raspberry Pi imager, which breaks some of OctoPi's scripts +# we need to install virtualenv-tools3, so let's get pip and that +apt install -y python3-pip +sudo -u pi pip3 install --user virtualenv-tools3 + +systemctl_if_exists enable user-fix.service + + #cleanup apt-get clean apt-get autoremove -y From 5ec881b5988911880b2896af5d765098c760c16a Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Thu, 27 Oct 2022 16:54:12 +0300 Subject: [PATCH 352/352] Add 64-bit in to name of generated rpi-imaer snipplet --- src/variants/rpios_arm64/config | 1 + 1 file changed, 1 insertion(+) diff --git a/src/variants/rpios_arm64/config b/src/variants/rpios_arm64/config index bbc234f2..36278105 100755 --- a/src/variants/rpios_arm64/config +++ b/src/variants/rpios_arm64/config @@ -5,3 +5,4 @@ export BASE_IMAGE_PATH=${DIST_PATH}/image-rpios_arm64 export BASE_IGNORE_VARIANT_NAME=yes export BASE_USER=pi export BASE_USER_PASSWORD=raspberry +export RPI_IMAGER_NAME="${DIST_NAME} version ${DIST_VERSION} 64-bit"