3dscreen_installer/helper_post

81 lines
2.1 KiB
Bash
Executable File

#!/bin/bash
. variables.inc.sh
echo
echo "Starting: helper_post"
set -xe
[ -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 -C $ConfigsHome/etc/default/klipper /etc/default/klipper
# Mainsail
[ -e /home/pi/mainsail ] && {
su - pi -c "cd /home/pi/mainsail \
&& chmod 755 .git \
&& git pull \
"
:
} || {
su - pi -c "cd /home/pi \
&& git clone --depth=1 $GITEA_BASE/mainsail.git \
&& (cd mainsail && git config pull.rebase false) \
"
}
chmod 0 /home/pi/mainsail/.git
apt-get -y install nginx
rm -f /etc/nginx/conf.d/default.conf
rm -f /etc/nginx/sites-enabled/default
[ -e /etc/nginx/conf.d/mainsail.conf ] || \
install -m644 -o 0 -g 0 $ConfigsHome/etc/nginx/conf.d/mainsail.conf /etc/nginx/conf.d/mainsail.conf
[ -e /etc/nginx/sites-enabled/mainsail ] || \
install -m644 -o 0 -g 0 $ConfigsHome/etc/nginx/sites-enabled/mainsail /etc/nginx/sites-enabled/mainsail
install -m644 -o 0 -g 0 -C $ConfigsHome/etc/haproxy/haproxy.cfg /etc/haproxy/haproxy.cfg
# Moonraker
mkdir /home/pi/printer_data/config &>/dev/null || :
chown pi:pi /home/pi/printer_data/config &>/dev/null || :
[ -e /home/pi/printer_data/config/moonraker.conf ] || \
install -m644 -o pi -g pi $ConfigsHome/home/pi/printer_data/config/moonraker.conf /home/pi/printer_data/config/moonraker.conf
[ -e /home/pi/moonraker ] && {
su - pi -c "cd /home/pi/moonraker \
&& git pull \
"
:
} || {
su - pi -c "cd /home/pi \
&& git clone --depth=1 $GITEA_BASE/moonraker.git \
&& (cd moonraker && git config pull.rebase false) \
&& ./moonraker/scripts/install-moonraker.sh \
"
}
bash -c '
systemctl enable klipper
systemctl unmask nginx
systemctl enable nginx
systemctl enable octoprint
systemctl restart haproxy
systemctl restart nginx
systemctl restart klipper
systemctl restart moonraker
' 2>/dev/null &