#!/bin/bash GITEA_BASE="https://app.3diy.ru:9999/3diy" HomePi="/home/pi" SetupHome="$HomePi/.setup" InstallHome="$SetupHome/installer" configsHome="$SetupHome/cfg" ConfigsHome=${MY_ConfigsHome:-$configsHome} [ "$configsHome" = "$ConfigsHome" ] || \ echo "Custom ConfigsHome: $ConfigsHome" set -x [ -e "$ConfigsHome" ] && { (cd "$ConfigsHome" \ && git pull \ ) : } || { git clone "$GITEA_BASE/octopi_configs.git" "$ConfigsHome" (cd "$ConfigsHome" && git config pull.rebase false) } mkdir -p /home/pi/printer_hw /home/pi/printer_soft /home/pi/printer [ -e /home/pi/printer.cfg ] || \ install -m644 -o 0 -g 0 $ConfigsHome/home/pi/printer.cfg /home/pi/printer.cfg [ -e /home/pi/printer_hw/bed.cfg ] || \ install -m644 -o 0 -g 0 $ConfigsHome/home/pi/printer_hw/bed.cfg /home/pi/printer_hw/bed.cfg [ -e /home/pi/printer_hw/filament_sensor.cfg ] || \ install -m644 -o 0 -g 0 $ConfigsHome/home/pi/printer_hw/filament_sensor.cfg /home/pi/printer_hw/filament_sensor.cfg [ -e /home/pi/printer_hw/hw.cfg ] || \ touch /home/pi/printer_hw/hw.cfg [ -e /home/pi/printer_soft/soft.cfg ] || \ touch /home/pi/printer_soft/soft.cfg chown -R 0:0 /home/pi/printer_hw /home/pi/printer_soft chown pi:pi /home/pi/printer install -m440 -o 0 -g 0 $ConfigsHome/etc/sudoers.d/010_pi-nopasswd /etc/sudoers.d/010_pi-nopasswd [ -e /home/pi/.octoprint/plugins/OctoprintKlipperPlugin ] && { bash -c 'cd /home/pi/.octoprint/plugins/OctoprintKlipperPlugin \ && git pull \ ' : } || { bash -c "cd /home/pi/.octoprint/plugins \ && git clone --depth=1 $GITEA_BASE/OctoprintKlipperPlugin.git \ && (cd OctoprintKlipperPlugin && git config pull.rebase false) \ " } SCREEN_URI="$GITEA_BASE/3diyscreen-klip-tek/releases/download/latest/3dscreen.zip" SCREEN_PATH=/home/pi/3dscreen SCREEN_ARCHIVE=/home/pi/3dscreen.zip [ -e /home/pi/3dscreen ] || { \ rm -rf "$SCREEN_PATH" "$SCREEN_ARCHIVE" \ && wget "$SCREEN_URI" -O "$SCREEN_ARCHIVE" \ && mkdir -p "$SCREEN_PATH" \ && (cd "$SCREEN_PATH" \ && unzip -q "$SCREEN_ARCHIVE" \ ) \ && echo "3dscreen: `cat $SCREEN_PATH/version`" } [ -e /home/pi/3dscreen.settings.json ] || \ install -m644 -o 0 -g 0 $ConfigsHome/home/pi/3dscreen.settings.json /home/pi/3dscreen.settings.json $InstallHome/install_helper [ -e /home/pi/klipper ] && { su - pi -c "cd /home/pi/klipper \ && git pull \ " : } || { su - pi -c "cd /home/pi \ && git clone --depth=1 $GITEA_BASE/klipper.git \ && (cd klipper && git config pull.rebase false) \ && ./klipper/scripts/install-octopi.sh \ " } install -m644 -o 0 -g 0 $ConfigsHome/etc/default/klipper /etc/default/klipper systemctl enable klipper 2>/dev/null systemctl disable octoprint 2>/dev/null systemctl restart klipper 2>/dev/null &