Skip to content

Commit 8608e9c

Browse files
committed
Save and read variables
1 parent 6d40ac8 commit 8608e9c

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

deploy/truenas_ws.sh

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -175,25 +175,31 @@ truenas_ws_deploy() {
175175
_debug _file_ca "$_file_ca"
176176
_debug _file_fullchain "$_file_fullchain"
177177

178-
########## Default values for hostname and protocol
179-
[ -n "${DEPLOY_TRUENAS_HOSTNAME}" ] || DEPLOY_TRUENAS_HOSTNAME="localhost"
180-
[ -n "${DEPLOY_TRUENAS_PROTOCOL}" ] || DEPLOY_TRUENAS_PROTOCOL="ws"
181-
182-
_debug2 DEPLOY_TRUENAS_HOSTNAME "$DEPLOY_TRUENAS_HOSTNAME"
183-
_debug2 DEPLOY_TRUENAS_PROTOCOL "$DEPLOY_TRUENAS_PROTOCOL"
184-
185-
_ws_uri="$DEPLOY_TRUENAS_PROTOCOL://$DEPLOY_TRUENAS_HOSTNAME/websocket"
186-
_debug _ws_uri "$_ws_uri"
187-
188178
########## Environment check
189179

190180
_info "Checking environment variables..."
191181
_getdeployconf DEPLOY_TRUENAS_APIKEY
182+
_getdeployconf DEPLOY_TRUENAS_HOSTNAME
183+
_getdeployconf DEPLOY_TRUENAS_PROTOCOL
192184
# Check API Key
193185
if [ -z "$DEPLOY_TRUENAS_APIKEY" ]; then
194186
_err "TrueNAS API key not found, please set the DEPLOY_TRUENAS_APIKEY environment variable."
195187
return 1
196188
fi
189+
# Check Hostname, default to localhost if not set
190+
if [ -z "$DEPLOY_TRUENAS_HOSTNAME" ]; then
191+
_info "TrueNAS hostname not set. Using 'localhost'."
192+
DEPLOY_TRUENAS_HOSTNAME="localhost"
193+
fi
194+
# Check protocol, default to ws if not set
195+
if [ -z "$DEPLOY_TRUENAS_PROTOCOL" ]; then
196+
_info "TrueNAS protocol not set. Using 'ws'."
197+
DEPLOY_TRUENAS_PROTOCOL="ws"
198+
fi
199+
_ws_uri="$DEPLOY_TRUENAS_PROTOCOL://$DEPLOY_TRUENAS_HOSTNAME/websocket"
200+
_debug2 DEPLOY_TRUENAS_HOSTNAME "$DEPLOY_TRUENAS_HOSTNAME"
201+
_debug2 DEPLOY_TRUENAS_PROTOCOL "$DEPLOY_TRUENAS_PROTOCOL"
202+
_debug _ws_uri "$_ws_uri"
197203
_secure_debug2 DEPLOY_TRUENAS_APIKEY "$DEPLOY_TRUENAS_APIKEY"
198204
_info "Environment variables: OK"
199205

@@ -215,6 +221,8 @@ truenas_ws_deploy() {
215221
return 2
216222
fi
217223
_savedeployconf DEPLOY_TRUENAS_APIKEY "$DEPLOY_TRUENAS_APIKEY"
224+
_savedeployconf DEPLOY_TRUENAS_HOSTNAME "$DEPLOY_TRUENAS_HOSTNAME"
225+
_savedeployconf DEPLOY_TRUENAS_PROTOCOL "$DEPLOY_TRUENAS_PROTOCOL"
218226
_info "TrueNAS health: OK"
219227

220228
########## System info

0 commit comments

Comments
 (0)