From 0c4a62fe6f381c505e3b7fcc774adc9e1859fe74 Mon Sep 17 00:00:00 2001 From: L Diaz Date: Sun, 9 Aug 2020 17:19:14 +0200 Subject: [PATCH] Sync with armbian stable remove klipper installation fix overlays in common.sh --- boards/common.sh | 44 ++++++++++++----- octocitrico.sh | 123 +++++++++++++++++++++++++++++++++++------------ 2 files changed, 124 insertions(+), 43 deletions(-) diff --git a/boards/common.sh b/boards/common.sh index e3e6835..258ade2 100644 --- a/boards/common.sh +++ b/boards/common.sh @@ -93,9 +93,10 @@ function add_overlay() { echo "Overlay ${ov} was already added to /boot/armbianEnv.txt, skipping" else sed -i -e "/^overlays=/ s/$/ ${ov}/" /boot/armbianEnv.txt - fi + fi else - sed -i -e "\$overlays=${ov}" /boot/armbianEnv.txt + #sed -i -e "\$overlays=${ov}" /boot/armbianEnv.txt + echo -e "overlays=${ov}" >> /boot/armbianEnv.txt fi # adding parameters at the end of the file if [ ! -z $pars ] ; then @@ -226,13 +227,14 @@ function install_octoprint_plugins() { # $1 -> user function install_mjpgstreamer() { local user=$1 - pushd /home/$user - su -l $user -c "git clone --depth 1 $MJPGSTREAMER_REPO mjpg-streamer" - popd + #pushd /home/$user + #su -l $user -c "git clone --depth 1 $MJPGSTREAMER_REPO mjpg-streamer" + #popd + pushd /home/$user/mjpg-streamer - su -l $user -c "cd /home/$user/mjpg-streamer && mv mjpg-streamer-experimental/* . && make && mkdir -p www-octopi" + su -l $user -c "cd /home/$user/mjpg-streamer && make && mkdir -p www-octopi" - cat <> www-octopi/index.html + cat <> www-octopi/index.html mjpg_streamer test page @@ -260,10 +262,10 @@ function install_extras() { su -l $user -c "virtualenv .platformio/penv" su -l $user -c "/home/$user/.platformio/penv/bin/pip --no-cache-dir install -U platformio" su -l $user -c "echo 'export PATH=\$PATH:~/.platformio/penv/bin' >> /home/$user/.profile" - su -l $user -c "git clone --depth 1 $KLIPPER_REPO" - sed -i 's/pip -r/pip --no-cache-dir -r /g' ./klipper/scripts/install-debian.sh - su -l $user -c "chmod u+x ./klipper/scripts/install-debian.sh && ./klipper/scripts/install-debian.sh" - systemctl disable klipper.service + #su -l $user -c "git clone --depth 1 $KLIPPER_REPO" + #sed -i 's/pip -r/pip --no-cache-dir -r /g' ./klipper/scripts/install-debian.sh + #su -l $user -c "chmod u+x ./klipper/scripts/install-debian.sh && ./klipper/scripts/install-debian.sh" + #systemctl disable klipper.service popd echo $? "[EXTRAS]" } @@ -286,10 +288,11 @@ function customize() { #users_and_groups $ROOTPASSWD $OCTO_USER $OCTO_PASSWD tweak_base change_host_name "citrico-$board" + df -h install_octoprint $OCTO_USER + df -h install_octoprint_plugins $OCTO_USER - install_mjpgstreamer $OCTO_USER - install_extras $OCTO_USER + df -h # unpack FS unpack_file $rt_dir/filesystem/boot/octopi.txt /boot/octopi.txt root @@ -301,6 +304,21 @@ function customize() { unpack $rt_dir/common_fs/etc /etc root unpack $rt_dir/common_fs/home/$OCTO_USER /home/$OCTO_USER $OCTO_USER + # make home/$user/scripts executable + chmod u+x /home/$OCTO_USER/scripts/* + + # unpack MJPG STREAMER + unpack $rt_dir/mjpg-streamer/mjpg-streamer-experimental /home/$OCTO_USER/mjpg-streamer $OCTO_USER + # unpack Klipper + #unpack $rt_dir/klipper /home/$OCTO_USER/klipper $OCTO_USER + + df -h + # Install extras + install_mjpgstreamer $OCTO_USER + df -h + install_extras $OCTO_USER + df -h + #enable/disable services systemctl enable gencert.service systemctl enable octoprint.service diff --git a/octocitrico.sh b/octocitrico.sh index 8d77cae..0ec8282 100755 --- a/octocitrico.sh +++ b/octocitrico.sh @@ -1,6 +1,8 @@ #!/bin/bash ARMBIAN_REPO="https://github.com/armbian/build" +ARMBIAN_TAG="v20.05" OCTOPI_REPO="https://github.com/guysoft/OctoPi" +MJPGSTREAMER_REPO="https://github.com/jacksonliam/mjpg-streamer.git" OCTOPI_TAG="0.17.0" AR_DIR=armbian_build UP_DIR=$AR_DIR/userpatches @@ -10,63 +12,93 @@ VAGRANT_DIR=armbian_build/config/templates VAGRANT_BOX="ubuntu/bionic64" #VAGRANT_BOX="ubuntu/focal64" +BOS=$(uname -s) + set -e -echo "OptoCitrico script => $1" +echo "OptoCitrico script => $1 [runining on $BOS]" if [ $# -eq 0 ] ; then echo "Usage:" - echo " $0 box : install ubuntu box for builing" - echo " $0 drop : destroy build virtual manchine" - echo " $0 clean : delete all build resources" - echo " $0 assets : download build assets" - echo " $0 build : Build image for board " - echo " $0 native : Build image in native supported Ubuntu" - echo " $0 release : Create a git release (use for maintenance)" + echo " $0 box : install ubuntu box for builing" + echo " $0 drop : destroy build virtual manchine" + echo " $0 clean : delete all build resources (assets,box,vm)" + echo " $0 assets : download build assets" + echo " $0 build : Build image for board uisng vagrant" + echo " $0 dbuild : Build image for board using docker" + echo " $0 native : Build image in native supported Ubuntu" + echo " $0 release : Create a git release (use for maintenance)" exit 1 fi +if [ "$BOS" != "Darwin" ] && [ "$BOS" != "Linux" ] ; then + echo "$BOS not supported." + exit 2 +fi + +SEDI="sed -i bup -e" +[ "$BOS" == "Linux" ] && SEDI="sed -i" function clean_vm() { - if [ -d $AR_DIR ] && [ -d $UP_DIR ]; then - pushd $UP_DIR + if [ -d $VAGRANT_DIR ]; then + pushd $VAGRANT_DIR echo "Cleaning virtual machine...." vagrant destroy popd else - echo "$UP_DIR do not exist. nothing to clean" + echo "$VAGRAT_DIR do not exist. nothing to clean" fi } function build_start() { local board=$1 - local native=$2 + local build_mode=$2 + local enable_cache=$3 + echo "Setting up build environment for $board..." cp -v -R -p opi_source/src/modules/octopi/filesystem $OV_DIR cp -v -p boards/manifest $OV_DIR cp -v -p boards/common.sh $OV_DIR cp -v -R -p boards/common_fs $OV_DIR cp -v -R -p boards/$board $OV_DIR - if [ -z $native ] ; then - cp -v -p boards/$board/config.conf $UP_DIR/config-vagrant-guest.conf + dest_conf="$UP_DIR/config-vagrant-guest.conf" + if [ -z $build_mode ] ; then + dest_conf="$UP_DIR/config-vagrant-guest.conf" + elif [ "$build_mode" == "docker" ] ; then + dest_conf="$UP_DIR/config-dbuild.conf" else - cp -v -p boards/$board/config.conf $UP_DIR/config-native.conf + dest_conf="$UP_DIR/config-native.conf" fi + cp -v -p boards/$board/config.conf $dest_conf + # errase clean level if enable cache + if [[ ! -z $enable_cache ]] ; then + echo "Setting max cache!" + ${SEDI} "s/^CLEAN_LEVEL=\".*\"/CLEAN_LEVEL=\"\"/" $dest_conf + echo + fi + + source boards/manifest # generate customize script cat > $UP_DIR/customize-image.sh < $UP_DIR/lib.config <