From 6036492cc54533a1608a4e3742760d955de86626 Mon Sep 17 00:00:00 2001 From: paukstelis Date: Tue, 27 Sep 2022 21:11:32 -0400 Subject: [PATCH 01/14] replace journal with dmesg --- octoprint_deploy.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/octoprint_deploy.sh b/octoprint_deploy.sh index 9b8148e..0bccb9a 100755 --- a/octoprint_deploy.sh +++ b/octoprint_deploy.sh @@ -454,14 +454,15 @@ add_camera() { detect_printer() { echo echo - journalctl --rotate > /dev/null 2>&1 - journalctl --vacuum-time=1seconds > /dev/null 2>&1 + #journalctl --rotate > /dev/null 2>&1 + #journalctl --vacuum-time=1seconds > /dev/null 2>&1 + dmesg -C echo "Plug your printer in via USB now (detection time-out in 1 min)" counter=0 while [[ -z "$UDEV" ]] && [[ $counter -lt 30 ]]; do - UDEV=$(timeout 1s journalctl -kf | sed -n -e 's/^.*SerialNumber: //p') + UDEV=$(timeout 1s dmesg -w | sed -n -e 's/^.*SerialNumber: //p') if [[ -z "$TEMPUSB" ]]; then - TEMPUSB=$(timeout 1s journalctl -kf | sed -n -e 's/^.*\(cdc_acm\|ftdi_sio\|ch341\|cp210x\) \([0-9].*[0-9]\): \(tty.*\|FTD.*\|ch341-uart.*\|cp210x\).*/\2/p') + TEMPUSB=$(timeout 1s dmesg -w | sed -n -e 's/^.*\(cdc_acm\|ftdi_sio\|ch341\|cp210x\) \([0-9].*[0-9]\): \(tty.*\|FTD.*\|ch341-uart.*\|cp210x\).*/\2/p') else sleep 1 fi From ef5722dbe6511c504f9b4b2a6ee0bb3ee8e10a2b Mon Sep 17 00:00:00 2001 From: paukstelis Date: Tue, 27 Sep 2022 21:21:36 -0400 Subject: [PATCH 02/14] camera to dmesg --- octoprint_deploy.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/octoprint_deploy.sh b/octoprint_deploy.sh index 0bccb9a..3ec0cc6 100755 --- a/octoprint_deploy.sh +++ b/octoprint_deploy.sh @@ -187,7 +187,7 @@ new_instance () { if prompt_confirm "Do you want to use the physical USB port to assign the udev entry? If you use this any USB hubs and printers detected this way must stay plugged into the same USB positions on your machine as they are right now"; then echo USB=$TEMPUSB - echo -e "Your printer will be setup at the following usb address:\033[0;34m $USB\033[0m" | log + echo -e "Your printer will be setup at the following usb address: $USB" | log echo else main_menu @@ -379,13 +379,14 @@ add_camera() { done fi - journalctl --rotate > /dev/null 2>&1 - journalctl --vacuum-time=1seconds > /dev/null 2>&1 + #journalctl --rotate > /dev/null 2>&1 + #journalctl --vacuum-time=1seconds > /dev/null 2>&1 + dmesg -C echo "Plug your camera in via USB now (detection time-out in 1 min)" counter=0 while [[ -z "$CAM" ]] && [[ $counter -lt 30 ]]; do - CAM=$(timeout 1s journalctl -kf | sed -n -e 's/^.*SerialNumber: //p') - TEMPUSBCAM=$(timeout 1s journalctl -kf | sed -n -e 's|^.*input:.*/\(.*\)/input/input.*|\1|p') + CAM=$(timeout 1s dmesg -w | sed -n -e 's/^.*SerialNumber: //p') + TEMPUSBCAM=$(timeout 1s dmesg -w | sed -n -e 's|^.*input:.*/\(.*\)/input/input.*|\1|p') counter=$(( $counter + 1 )) done #Failed state. Nothing detected From bb541cefb0f63a0a933c07af669ad6149444bcbc Mon Sep 17 00:00:00 2001 From: paukstelis Date: Wed, 28 Sep 2022 19:18:48 -0400 Subject: [PATCH 03/14] terminate early if no SN --- octoprint_deploy.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/octoprint_deploy.sh b/octoprint_deploy.sh index 3ec0cc6..64e3918 100755 --- a/octoprint_deploy.sh +++ b/octoprint_deploy.sh @@ -193,7 +193,7 @@ new_instance () { main_menu fi else - echo -e "Serial number detected as: \033[0;34m $UDEV\033[0m" | log + echo -e "Serial number detected as: $UDEV" | log check_sn "$UDEV" echo fi @@ -388,9 +388,12 @@ add_camera() { CAM=$(timeout 1s dmesg -w | sed -n -e 's/^.*SerialNumber: //p') TEMPUSBCAM=$(timeout 1s dmesg -w | sed -n -e 's|^.*input:.*/\(.*\)/input/input.*|\1|p') counter=$(( $counter + 1 )) + if [[ -n "$TEMPUSBCAM" ]] && [[ -z "$CAM" ]] + break + fi done #Failed state. Nothing detected - if [ -z "$CAM" ] && [ -z "$TEMPUSBCAM" ]; then + if [ -z "$CAM" ] && [ -z "$TEMPUSBCAM" ] ; then echo echo -e "\033[0;31mNo camera was detected during the detection period.\033[0m" echo @@ -468,6 +471,10 @@ detect_printer() { sleep 1 fi counter=$(( $counter + 1 )) + #No need to complete timeout in this case + if [[ -n "$TEMPUSB" ]] && [[ -z "$UDEV" ]] + break + fi done } From 6b944270f5a848cf8453dbef5e34f1950d34d73b Mon Sep 17 00:00:00 2001 From: paukstelis Date: Wed, 28 Sep 2022 19:20:14 -0400 Subject: [PATCH 04/14] dmesg commit --- octoprint_deploy.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/octoprint_deploy.sh b/octoprint_deploy.sh index 64e3918..e65f98d 100755 --- a/octoprint_deploy.sh +++ b/octoprint_deploy.sh @@ -379,8 +379,6 @@ add_camera() { done fi - #journalctl --rotate > /dev/null 2>&1 - #journalctl --vacuum-time=1seconds > /dev/null 2>&1 dmesg -C echo "Plug your camera in via USB now (detection time-out in 1 min)" counter=0 @@ -388,7 +386,7 @@ add_camera() { CAM=$(timeout 1s dmesg -w | sed -n -e 's/^.*SerialNumber: //p') TEMPUSBCAM=$(timeout 1s dmesg -w | sed -n -e 's|^.*input:.*/\(.*\)/input/input.*|\1|p') counter=$(( $counter + 1 )) - if [[ -n "$TEMPUSBCAM" ]] && [[ -z "$CAM" ]] + if [[ -n "$TEMPUSBCAM" ]] && [[ -z "$CAM" ]]; then break fi done From 66c00441cd35c1d67968ad951baae9971923dabf Mon Sep 17 00:00:00 2001 From: paukstelis Date: Wed, 28 Sep 2022 19:20:46 -0400 Subject: [PATCH 05/14] camera dmesg --- octoprint_deploy.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/octoprint_deploy.sh b/octoprint_deploy.sh index e65f98d..a4e447a 100755 --- a/octoprint_deploy.sh +++ b/octoprint_deploy.sh @@ -470,7 +470,7 @@ detect_printer() { fi counter=$(( $counter + 1 )) #No need to complete timeout in this case - if [[ -n "$TEMPUSB" ]] && [[ -z "$UDEV" ]] + if [[ -n "$TEMPUSB" ]] && [[ -z "$UDEV" ]]; then break fi done From f97d0ae80f2dc94630ac86ab490d6072d53d1eab Mon Sep 17 00:00:00 2001 From: paukstelis Date: Wed, 28 Sep 2022 19:33:38 -0400 Subject: [PATCH 06/14] redorder udev an tempusb --- octoprint_deploy.sh | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/octoprint_deploy.sh b/octoprint_deploy.sh index a4e447a..8623899 100755 --- a/octoprint_deploy.sh +++ b/octoprint_deploy.sh @@ -461,13 +461,9 @@ detect_printer() { dmesg -C echo "Plug your printer in via USB now (detection time-out in 1 min)" counter=0 - while [[ -z "$UDEV" ]] && [[ $counter -lt 30 ]]; do + while [[ -z "$UDEV" ]] && [[ $counter -lt 30 ]]; do + TEMPUSB=$(timeout 1s dmesg -w | sed -n -e 's/^.*\(cdc_acm\|ftdi_sio\|ch341\|cp210x\) \([0-9].*[0-9]\): \(tty.*\|FTD.*\|ch341-uart.*\|cp210x\).*/\2/p') UDEV=$(timeout 1s dmesg -w | sed -n -e 's/^.*SerialNumber: //p') - if [[ -z "$TEMPUSB" ]]; then - TEMPUSB=$(timeout 1s dmesg -w | sed -n -e 's/^.*\(cdc_acm\|ftdi_sio\|ch341\|cp210x\) \([0-9].*[0-9]\): \(tty.*\|FTD.*\|ch341-uart.*\|cp210x\).*/\2/p') - else - sleep 1 - fi counter=$(( $counter + 1 )) #No need to complete timeout in this case if [[ -n "$TEMPUSB" ]] && [[ -z "$UDEV" ]]; then From 82eedca7ecf57f93c42d83a9224976f9de537480 Mon Sep 17 00:00:00 2001 From: paukstelis Date: Wed, 28 Sep 2022 19:40:50 -0400 Subject: [PATCH 07/14] extra tempusb check --- octoprint_deploy.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/octoprint_deploy.sh b/octoprint_deploy.sh index 8623899..00f2b9f 100755 --- a/octoprint_deploy.sh +++ b/octoprint_deploy.sh @@ -469,7 +469,10 @@ detect_printer() { if [[ -n "$TEMPUSB" ]] && [[ -z "$UDEV" ]]; then break fi + #run this one more time just to catch the USB position,even if we have a serial number done + TEMPUSB=$(dmesg | sed -n -e 's/^.*\(cdc_acm\|ftdi_sio\|ch341\|cp210x\) \([0-9].*[0-9]\): \(tty.*\|FTD.*\|ch341-uart.*\|cp210x\).*/\2/p') + } remove_instance() { From 8f8c9006cb66afaf37a1d0da62f6f74460672691 Mon Sep 17 00:00:00 2001 From: paukstelis Date: Wed, 28 Sep 2022 19:57:00 -0400 Subject: [PATCH 08/14] remove timeout on dmesg --- octoprint_deploy.sh | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/octoprint_deploy.sh b/octoprint_deploy.sh index 00f2b9f..c3c738f 100755 --- a/octoprint_deploy.sh +++ b/octoprint_deploy.sh @@ -383,13 +383,15 @@ add_camera() { echo "Plug your camera in via USB now (detection time-out in 1 min)" counter=0 while [[ -z "$CAM" ]] && [[ $counter -lt 30 ]]; do - CAM=$(timeout 1s dmesg -w | sed -n -e 's/^.*SerialNumber: //p') - TEMPUSBCAM=$(timeout 1s dmesg -w | sed -n -e 's|^.*input:.*/\(.*\)/input/input.*|\1|p') + CAM=$(dmesg -w | sed -n -e 's/^.*SerialNumber: //p') + TEMPUSBCAM=$(dmesg -w | sed -n -e 's|^.*input:.*/\(.*\)/input/input.*|\1|p') counter=$(( $counter + 1 )) if [[ -n "$TEMPUSBCAM" ]] && [[ -z "$CAM" ]]; then break fi + sleep 2 done + dmesg -C #Failed state. Nothing detected if [ -z "$CAM" ] && [ -z "$TEMPUSBCAM" ] ; then echo @@ -462,17 +464,16 @@ detect_printer() { echo "Plug your printer in via USB now (detection time-out in 1 min)" counter=0 while [[ -z "$UDEV" ]] && [[ $counter -lt 30 ]]; do - TEMPUSB=$(timeout 1s dmesg -w | sed -n -e 's/^.*\(cdc_acm\|ftdi_sio\|ch341\|cp210x\) \([0-9].*[0-9]\): \(tty.*\|FTD.*\|ch341-uart.*\|cp210x\).*/\2/p') - UDEV=$(timeout 1s dmesg -w | sed -n -e 's/^.*SerialNumber: //p') + TEMPUSB=$(dmesg -w | sed -n -e 's/^.*\(cdc_acm\|ftdi_sio\|ch341\|cp210x\) \([0-9].*[0-9]\): \(tty.*\|FTD.*\|ch341-uart.*\|cp210x\).*/\2/p') + UDEV=$(dmesg -w | sed -n -e 's/^.*SerialNumber: //p') counter=$(( $counter + 1 )) #No need to complete timeout in this case if [[ -n "$TEMPUSB" ]] && [[ -z "$UDEV" ]]; then break fi - #run this one more time just to catch the USB position,even if we have a serial number + sleep 2 done - TEMPUSB=$(dmesg | sed -n -e 's/^.*\(cdc_acm\|ftdi_sio\|ch341\|cp210x\) \([0-9].*[0-9]\): \(tty.*\|FTD.*\|ch341-uart.*\|cp210x\).*/\2/p') - + dmesg -C } remove_instance() { From fc05a04994382866c7f9dccb3761ec0f5775dafc Mon Sep 17 00:00:00 2001 From: paukstelis Date: Wed, 28 Sep 2022 19:59:43 -0400 Subject: [PATCH 09/14] remove console wait for dmesg --- octoprint_deploy.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/octoprint_deploy.sh b/octoprint_deploy.sh index c3c738f..43005bf 100755 --- a/octoprint_deploy.sh +++ b/octoprint_deploy.sh @@ -383,8 +383,8 @@ add_camera() { echo "Plug your camera in via USB now (detection time-out in 1 min)" counter=0 while [[ -z "$CAM" ]] && [[ $counter -lt 30 ]]; do - CAM=$(dmesg -w | sed -n -e 's/^.*SerialNumber: //p') - TEMPUSBCAM=$(dmesg -w | sed -n -e 's|^.*input:.*/\(.*\)/input/input.*|\1|p') + CAM=$(dmesg | sed -n -e 's/^.*SerialNumber: //p') + TEMPUSBCAM=$(dmesg | sed -n -e 's|^.*input:.*/\(.*\)/input/input.*|\1|p') counter=$(( $counter + 1 )) if [[ -n "$TEMPUSBCAM" ]] && [[ -z "$CAM" ]]; then break @@ -464,8 +464,8 @@ detect_printer() { echo "Plug your printer in via USB now (detection time-out in 1 min)" counter=0 while [[ -z "$UDEV" ]] && [[ $counter -lt 30 ]]; do - TEMPUSB=$(dmesg -w | sed -n -e 's/^.*\(cdc_acm\|ftdi_sio\|ch341\|cp210x\) \([0-9].*[0-9]\): \(tty.*\|FTD.*\|ch341-uart.*\|cp210x\).*/\2/p') - UDEV=$(dmesg -w | sed -n -e 's/^.*SerialNumber: //p') + TEMPUSB=$(dmesg | sed -n -e 's/^.*\(cdc_acm\|ftdi_sio\|ch341\|cp210x\) \([0-9].*[0-9]\): \(tty.*\|FTD.*\|ch341-uart.*\|cp210x\).*/\2/p') + UDEV=$(dmesg | sed -n -e 's/^.*SerialNumber: //p') counter=$(( $counter + 1 )) #No need to complete timeout in this case if [[ -n "$TEMPUSB" ]] && [[ -z "$UDEV" ]]; then From 5c665e0318936524249a61f46e834fae81446c83 Mon Sep 17 00:00:00 2001 From: paukstelis Date: Wed, 28 Sep 2022 20:32:04 -0400 Subject: [PATCH 10/14] version 0.1.3 --- README.md | 5 +++-- octoprint_deploy.sh | 13 +++++-------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 837479c..9758323 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ These files provide a simple bash script for quickly deploying multiple octoprin * If you did not setup admin user in the script, setup admin user by connecting to http://octopi.local via browser. * Back in the ssh session, choose `New Instance` and follow the instructions. * Do not plug your printer in by USB until you are asked to do so. - * If your printer does not have a serial number (all Creality printers), it will time out during serial number detection and use the physical USB address for udev entries. + * If your printer does not have a serial number (all Creality printers), it will detect and use the physical USB address for udev entries. * Continue until you have added all the printers you want to use. * haproxy entries are updated so you can connect via http://octopi.local/instancename/ (trailing slash is needed). * Please note, haproxy entries are NOT used for webcams once you use this system. Connect to them via hostname:port. @@ -42,7 +42,7 @@ These files provide a simple bash script for quickly deploying multiple octoprin * __This instance is just a generic template used for making all your other instances. You need to make at least one instance using the script when this is done. Do not add a camera to the generic instance.__ * Continue with octoprint_deploy script, choose `New Instance` and follow the instructions. * Do not plug the printer in by USB until you are asked to do so. - * If your printer does not have a serial number (all Creality printers) allow the auto-detection to time-out and it will detect by the USB port you plugged it in to. + * If your printer does not have a serial number (all Creality printers) it will detect by the USB port you plugged it in to. * After adding the first instance, the template instance will be shutdown. This is normal. * Add as many instances as you have printers, following the instructions. * To add more printers at a later date, or to add cameras to an instance if you did not do that while setting up the printers, simply run the script again (`sudo octoprint_deploy/octoprint_deploy.sh`) and choose the appropriate options. @@ -56,6 +56,7 @@ These files provide a simple bash script for quickly deploying multiple octoprin * Restart all non-template instances from the command line: `sudo octoprint_deploy/octoprint_deploy.sh restart_all` * Change udev rules for an instance with `sudo octoprint_deploy/octoprint_deploy.sh replace` # Recent Changes +* 0.1.3, printer and camera detection now done with dmesg instead of journalctl. This allows faster timeouts when a device is detected by USB port but it does not have a serial number. * Write /etc/octoprint_deploy if missing (older version system preparation) * Add option for plugin installation during system preparation. * Enable ssh. diff --git a/octoprint_deploy.sh b/octoprint_deploy.sh index 43005bf..b9b892e 100755 --- a/octoprint_deploy.sh +++ b/octoprint_deploy.sh @@ -382,14 +382,14 @@ add_camera() { dmesg -C echo "Plug your camera in via USB now (detection time-out in 1 min)" counter=0 - while [[ -z "$CAM" ]] && [[ $counter -lt 30 ]]; do + while [[ -z "$CAM" ]] && [[ $counter -lt 60 ]]; do CAM=$(dmesg | sed -n -e 's/^.*SerialNumber: //p') TEMPUSBCAM=$(dmesg | sed -n -e 's|^.*input:.*/\(.*\)/input/input.*|\1|p') counter=$(( $counter + 1 )) if [[ -n "$TEMPUSBCAM" ]] && [[ -z "$CAM" ]]; then break fi - sleep 2 + sleep 1 done dmesg -C #Failed state. Nothing detected @@ -458,20 +458,17 @@ add_camera() { detect_printer() { echo echo - #journalctl --rotate > /dev/null 2>&1 - #journalctl --vacuum-time=1seconds > /dev/null 2>&1 dmesg -C echo "Plug your printer in via USB now (detection time-out in 1 min)" counter=0 - while [[ -z "$UDEV" ]] && [[ $counter -lt 30 ]]; do + while [[ -z "$UDEV" ]] && [[ $counter -lt 60 ]]; do TEMPUSB=$(dmesg | sed -n -e 's/^.*\(cdc_acm\|ftdi_sio\|ch341\|cp210x\) \([0-9].*[0-9]\): \(tty.*\|FTD.*\|ch341-uart.*\|cp210x\).*/\2/p') UDEV=$(dmesg | sed -n -e 's/^.*SerialNumber: //p') counter=$(( $counter + 1 )) - #No need to complete timeout in this case if [[ -n "$TEMPUSB" ]] && [[ -z "$UDEV" ]]; then break fi - sleep 2 + sleep 1 done dmesg -C } @@ -1088,7 +1085,7 @@ replace_id() { } main_menu() { - VERSION=0.1.2 + VERSION=0.1.3 #reset UDEV='' TEMPUSB='' From b8fd1dacded7e372d626828bd5176d13c0485501 Mon Sep 17 00:00:00 2001 From: paukstelis Date: Wed, 28 Sep 2022 20:51:03 -0400 Subject: [PATCH 11/14] root check --- README.md | 8 ++++---- octoprint_deploy.sh | 8 +++++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 9758323..be3fee8 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -Updated June 26, 2022. +Updated September 28, 2022. Want to support this work? Buy Me a Coffee. https://www.buymeacoffee.com/ppaukstelis. Need help with octoprint_deploy? You can open issues here or ask on Discord: https://discord.gg/6vgSjgvR6u # octoprint_deploy -These files provide a simple bash script for quickly deploying multiple octoprint instances on a single computer. For Linux systems (Ubuntu, Fedora, etc.) it will also install OctoPrint and a video streamer (mjpg-streamer or ustreamer). No need for lots of file editing or complicated Docker compose scripts! +These files provide a bash script for quickly deploying multiple octoprint instances on a single computer. For Linux systems (Ubuntu, Fedora, etc.) it will also install OctoPrint and a video streamer (mjpg-streamer or ustreamer). No need for lots of file editing or complicated Docker compose scripts! # How to use * OctoPi @@ -56,13 +56,13 @@ These files provide a simple bash script for quickly deploying multiple octoprin * Restart all non-template instances from the command line: `sudo octoprint_deploy/octoprint_deploy.sh restart_all` * Change udev rules for an instance with `sudo octoprint_deploy/octoprint_deploy.sh replace` # Recent Changes -* 0.1.3, printer and camera detection now done with dmesg instead of journalctl. This allows faster timeouts when a device is detected by USB port but it does not have a serial number. +* 0.1.3, printer and camera detection now done with dmesg instead of journalctl. This allows faster timeouts when a device is detected by the USB port but it does not have a serial number. * Write /etc/octoprint_deploy if missing (older version system preparation) * Add option for plugin installation during system preparation. * Enable ssh. * Added webcam restart to system commands during camera addition. * Admin user and first run wizards during Prepare System. # TODO -* Cameras behind haproxy? +* Multiple cameras for an instance (see multi-camera branch) diff --git a/octoprint_deploy.sh b/octoprint_deploy.sh index b9b892e..e2cfa2f 100755 --- a/octoprint_deploy.sh +++ b/octoprint_deploy.sh @@ -2,7 +2,13 @@ #all operations must be with root/sudo if (( $EUID != 0 )); then - echo "Please run as root (sudo)" + echo "Please run with sudo" + exit +fi + +#this is a weak check, but while catch most cases +if [ "$USER" == root ]; then + echo "You should not run this script as root. Use sudo as a normal user" exit fi From 9363901fe94e7f978efe59ee743fb5b28ea0c32a Mon Sep 17 00:00:00 2001 From: paukstelis Date: Wed, 28 Sep 2022 21:35:38 -0400 Subject: [PATCH 12/14] fix root check --- README.md | 9 +++++---- octoprint_deploy.sh | 6 +++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index be3fee8..19b395e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ Updated September 28, 2022. Want to support this work? Buy Me a Coffee. https://www.buymeacoffee.com/ppaukstelis. -Need help with octoprint_deploy? You can open issues here or ask on Discord: https://discord.gg/6vgSjgvR6u +Need help with octoprint_deploy? Ask on Discord: https://discord.gg/6vgSjgvR6u # octoprint_deploy These files provide a bash script for quickly deploying multiple octoprint instances on a single computer. For Linux systems (Ubuntu, Fedora, etc.) it will also install OctoPrint and a video streamer (mjpg-streamer or ustreamer). No need for lots of file editing or complicated Docker compose scripts! @@ -39,13 +39,13 @@ These files provide a bash script for quickly deploying multiple octoprint insta * You will be prompted if you want to setup the admin user and do the first run wizard via the commandline. If you do this now you can start making new instances as soon as the system preparation is complete. * You will be prompted if you want to install recommended plugins and cloud plugins. This can be useful if you want to configure plugins in your template instance, before adding new instances. * If you didn't setup admin user in the step above, setup admin user by connecting to your system (either http://localhost:5000 or http://[hostname]:5000 via a browser - * __This instance is just a generic template used for making all your other instances. You need to make at least one instance using the script when this is done. Do not add a camera to the generic instance.__ + * __This instance is just a generic template used for making all your other instances. You need to make at least one instance using the script when this is done.__ * Continue with octoprint_deploy script, choose `New Instance` and follow the instructions. * Do not plug the printer in by USB until you are asked to do so. - * If your printer does not have a serial number (all Creality printers) it will detect by the USB port you plugged it in to. + * If your printer does not have a serial number (all Creality printers) it will be detected by the USB port you plugged it in to. * After adding the first instance, the template instance will be shutdown. This is normal. * Add as many instances as you have printers, following the instructions. - * To add more printers at a later date, or to add cameras to an instance if you did not do that while setting up the printers, simply run the script again (`sudo octoprint_deploy/octoprint_deploy.sh`) and choose the appropriate options. + * To add more printers at a later date, or to add cameras to an instance, simply run the script again (`sudo octoprint_deploy/octoprint_deploy.sh`) and choose the appropriate options. * Remember, camera installed with this script are experimental and always will be. The script makes some basic assumptions that you may need to change later. Cameras suck up quite a bit of USB bandwidth so while it is quite straightforward to run 10 printers with a modest computer, you can't also run 10 cameras. * What else can you do? * Remove instances @@ -57,6 +57,7 @@ These files provide a bash script for quickly deploying multiple octoprint insta * Change udev rules for an instance with `sudo octoprint_deploy/octoprint_deploy.sh replace` # Recent Changes * 0.1.3, printer and camera detection now done with dmesg instead of journalctl. This allows faster timeouts when a device is detected by the USB port but it does not have a serial number. +* Fail if sudouser is root. * Write /etc/octoprint_deploy if missing (older version system preparation) * Add option for plugin installation during system preparation. * Enable ssh. diff --git a/octoprint_deploy.sh b/octoprint_deploy.sh index e2cfa2f..55552bd 100755 --- a/octoprint_deploy.sh +++ b/octoprint_deploy.sh @@ -6,8 +6,9 @@ if (( $EUID != 0 )); then exit fi -#this is a weak check, but while catch most cases -if [ "$USER" == root ]; then +#this is a weak check, but will catch most cases +if [ $SUDO_USER ]; then user=$SUDO_USER; fi +if [ "$user" == root ]; then echo "You should not run this script as root. Use sudo as a normal user" exit fi @@ -1150,7 +1151,6 @@ main_menu() { done } # initiate logging -if [ $SUDO_USER ]; then user=$SUDO_USER; fi logfile='octoprint_deploy.log' SCRIPTDIR=$(dirname $(readlink -f $0)) source $SCRIPTDIR/plugins.sh From 17d92ad774868b5dde78ec6cf2a0a0e9bf13059d Mon Sep 17 00:00:00 2001 From: paukstelis Date: Wed, 28 Sep 2022 21:42:37 -0400 Subject: [PATCH 13/14] update readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 19b395e..9b8ff15 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,7 @@ These files provide a bash script for quickly deploying multiple octoprint insta # Recent Changes * 0.1.3, printer and camera detection now done with dmesg instead of journalctl. This allows faster timeouts when a device is detected by the USB port but it does not have a serial number. * Fail if sudouser is root. +* Add MIT license * Write /etc/octoprint_deploy if missing (older version system preparation) * Add option for plugin installation during system preparation. * Enable ssh. From a275b4bf1cf22a5abc2978c75b02d46568d4a245 Mon Sep 17 00:00:00 2001 From: paukstelis Date: Wed, 28 Sep 2022 21:44:14 -0400 Subject: [PATCH 14/14] add update note --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 9b8ff15..22e5450 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,7 @@ These files provide a bash script for quickly deploying multiple octoprint insta * Backup and restore files for an instance from the menu, or backup all instances with `sudo octoprint_deploy/octoprint_deploy backup` * Restart all non-template instances from the command line: `sudo octoprint_deploy/octoprint_deploy.sh restart_all` * Change udev rules for an instance with `sudo octoprint_deploy/octoprint_deploy.sh replace` + * Always a good idea to update octoprint_deploy from time-to-time with `git -C octoprint_deploy pull` # Recent Changes * 0.1.3, printer and camera detection now done with dmesg instead of journalctl. This allows faster timeouts when a device is detected by the USB port but it does not have a serial number. * Fail if sudouser is root.