This commit is contained in:
Nikolay Kopitonenko 2024-02-16 05:33:03 +03:00
commit 507d1a5a82
4 changed files with 240 additions and 0 deletions

BIN
goss Executable file

Binary file not shown.

145
goss.yaml Normal file
View File

@ -0,0 +1,145 @@
file:
/home/pi/printer.cfg:
exists: true
filetype: file
owner: root
group: root
mode: "0644"
contents:
- "[include printer_hw/hw.cfg]"
- "[include printer_soft/soft.cfg]"
- "[include 3dscreen/klipper/configs/*.cfg]"
- "[include printer/*.cfg]"
- "[bltouch]"
/home/pi/printer_hw/bed.cfg:
exists: true
filetype: file
owner: root
group: root
mode: "0644"
/home/pi/printer_hw/filament_sensor.cfg:
exists: true
filetype: file
owner: root
group: root
mode: "0644"
/home/pi/printer_hw/hw.cfg:
exists: true
filetype: file
owner: root
group: root
mode: "0644"
/home/pi/printer_soft/soft.cfg:
exists: true
filetype: file
owner: root
group: root
mode: "0644"
/home/pi/printer_hw:
filetype: directory
exists: true
owner: root
group: root
mode: "0755"
/home/pi/printer_soft:
filetype: directory
exists: true
owner: root
group: root
mode: "0755"
/home/pi/printer:
filetype: directory
exists: true
owner: pi
group: pi
mode: "0755"
/home/pi/klipper/.git:
filetype: directory
exists: true
owner: pi
group: pi
mode: "0755"
/home/pi/.octoprint/config.yaml:
exists: true
filetype: file
mode: "0644"
contents:
- "port: /tmp/printer"
- " - /tmp/printer"
/home/pi/.octoprint/plugins/OctoprintKlipperPlugin/.git:
filetype: directory
exists: true
owner: root
group: root
mode: "0755"
/etc/init.d/klipper:
exists: true
filetype: file
owner: root
group: root
mode: "0755"
md5: 3e4606f6b4d8d0037d5383a3cdcfaf3f
/etc/default/klipper:
exists: true
filetype: file
owner: root
group: root
mode: "0644"
contents: |
KLIPPY_USER=pi
KLIPPY_EXEC=/home/pi/klippy-env/bin/python
KLIPPY_ARGS="/home/pi/klipper/klippy/klippy.py /home/pi/printer.cfg -I /tmp/klippy -a /tmp/klippy.sock -l /tmp/klippy.log"
/home/pi/3dscreen:
exists: true
filetype: directory
owner: root
group: root
mode: "0755"
/home/pi/3dscreen.settings.json:
exists: true
filetype: file
owner: root
group: root
mode: "0644"
contents:
- '"system.branch.tekuschaya":"true"'
/home/pi/3dscreen.custom.config.js:
exists: true
filetype: file
owner: root
group: root
mode: "0644"
/etc/sudoers.d/010_pi-nopasswd:
exists: true
filetype: file
owner: root
group: root
mode: "0440"
contents: |
pi ALL=(ALL) NOPASSWD: ALL
service:
klipper:
name: klipper
enabled: true
octoprint:
name: octoprint
enabled: false

95
install Executable file
View File

@ -0,0 +1,95 @@
#!/bin/bash
GITEA_BASE="https://app.3diy.ru:9999/3diy"
HomePi="/home/pi"
SetupHome="$HomePi/.setup"
InstallHome="$SetupHome/install"
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)
}
[ -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
mkdir -p /home/pi/printer_hw /home/pi/printer_soft /home/pi/printer
[ -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 &

BIN
install_helper Executable file

Binary file not shown.