touchprint/stage2/04-octoprint/01-run.sh
Logan Gartner c7f44ec412
Added HTTP basic auth, default octoprint config
Added HTTP basic auth to MJPG stream, so now you don't have to worry
about creeps watching your printer

Nginx now runs as www-data

Frontend specific files are no longer put into /etc/skel, they are now
only installed to the kiosk account

OctoPrint now has a default config so that users don't have to configure
system stuff (ex. You don't have to input /webcam/ into the stream box
anymore)

Restart Browser button now kills old Surf sessions

The Raspberry Pi now starts with the Raspberry Pi cameras enabled on
first boot

OctoPrint can now shutdown, reboot and restart its own service using
sudo without a password

Kiosk account no longer has a password since you aren't supposed to
login as kiosk anyways
2020-08-26 21:30:10 -06:00

33 lines
1.3 KiB
Bash
Executable file

#!/bin/bash -e
install -m 644 files/octoprint.service ${ROOTFS_DIR}/etc/systemd/system/octoprint.service
mkdir -p ${ROOTFS_DIR}/home/octoprint/.octoprint/
install -m 600 files/config.yaml ${ROOTFS_DIR}/home/octoprint/.octoprint/config.yaml
install -m 644 files/nginx.conf ${ROOTFS_DIR}/etc/nginx/nginx.conf
echo -e "listen 443;" > ${ROOTFS_DIR}/etc/nginx/listen.conf
mkdir -p ${ROOTFS_DIR}/usr/local/bin
install -m 755 files/restart-octoprint ${ROOTFS_DIR}/usr/local/bin/restart-octoprint
# Yeah I could've used polkit, but this works fine so whatever
mkdir -p ${ROOTFS_DIR}/etc/sudoers.d
echo "octoprint ALL=NOPASSWD: /sbin/shutdown" > ${ROOTFS_DIR}/etc/sudoers.d/octoprint-shutdown
echo "octoprint ALL=NOPASSWD: /usr/local/bin/restart-octoprint" > ${ROOTFS_DIR}/etc/sudoers.d/octoprint-restart
on_chroot << EOF
# Package enables this when installed, won't start until first-time is run due to missing SSL certs
systemctl disable nginx
# If OctoPrint already exists, skip this (for debugging)
if [[ ! -f /srv/octoprint/bin/octoprint ]]; then
cd /srv/ || exit 1
virtualenv octoprint || exit 1
source octoprint/bin/activate || exit 1
pip install pip --upgrade
pip install octoprint || exit 1
# Fix permissions
chown -R octoprint:octoprint /srv/octoprint
chown -R octoprint:octoprint /home/octoprint
fi
EOF