Merge branch 'dmesg'
This commit is contained in:
20
README.md
20
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
|
||||
Need help with octoprint_deploy? 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
|
||||
@@ -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.
|
||||
@@ -39,13 +39,13 @@ These files provide a simple bash script for quickly deploying multiple octoprin
|
||||
* 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) 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 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
|
||||
@@ -55,13 +55,17 @@ These files provide a simple bash script for quickly deploying multiple octoprin
|
||||
* 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.
|
||||
* Add MIT license
|
||||
* 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)
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,14 @@
|
||||
|
||||
#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 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
|
||||
|
||||
@@ -187,13 +194,13 @@ 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
|
||||
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
|
||||
@@ -379,17 +386,21 @@ 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
|
||||
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')
|
||||
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 1
|
||||
done
|
||||
dmesg -C
|
||||
#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
|
||||
@@ -454,19 +465,19 @@ 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
|
||||
UDEV=$(timeout 1s journalctl -kf | 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')
|
||||
else
|
||||
sleep 1
|
||||
fi
|
||||
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 ))
|
||||
if [[ -n "$TEMPUSB" ]] && [[ -z "$UDEV" ]]; then
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
dmesg -C
|
||||
}
|
||||
|
||||
remove_instance() {
|
||||
@@ -1081,7 +1092,7 @@ replace_id() {
|
||||
}
|
||||
|
||||
main_menu() {
|
||||
VERSION=0.1.2
|
||||
VERSION=0.1.3
|
||||
#reset
|
||||
UDEV=''
|
||||
TEMPUSB=''
|
||||
@@ -1140,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
|
||||
|
||||
Reference in New Issue
Block a user