allow initial instance creation without udev (#96)

* better failure if first run is true

* better conditional for tempusb

* remove camera port selection

* syntax error

* bad break

* add qualifier if udev not set
This commit is contained in:
paukstelis
2023-06-30 09:35:28 -04:00
committed by GitHub
parent 829de78794
commit 9f70670ee8
5 changed files with 31 additions and 36 deletions

View File

@@ -1,9 +1,9 @@
Updated June 24, 2023. Updated June 30, 2023.
Want to support this work? Buy Me a Coffee. https://www.buymeacoffee.com/ppaukstelis. Want to support this work? Buy Me a Coffee. https://www.buymeacoffee.com/ppaukstelis.
Need help with octoprint_deploy? Ask on Discord: https://discord.gg/6vgSjgvR6u Need help with octoprint_deploy? Ask on Discord: https://discord.gg/6vgSjgvR6u
# octoprint_deploy 1.0.1 - ALL NEW # octoprint_deploy 1.0.2 - ALL NEW
* 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 (ustreamer). No need for lots of file editing or complicated Docker compose scripts! A background video on how it generally works from my ERRF2022 talk can be found here: https://www.youtube.com/watch?v=q0iCNl8-kJI&t=15378s * 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 (ustreamer). No need for lots of file editing or complicated Docker compose scripts! A background video on how it generally works from my ERRF2022 talk can be found here: https://www.youtube.com/watch?v=q0iCNl8-kJI&t=15378s
* octoprint_deploy and octoprint_install are being merged! Maintaining two separate scripts was close to twice the amount of work. By merging the scripts many new features have been included, while also providing greater simplicity in setup. For now, the merged script will be called octoprint_deploy and at some point the octoprint_install repository will point here. * octoprint_deploy and octoprint_install are being merged! Maintaining two separate scripts was close to twice the amount of work. By merging the scripts many new features have been included, while also providing greater simplicity in setup. For now, the merged script will be called octoprint_deploy and at some point the octoprint_install repository will point here.
* The biggest change is that there is no longer the notion of a single 'template' OctoPrint instance. Now, _any_ previously configured instance can be used as a template when a new instance is created. The choice is up to the user. * The biggest change is that there is no longer the notion of a single 'template' OctoPrint instance. Now, _any_ previously configured instance can be used as a template when a new instance is created. The choice is up to the user.
@@ -48,6 +48,7 @@ Need help with octoprint_deploy? Ask on Discord: https://discord.gg/6vgSjgvR6u
* Backup and restore files for an instance from the menu, or backup all instances with `sudo octoprint_deploy/octoprint_deploy backup` * Backup and restore files for an instance from the menu, or backup all instances with `sudo octoprint_deploy/octoprint_deploy backup`
* Restart all instances from the command line: `sudo octoprint_deploy/octoprint_deploy.sh restart_all` * Restart all instances from the command line: `sudo octoprint_deploy/octoprint_deploy.sh restart_all`
# Recent Changes # Recent Changes
* Allow first instance creation without udev rule
* Fixed dialout permissions. * Fixed dialout permissions.
* Lots of changes, now octoprint_deploy 1.0.0 * Lots of changes, now octoprint_deploy 1.0.0
* Udev utility menu * Udev utility menu

View File

@@ -76,7 +76,7 @@ write_camera() {
mv $SCRIPTDIR/cam${INUM}_$INSTANCE.service /etc/systemd/system/ mv $SCRIPTDIR/cam${INUM}_$INSTANCE.service /etc/systemd/system/
echo "camera:cam${INUM}_$INSTANCE port:$CAMPORT udev:true" >> /etc/octoprint_cameras echo "camera:cam${INUM}_$INSTANCE port:$CAMPORT udev:true" >> /etc/octoprint_cameras
#config.yaml modifications - only if INUM not set #config.yaml modifications - only if INUM not set
if [ -z "$INUM" ]; then if [ -z "$INUM" ]; then
sudo -u $user $OCTOEXEC --basedir $BASE config set plugins.classicwebcam.snapshot "http://localhost:$CAMPORT?action=snapshot" sudo -u $user $OCTOEXEC --basedir $BASE config set plugins.classicwebcam.snapshot "http://localhost:$CAMPORT?action=snapshot"
@@ -86,7 +86,7 @@ write_camera() {
else else
sudo -u $user $OCTOEXEC --basedir $BASE config set plugins.classicwebcam.stream "/cam_$INSTANCE/?action=stream" sudo -u $user $OCTOEXEC --basedir $BASE config set plugins.classicwebcam.stream "/cam_$INSTANCE/?action=stream"
fi fi
sudo -u $user $OCTOEXEC --basedir $BASE config append_value --json system.actions "{\"action\": \"Reset video streamer\", \"command\": \"sudo systemctl restart cam_$INSTANCE\", \"name\": \"Restart webcam\"}" sudo -u $user $OCTOEXEC --basedir $BASE config append_value --json system.actions "{\"action\": \"Reset video streamer\", \"command\": \"sudo systemctl restart cam_$INSTANCE\", \"name\": \"Restart webcam\"}"
if prompt_confirm "Instance must be restarted for settings to take effect. Restart now?"; then if prompt_confirm "Instance must be restarted for settings to take effect. Restart now?"; then
@@ -220,24 +220,11 @@ add_camera() {
echo echo
fi fi
while true; do CAMPORT=$(tail -1 /etc/octoprint_cameras 2>/dev/null | sed -n -e 's/^.*\(port:\)\(.*\)/\2/p')
echo "Camera Port (ENTER will increment last value found in /etc/octoprint_cameras):" if [ -z "$CAMPORT" ]; then
read CAMPORT CAMPORT=8000
if [ -z "$CAMPORT" ]; then fi
CAMPORT=$(tail -1 /etc/octoprint_cameras | sed -n -e 's/^.*\(port:\)\(.*\)/\2/p') CAMPORT=$((CAMPORT+1))
if [ -z "$CAMPORT" ]; then
CAMPORT=8000
fi
CAMPORT=$((CAMPORT+1))
fi
if [ $CAMPORT -gt 7000 ]; then
break
else
echo "Camera Port must be greater than 7000"
fi
done
echo "Settings can be modified after initial setup in /etc/systemd/system/cam${INUM}_$INSTANCE.service" echo "Settings can be modified after initial setup in /etc/systemd/system/cam${INUM}_$INSTANCE.service"
echo echo

View File

@@ -144,16 +144,20 @@ new_instance() {
printer_udev true printer_udev true
#Append instance name to list for removal tool #Append instance name to list for removal tool
echo "instance:$INSTANCE port:$PORT udev:true" >> /etc/octoprint_instances if [ -z "$UDEV" ] && [ -z "$TEMPUSB" ]; then
echo "instance:$INSTANCE port:$PORT udev:false" >> /etc/octoprint_instances
else
echo "instance:$INSTANCE port:$PORT udev:true" >> /etc/octoprint_instances
fi
if [ -n "$TEMPLATE" ]; then if [ -n "$TEMPLATE" ]; then
#There may be other combinations of things to include/exclude #There may be other combinations of things to include/exclude
if [ $COPY -eq 1 ]; then if [ $COPY -eq 1 ]; then
sudo -u $user rsync -r \ sudo -u $user rsync -r \
--exclude 'timelapse' \ --exclude 'timelapse' \
--exclude 'uploads' \ --exclude 'uploads' \
--exclude 'logs' \ --exclude 'logs' \
$BFOLD/* $OCTOCONFIG/.$INSTANCE/ $BFOLD/* $OCTOCONFIG/.$INSTANCE/
fi fi
if [ $COPY -eq 2 ]; then if [ $COPY -eq 2 ]; then
sudo -u $user rsync -r \ sudo -u $user rsync -r \
@@ -279,7 +283,7 @@ printer_udev() {
fi fi
else else
#No serial number #No serial number
if [ -z "$UDEV" ]; then if [ -z "$UDEV" ] && [ -n "$TEMPUSB" ]; then
echo "Printer Serial Number not detected" echo "Printer Serial Number not detected"
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 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 echo
@@ -301,7 +305,11 @@ printer_udev() {
echo "Check your USB cable (power only?) and try again." echo "Check your USB cable (power only?) and try again."
echo echo
echo echo
main_menu if [ $firstrun == "true" ]; then
echo "You can attempt adding a udev rule later from the Utilities menu."
else
main_menu
fi
fi fi
fi fi
} }

11
menu.sh
View File

@@ -2,6 +2,7 @@
source $SCRIPTDIR/prepare.sh source $SCRIPTDIR/prepare.sh
white=$(echo -en "\e[39m") white=$(echo -en "\e[39m")
green=$(echo -en "\e[92m") green=$(echo -en "\e[92m")
red=$(echo -en "\e[91m")
magenta=$(echo -en "\e[35m") magenta=$(echo -en "\e[35m")
cyan=$(echo -en "\e[96m") cyan=$(echo -en "\e[96m")
yellow=$(echo -en "\e[93m") yellow=$(echo -en "\e[93m")
@@ -100,10 +101,9 @@ remove_instance_menu() {
remove_camera_menu() { remove_camera_menu() {
get_settings get_settings
PS3="${green}Select camera number to remove: ${white}" PS3="${green}Select camera number to remove: ${white}"
readarray -t cameras < <(cat /etc/octoprint_cameras | sed -n -e 's/^camera:\([[:graph:]]*\) .*/\1/p') get_cameras true
cameras+=("Quit")
select camera in "${cameras[@]}" select camera in "${CAMERA_ARR[@]}"
do do
if [ "$camera" == Quit ]; then if [ "$camera" == Quit ]; then
main_menu main_menu
@@ -225,9 +225,8 @@ create_menu() {
echo echo
echo echo
PS3="${green}Select instance number to backup: ${white}" PS3="${green}Select instance number to backup: ${white}"
readarray -t options < <(cat /etc/octoprint_instances | sed -n -e 's/^instance:\([[:graph:]]*\) .*/\1/p') get_instances true
options+=("Quit") select opt in "${INSTANCE_ARR[@]}"
select opt in "${options[@]}"
do do
if [ "$opt" == Quit ]; then if [ "$opt" == Quit ]; then
main_menu main_menu

View File

@@ -304,13 +304,13 @@ remove_everything() {
get_settings get_settings
if prompt_confirm "Remove everything?"; then if prompt_confirm "Remove everything?"; then
get_instances false get_instances false
unset 'instances[0]' get_cameras false
readarray -t cameras < <(ls -1 /etc/systemd/system/cam*.service 2>/dev/null | sed -n -e 's/^.*\/\(.*\).service/\1/p')
for instance in "${INSTANCE_ARR[@]}"; do for instance in "${INSTANCE_ARR[@]}"; do
remove_instance $instance remove_instance $instance
done done
for camera in "${cameras[@]}"; do for camera in "${CAMERA_ARR[@]}"; do
remove_camera $camera remove_camera $camera
done done