From 76200d1b89098b15f243ece877777503e4482676 Mon Sep 17 00:00:00 2001 From: Logan Gartner Date: Tue, 11 Aug 2020 17:26:21 -0600 Subject: [PATCH] Added OctoPrint service, made NoDM actually work Changed the NoDM config so that it evaluated variables Added OctoPrint service file Started work on custom config tools Browser now checks to see if OctoPrint is running before launching browser --- stage1/01-sys-tweaks/00-run.sh | 1 + stage1/01-sys-tweaks/files/.browser.sh | 8 ++++++++ stage1/01-sys-tweaks/files/autostart | 2 +- stage1/03-install-packages/01-run.sh | 4 ++++ stage1/03-install-packages/files/octo-config | 3 +++ stage2/04-octoprint/01-run.sh | 20 ++++++++++++-------- stage2/04-octoprint/files/octoprint.service | 12 ++++++++++++ stage3/00-install-packages/01-run.sh | 2 +- 8 files changed, 42 insertions(+), 10 deletions(-) create mode 100644 stage1/01-sys-tweaks/files/.browser.sh create mode 100755 stage1/03-install-packages/01-run.sh create mode 100755 stage1/03-install-packages/files/octo-config create mode 100644 stage2/04-octoprint/files/octoprint.service diff --git a/stage1/01-sys-tweaks/00-run.sh b/stage1/01-sys-tweaks/00-run.sh index de17df8..f65334f 100755 --- a/stage1/01-sys-tweaks/00-run.sh +++ b/stage1/01-sys-tweaks/00-run.sh @@ -4,6 +4,7 @@ install -d "${ROOTFS_DIR}/etc/systemd/system/getty@tty1.service.d" install -m 644 files/noclear.conf "${ROOTFS_DIR}/etc/systemd/system/getty@tty1.service.d/noclear.conf" install -v -m 644 files/fstab "${ROOTFS_DIR}/etc/fstab" install -m 755 files/.xprofile "${ROOTFS_DIR}/etc/skel/.xprofile" +install -m 755 files/.browser.sh "${ROOTFS_DIR}/etc/skel/.browser.sh" mkdir -p "${ROOTFS_DIR}/etc/skel/.config/openbox" install -m 644 files/autostart "${ROOTFS_DIR}/etc/skel/.config/openbox/autostart" diff --git a/stage1/01-sys-tweaks/files/.browser.sh b/stage1/01-sys-tweaks/files/.browser.sh new file mode 100644 index 0000000..e4ead29 --- /dev/null +++ b/stage1/01-sys-tweaks/files/.browser.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +# Wait until OctoPrint comes up +while ! curl localhost:5000 2>&1 >/dev/null; do + sleep 1 +done + +surf -d -F -g -K -n -p localhost:5000 diff --git a/stage1/01-sys-tweaks/files/autostart b/stage1/01-sys-tweaks/files/autostart index 3cf629e..94f13e2 100644 --- a/stage1/01-sys-tweaks/files/autostart +++ b/stage1/01-sys-tweaks/files/autostart @@ -1 +1 @@ -surf -d -F -g -K -n -p google.com & +bash ~/.browser.sh & diff --git a/stage1/03-install-packages/01-run.sh b/stage1/03-install-packages/01-run.sh new file mode 100755 index 0000000..88b9e91 --- /dev/null +++ b/stage1/03-install-packages/01-run.sh @@ -0,0 +1,4 @@ +#!/bin/bash -e + +mkdir -p "${ROOTFS_DIR}/usr/local/bin/" +install -m 755 files/octo-config "${ROOTFS_DIR}/usr/local/bin/octo-config" diff --git a/stage1/03-install-packages/files/octo-config b/stage1/03-install-packages/files/octo-config new file mode 100755 index 0000000..9ad7a17 --- /dev/null +++ b/stage1/03-install-packages/files/octo-config @@ -0,0 +1,3 @@ +#!/bin/bash + + diff --git a/stage2/04-octoprint/01-run.sh b/stage2/04-octoprint/01-run.sh index 1a8cc90..b0def11 100755 --- a/stage2/04-octoprint/01-run.sh +++ b/stage2/04-octoprint/01-run.sh @@ -1,13 +1,17 @@ #!/bin/bash -e +install -m 644 files/octoprint.service ${ROOTFS_DIR}/etc/systemd/system/octoprint.service + on_chroot << EOF -if [ -d /home/octoprint ]; then - cd /home/octoprint || exit 1 - mkdir OctoPrint || exit 1 - cd OctoPrint || exit 1 - virtualenv venv || exit 1 - source venv/bin/activate || exit 1 - pip install pip --upgrade || exit 1 - pip install octoprint || exit 1 +if ! pip list | grep -F octoprint; then + if [ -d /home/octoprint ]; then + cd /home/octoprint || exit 1 + if [[ ! -d OctoPrint ]]; then mkdir OctoPrint; fi || exit 1 + cd OctoPrint || exit 1 + virtualenv venv || exit 1 + source venv/bin/activate || exit 1 + pip install pip --upgrade || exit 1 + pip install octoprint || exit 1 + fi fi EOF diff --git a/stage2/04-octoprint/files/octoprint.service b/stage2/04-octoprint/files/octoprint.service new file mode 100644 index 0000000..08c3b66 --- /dev/null +++ b/stage2/04-octoprint/files/octoprint.service @@ -0,0 +1,12 @@ +[Unit] +Description=OctoPrint Daemon + +[Service] +Type=simple +User=octoprint +Group=octoprint +ExecStart=/home/octoprint/OctoPrint/venv/bin/octoprint serve + +[Install] +WantedBy=multi-user.target + diff --git a/stage3/00-install-packages/01-run.sh b/stage3/00-install-packages/01-run.sh index a17b109..3e596c2 100755 --- a/stage3/00-install-packages/01-run.sh +++ b/stage3/00-install-packages/01-run.sh @@ -2,7 +2,7 @@ #echo -n -e "NODM_USER=${FIRST_USER_NAME}\nNODM_XSESSION=/home/${FIRST_USER_NAME}/.xprofile" > ${ROOTFS_DIR}/etc/nodm.conf -cat > /etc/default/nodm << 'EOF' +cat > ${ROOTFS_DIR}/etc/default/nodm << EOF # nodm configuration # Set NODM_ENABLED to something different than 'false' to enable nodm