Skip to content

Commit

Permalink
Update truenas_ws.sh (added return instead exit)
Browse files Browse the repository at this point in the history
  • Loading branch information
Attackwave authored Nov 25, 2024
1 parent d7855e8 commit f2a311b
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions deploy/truenas_ws.sh
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ truenas_ws_deploy() {
if [ -z "$DEPLOY_TRUENAS_APIKEY" ]
then
_err "TrueNAS API key not found, please set the DEPLOY_TRUENAS_APIKEY environment variable."
exit 1
return 1
fi
_secure_debug2 DEPLOY_TRUENAS_APIKEY "$DEPLOY_TRUENAS_APIKEY"
_info "Environment variables: OK"
Expand All @@ -175,15 +175,15 @@ truenas_ws_deploy() {
then
_err "Error calling system.ready:"
_err "$_ws_response"
exit $_ws_ret
return $_ws_ret
fi

if [ "$_ws_response" != "TRUE" ]
then
_err "TrueNAS is not ready."
_err "Please check environment variables DEPLOY_TRUENAS_APIKEY, DEPLOY_TRUENAS_HOSTNAME and DEPLOY_TRUENAS_PROTOCOL."
_err "Verify API key."
exit 2
return 2
fi
_savedeployconf DEPLOY_TRUENAS_APIKEY "$DEPLOY_TRUENAS_APIKEY"
_info "TrueNAS health: OK"
Expand All @@ -199,7 +199,7 @@ truenas_ws_deploy() {
if [ "$_truenas_system" != "SCALE" ] && [ "$_truenas_system" != "CORE" ]
then
_err "Cannot gather TrueNAS system. Nor CORE oder SCALE detected."
exit 10
return 10
fi

########## Gather current certificate
Expand All @@ -221,13 +221,13 @@ truenas_ws_deploy() {
if ! _ws_check_jobid "$_ws_jobid"
then
_err "No JobID returned from websocket method."
exit 3
return 3
fi
_ws_result=$(_ws_get_job_result "$_ws_jobid")
_ws_ret=$?
if [ $_ws_ret -gt 0 ]
then
exit $_ws_ret
return $_ws_ret
fi
_debug "_ws_result" "$_ws_result"
_new_certid=$(printf "%s" "$_ws_result" | jq -r '."id"')
Expand All @@ -242,7 +242,7 @@ truenas_ws_deploy() {
then
_err "Cannot set FTP certificate."
_debug "_ws_response" "$_ws_response"
exit 4
return 4
fi

########## ix Apps (SCALE only)
Expand All @@ -264,13 +264,13 @@ truenas_ws_deploy() {
if ! _ws_check_jobid "$_ws_jobid"
then
_err "No JobID returned from websocket method."
exit 3
return 3
fi
_ws_result=$(_ws_get_job_result "$_ws_jobid")
_ws_ret=$?
if [ $_ws_ret -gt 0 ]
then
exit $_ws_ret
return $_ws_ret
fi
_debug "_ws_result" "$_ws_result"
_info "App certificate replaced."
Expand All @@ -288,7 +288,7 @@ truenas_ws_deploy() {
if [ "$_changed_certid" != "$_new_certid" ]
then
_err "WebUI certificate change error.."
exit 5
return 5
else
_info "WebUI certificate replaced."
fi
Expand All @@ -304,13 +304,13 @@ truenas_ws_deploy() {
if ! _ws_check_jobid "$_ws_jobid"
then
_err "No JobID returned from websocket method."
exit 3
return 3
fi
_ws_result=$(_ws_get_job_result "$_ws_jobid")
_ws_ret=$?
if [ $_ws_ret -gt 0 ]
then
exit $_ws_ret
return $_ws_ret
fi


Expand Down

0 comments on commit f2a311b

Please sign in to comment.