Author: Adam <git@apiote.xyz>
return 1 from execute on errors
toymaker.sh | 16 ++++++++++++++--
diff --git a/toymaker.sh b/toymaker.sh index f39a92384f95dcfbf6ca2f109f548581ab7b6798..8c35678651acb5313c1f4561faee6e3c12010cfa 100755 --- a/toymaker.sh +++ b/toymaker.sh @@ -191,6 +191,7 @@ then respond200 "$(echo "$page" | tail -n+2)" else respond406 "$accept" + return 1 fi else r=$(list_items "$toy") @@ -199,11 +200,13 @@ content=$(echo "$r" | cut -d ';' -f2) if [ "$status" = 'n' ] then respond404 "$path" + return 1 elif page=$(templateMessage "$toy;$content" 'toy' 'text/html') then respond200 "$(echo "$page" | tail -n+2)" else respond406 "$accept" + return 1 fi fi elif [ "$(slashes "$path")" -eq 3 ] @@ -221,6 +224,7 @@ status=$(echo "$r" | head -n1 | cut -d ';' -f1) if [ "$status" = 'n' ] then respond404 "$path" + return 1 elif page=$(templateMessage "$toy;$item;$r" 'item' "$accept") # todo add artifacts to message then body=$(echo "$page" | tail -n+2) @@ -233,6 +237,7 @@ respond200 "$body" "$contentType" fi else respond406 "$accept" + return 1 fi elif [ "$(slashes "$path")" -eq 4 ] then @@ -244,6 +249,7 @@ status=$(echo "$r" | cut -d ';' -f 1) if [ "$status" = 'n' ] then respond404 "$path" + return 1 else contentType=$(echo "$r" | cut -d ';' -f 2) filePath=$(echo "$r" | cut -d ';' -f 3) @@ -251,15 +257,17 @@ respond200file "$filePath" "$contentType" fi else respond404 "$path" + return 1 fi ;; POST) - check_auth "$authorization" || return + check_auth "$authorization" || return 1 toy=$(field "$path" 3) if [ "$(slashes "$path")" -ne 3 ] || [ -n "$(field "$path" 4)" ] then respond404 "$path" + return 1 fi if ! (podman image ls --format "{{.Repository}}" | grep -x "localhost/toy_$toy" -q) @@ -273,11 +281,12 @@ then respond202 "$toy" "$item" else respond500 "error while creating $toy" + return 1 fi ;; DELETE) - check_auth "$authorization" || return + check_auth "$authorization" || return 1 if [ "$(slashes "$path")" -eq 3 ] then @@ -288,13 +297,16 @@ then respond200 "" else respond500 "error while stopping $toy/$item" + return 1 fi else respond404 "$path" + return 1 fi ;; *) respond405 "$method" + return 1 ;; esac }