From 9a60f738bb74dc1bccadc839e58e7be78f25b15b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Norh=C3=B8j?= Date: Thu, 14 Jul 2022 20:43:17 +0200 Subject: [PATCH] Check formatting on resolution --- octoprint_deploy.sh | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/octoprint_deploy.sh b/octoprint_deploy.sh index 525c6a5..cbe0637 100755 --- a/octoprint_deploy.sh +++ b/octoprint_deploy.sh @@ -419,13 +419,20 @@ add_camera() { fi echo "Settings can be modified after initial setup in /etc/systemd/system/cam_$INSTANCE" echo - echo "Camera Resolution (no sanity check, so get it right) [default: 640x480]:" - read RESOLUTION - if [ -z "$RESOLUTION" ]; then - RESOLUTION="640x480" - fi + while true; do + echo "Camera Resolution [default: 640x480]:" + read RESOLUTION + if [ -z $RESOLUTION] + then + RESOLUTION="640x480" + break + elif [[ $RESOLUTION =~ ^[0-9]+x[0-9]+$ ]] + then + break + fi + echo "Invalid resolution" + done echo "Selected camera resolution: $RESOLUTION" | log - #TODO check formating echo "Camera Framerate (use 0 for ustreamer hardware) [default: 5]:" read FRAMERATE if [ -z "$FRAMERATE" ]; then