2020-09-03 03:20:38 -04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -e
|
2020-08-17 19:54:31 -04:00
|
|
|
|
|
|
|
install -m 644 files/octoprint.service ${ROOTFS_DIR}/etc/systemd/system/octoprint.service
|
2020-08-26 23:30:10 -04:00
|
|
|
mkdir -p ${ROOTFS_DIR}/home/octoprint/.octoprint/
|
|
|
|
install -m 600 files/config.yaml ${ROOTFS_DIR}/home/octoprint/.octoprint/config.yaml
|
2020-08-17 19:54:31 -04:00
|
|
|
|
|
|
|
install -m 644 files/nginx.conf ${ROOTFS_DIR}/etc/nginx/nginx.conf
|
2021-01-27 20:34:57 -05:00
|
|
|
echo -e "listen 443 ssl;" > ${ROOTFS_DIR}/etc/nginx/listen.conf
|
2020-09-03 18:55:33 -04:00
|
|
|
touch ${ROOTFS_DIR}/etc/nginx/auth.conf
|
2020-08-17 19:54:31 -04:00
|
|
|
|
2020-08-26 23:30:10 -04:00
|
|
|
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
|
|
|
|
|
2020-08-17 19:54:31 -04:00
|
|
|
on_chroot << EOF
|
|
|
|
# Package enables this when installed, won't start until first-time is run due to missing SSL certs
|
|
|
|
systemctl disable nginx
|
2020-08-26 23:30:10 -04:00
|
|
|
|
2020-08-17 19:54:31 -04:00
|
|
|
# If OctoPrint already exists, skip this (for debugging)
|
|
|
|
if [[ ! -f /srv/octoprint/bin/octoprint ]]; then
|
2020-10-10 19:51:21 -04:00
|
|
|
python3 -m venv /srv/octoprint || exit 1
|
|
|
|
source /srv/octoprint/bin/activate || exit 1
|
2020-08-17 19:54:31 -04:00
|
|
|
pip install pip --upgrade
|
|
|
|
pip install octoprint || exit 1
|
|
|
|
# Fix permissions
|
|
|
|
chown -R octoprint:octoprint /srv/octoprint
|
2020-08-26 23:30:10 -04:00
|
|
|
chown -R octoprint:octoprint /home/octoprint
|
2020-08-17 19:54:31 -04:00
|
|
|
fi
|
|
|
|
EOF
|