From 928565685e74ab6018487596a1caef3857142f65 Mon Sep 17 00:00:00 2001 From: paukstelis Date: Sun, 5 Mar 2023 09:26:31 -0500 Subject: [PATCH 1/4] cameraport gt 7000 --- octoprint_deploy.sh | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/octoprint_deploy.sh b/octoprint_deploy.sh index 34dd3e4..d39749e 100755 --- a/octoprint_deploy.sh +++ b/octoprint_deploy.sh @@ -490,18 +490,26 @@ add_camera() { echo fi - echo "Camera Port (ENTER will increment last value in /etc/camera_ports):" - read CAMPORT - if [ -z "$CAMPORT" ]; then - CAMPORT=$(tail -1 /etc/camera_ports) + while true; do + echo "Camera Port (ENTER will increment last value in /etc/camera_ports):" + read CAMPORT + if [ -z "$CAMPORT" ]; then + CAMPORT=$(tail -1 /etc/camera_ports) if [ -z "$CAMPORT" ]; then CAMPORT=8000 fi - CAMPORT=$((CAMPORT+1)) - echo Selected port is: $CAMPORT | log + + if [[ $CAMPORT -gt 7000 ]]; then + break + else + echo "Camera Port must be greater than 7000" + fi fi + + done + echo "Settings can be modified after initial setup in /etc/systemd/system/cam${INUM}_$INSTANCE.service" echo while true; do From 05ddd6b03b433cd6479e8d5d1e85f7320780686f Mon Sep 17 00:00:00 2001 From: paukstelis Date: Thu, 6 Apr 2023 19:48:38 -0400 Subject: [PATCH 2/4] cameraport adjust --- octoprint_deploy.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/octoprint_deploy.sh b/octoprint_deploy.sh index d39749e..21a3be7 100755 --- a/octoprint_deploy.sh +++ b/octoprint_deploy.sh @@ -501,7 +501,7 @@ add_camera() { fi CAMPORT=$((CAMPORT+1)) - if [[ $CAMPORT -gt 7000 ]]; then + if [ $CAMPORT -gt 7000 ]; then break else echo "Camera Port must be greater than 7000" From 9149a1b790090a0ef73ba8e6477d44ae96291a10 Mon Sep 17 00:00:00 2001 From: paukstelis Date: Thu, 6 Apr 2023 19:54:18 -0400 Subject: [PATCH 3/4] more fixes for camport --- octoprint_deploy.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/octoprint_deploy.sh b/octoprint_deploy.sh index 21a3be7..db350e0 100755 --- a/octoprint_deploy.sh +++ b/octoprint_deploy.sh @@ -495,10 +495,12 @@ add_camera() { read CAMPORT if [ -z "$CAMPORT" ]; then CAMPORT=$(tail -1 /etc/camera_ports) - + fi + if [ -z "$CAMPORT" ]; then CAMPORT=8000 fi + CAMPORT=$((CAMPORT+1)) if [ $CAMPORT -gt 7000 ]; then From 5f6f5a81ce45a6b7890daa0d8cb01fee90d41d18 Mon Sep 17 00:00:00 2001 From: paukstelis Date: Thu, 6 Apr 2023 19:55:03 -0400 Subject: [PATCH 4/4] if fixes --- octoprint_deploy.sh | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/octoprint_deploy.sh b/octoprint_deploy.sh index db350e0..50acbe9 100755 --- a/octoprint_deploy.sh +++ b/octoprint_deploy.sh @@ -277,13 +277,13 @@ new_instance () { HAversion=$(haproxy -v | sed -n 's/^.*version \([0-9]\).*/\1/p') #find frontend line, do insert #Don't know how to do the formatting correctly here. This works, however. - -SEDREPLACE="#$INSTANCE start\n\ - acl is_$INSTANCE url_beg /$INSTANCE\n\ - http-request redirect scheme http drop-query append-slash if is_$INSTANCE ! { path_beg /$INSTANCE/ }\n\ - use_backend $INSTANCE if { path_beg /$INSTANCE/ }\n\ -#$INSTANCE stop" - + + SEDREPLACE="#$INSTANCE start\n\ + acl is_$INSTANCE url_beg /$INSTANCE\n\ + http-request redirect scheme http drop-query append-slash if is_$INSTANCE ! { path_beg /$INSTANCE/ }\n\ + use_backend $INSTANCE if { path_beg /$INSTANCE/ }\n\ + #$INSTANCE stop" + sed -i "/option forwardfor except 127.0.0.1/a $SEDREPLACE" /etc/haproxy/haproxy.cfg echo "#$INSTANCE start" >> /etc/haproxy/haproxy.cfg echo "backend $INSTANCE" >> /etc/haproxy/haproxy.cfg @@ -392,15 +392,15 @@ write_camera() { #find frontend line, do insert sed -i "/use_backend $INSTANCE if/a\ use_backend cam${INUM}_$INSTANCE if { path_beg /cam${INUM}_$INSTANCE/ }" /etc/haproxy/haproxy.cfg if [ $HAversion -gt 1 ]; then -EXTRACAM="backend cam${INUM}_$INSTANCE\n\ - http-request replace-path /cam${INUM}_$INSTANCE/(.*) /|\1\n\ - server webcam1 127.0.0.1:$CAMPORT" + EXTRACAM="backend cam${INUM}_$INSTANCE\n\ + http-request replace-path /cam${INUM}_$INSTANCE/(.*) /|\1\n\ + server webcam1 127.0.0.1:$CAMPORT" else -EXTRACAM="backend cam${INUM}_$INSTANCE\n\ - reqrep ^([^\ :]*)\ /cam${INUM}_$INSTANCE/(.*) \1\ /|\2 \n\ - server webcam1 127.0.0.1:$CAMPORT" + EXTRACAM="backend cam${INUM}_$INSTANCE\n\ + reqrep ^([^\ :]*)\ /cam${INUM}_$INSTANCE/(.*) \1\ /|\2 \n\ + server webcam1 127.0.0.1:$CAMPORT" fi - + echo "#cam${INUM}_$INSTANCE start" >> /etc/haproxy/haproxy.cfg sed -i "/#cam${INUM}_$INSTANCE start/a $EXTRACAM" /etc/haproxy/haproxy.cfg #these are necessary because sed append seems to have issues with escaping for the /\1 @@ -496,22 +496,22 @@ add_camera() { if [ -z "$CAMPORT" ]; then CAMPORT=$(tail -1 /etc/camera_ports) fi - + if [ -z "$CAMPORT" ]; then CAMPORT=8000 fi CAMPORT=$((CAMPORT+1)) - + if [ $CAMPORT -gt 7000 ]; then break else echo "Camera Port must be greater than 7000" fi - fi - + + done - + echo "Settings can be modified after initial setup in /etc/systemd/system/cam${INUM}_$INSTANCE.service" echo while true; do @@ -1024,7 +1024,7 @@ remove_instance() { for camera in "${cameras[@]}"; do remove_camera $camera done - + #remove udev entry sed -i "/$opt/d" /etc/udev/rules.d/99-octoprint.rules #remove files