Install-файл стал бинарём и добавлены bash-помощники helper_pre/post

This commit is contained in:
Nikolay Kopitonenko 2024-03-15 21:49:12 +03:00
parent a2a39b14bd
commit b58389da87
5 changed files with 89 additions and 0 deletions

21
helper_post Executable file
View File

@ -0,0 +1,21 @@
#!/bin/bash
. variables.inc.sh
[ -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 &

60
helper_pre Executable file
View File

@ -0,0 +1,60 @@
#!/bin/bash
. variables.inc.sh
[ "$configsHome" = "$ConfigsHome" ] || \
echo "Custom ConfigsHome: $ConfigsHome"
set -x
git config pull.rebase false
[ -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
chown -R 0:0 /home/pi/printer_hw
mkdir -p /home/pi/.klippy
chown pi:pi /home/pi/.klippy
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
[ -e /home/pi/3dscreen.custom.config.js ] || \
touch /home/pi/3dscreen.custom.config.js

BIN
install

Binary file not shown.

Binary file not shown.

8
variables.inc.sh Executable file
View File

@ -0,0 +1,8 @@
#!/bin/bash
GITEA_BASE="https://app.3diy.ru:9999/3diy"
HomePi="/home/pi"
SetupHome="$HomePi/.setup"
InstallHome="$PWD"
configsHome="$SetupHome/cfg"
ConfigsHome=${MY_ConfigsHome:-$configsHome}