mirror of
https://github.com/acmesh-official/acme.sh.git
synced 2026-10-21 13:31:18 +00:00
Adding custom Port definitions for truenas (#7033)
* closing bracket and adding port for customer installations * adding savedeployconfig * fixing shfmt * changeing --------- Co-authored-by: neil <github@neilpang.com>
This commit is contained in:
1 parent
0d53d29f7e
commit
0925d5c522
1 file changed
+25
-5
+25
-5
@@ -16,7 +16,12 @@
|
|||||||
#
|
#
|
||||||
# # API KEY
|
# # API KEY
|
||||||
# # Use the folowing URL to create a new API token: <TRUENAS_HOSTNAME OR IP>/ui/apikeys
|
# # Use the folowing URL to create a new API token: <TRUENAS_HOSTNAME OR IP>/ui/apikeys
|
||||||
# export DEPLOY_TRUENAS_APIKEY="<API_KEY_GENERATED_IN_THE_WEB_UI"
|
# export DEPLOY_TRUENAS_APIKEY="<API_KEY_GENERATED_IN_THE_WEB_UI>"
|
||||||
|
# Optional:
|
||||||
|
# export DEPLOY_TRUENAS_HOSTNAME="<TRUENAS_HOSTNAME_OR_IP>"
|
||||||
|
# export DEPLOY_TRUENAS_PROTOCOL="wss" # ws or wss
|
||||||
|
# export DEPLOY_TRUENAS_PORT="443" # optional, e.g. 80, 443, 8443
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
||||||
### Private functions
|
### Private functions
|
||||||
@@ -56,7 +61,6 @@ _ws_call() {
|
|||||||
_ws_upload_cert() {
|
_ws_upload_cert() {
|
||||||
|
|
||||||
/usr/bin/env python - <<EOF
|
/usr/bin/env python - <<EOF
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from truenas_api_client import Client
|
from truenas_api_client import Client
|
||||||
@@ -78,7 +82,6 @@ with Client(uri="$_ws_uri") as c:
|
|||||||
print("R:0")
|
print("R:0")
|
||||||
print("E:_ws_upload_cert error!")
|
print("E:_ws_upload_cert error!")
|
||||||
sys.exit(7)
|
sys.exit(7)
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
return $?
|
return $?
|
||||||
@@ -181,6 +184,8 @@ truenas_ws_deploy() {
|
|||||||
_getdeployconf DEPLOY_TRUENAS_APIKEY
|
_getdeployconf DEPLOY_TRUENAS_APIKEY
|
||||||
_getdeployconf DEPLOY_TRUENAS_HOSTNAME
|
_getdeployconf DEPLOY_TRUENAS_HOSTNAME
|
||||||
_getdeployconf DEPLOY_TRUENAS_PROTOCOL
|
_getdeployconf DEPLOY_TRUENAS_PROTOCOL
|
||||||
|
_getdeployconf DEPLOY_TRUENAS_PORT
|
||||||
|
|
||||||
# Check API Key
|
# Check API Key
|
||||||
if [ -z "$DEPLOY_TRUENAS_APIKEY" ]; then
|
if [ -z "$DEPLOY_TRUENAS_APIKEY" ]; then
|
||||||
_err "TrueNAS API key not found, please set the DEPLOY_TRUENAS_APIKEY environment variable."
|
_err "TrueNAS API key not found, please set the DEPLOY_TRUENAS_APIKEY environment variable."
|
||||||
@@ -196,7 +201,21 @@ truenas_ws_deploy() {
|
|||||||
_info "TrueNAS protocol not set. Using 'ws'."
|
_info "TrueNAS protocol not set. Using 'ws'."
|
||||||
DEPLOY_TRUENAS_PROTOCOL="ws"
|
DEPLOY_TRUENAS_PROTOCOL="ws"
|
||||||
fi
|
fi
|
||||||
_ws_uri="$DEPLOY_TRUENAS_PROTOCOL://$DEPLOY_TRUENAS_HOSTNAME/websocket"
|
|
||||||
|
# Check port, optional
|
||||||
|
if [ -n "$DEPLOY_TRUENAS_PORT" ]; then
|
||||||
|
case "$DEPLOY_TRUENAS_PORT" in
|
||||||
|
'' | *[!0-9]*)
|
||||||
|
_err "Invalid TrueNAS port '$DEPLOY_TRUENAS_PORT'. DEPLOY_TRUENAS_PORT must be numeric."
|
||||||
|
return 8
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
_ws_uri="$DEPLOY_TRUENAS_PROTOCOL://$DEPLOY_TRUENAS_HOSTNAME:$DEPLOY_TRUENAS_PORT/websocket"
|
||||||
|
else
|
||||||
|
_ws_uri="$DEPLOY_TRUENAS_PROTOCOL://$DEPLOY_TRUENAS_HOSTNAME/websocket"
|
||||||
|
fi
|
||||||
|
|
||||||
_debug2 DEPLOY_TRUENAS_HOSTNAME "$DEPLOY_TRUENAS_HOSTNAME"
|
_debug2 DEPLOY_TRUENAS_HOSTNAME "$DEPLOY_TRUENAS_HOSTNAME"
|
||||||
_debug2 DEPLOY_TRUENAS_PROTOCOL "$DEPLOY_TRUENAS_PROTOCOL"
|
_debug2 DEPLOY_TRUENAS_PROTOCOL "$DEPLOY_TRUENAS_PROTOCOL"
|
||||||
_debug _ws_uri "$_ws_uri"
|
_debug _ws_uri "$_ws_uri"
|
||||||
@@ -216,13 +235,14 @@ truenas_ws_deploy() {
|
|||||||
|
|
||||||
if [ "$_ws_response" != "TRUE" ]; then
|
if [ "$_ws_response" != "TRUE" ]; then
|
||||||
_err "TrueNAS is not ready."
|
_err "TrueNAS is not ready."
|
||||||
_err "Please check environment variables DEPLOY_TRUENAS_APIKEY, DEPLOY_TRUENAS_HOSTNAME and DEPLOY_TRUENAS_PROTOCOL."
|
_err "Please check environment variables DEPLOY_TRUENAS_APIKEY, DEPLOY_TRUENAS_HOSTNAME, DEPLOY_TRUENAS_PROTOCOL and DEPLOY_TRUENAS_PORT."
|
||||||
_err "Verify API key."
|
_err "Verify API key."
|
||||||
return 2
|
return 2
|
||||||
fi
|
fi
|
||||||
_savedeployconf DEPLOY_TRUENAS_APIKEY "$DEPLOY_TRUENAS_APIKEY"
|
_savedeployconf DEPLOY_TRUENAS_APIKEY "$DEPLOY_TRUENAS_APIKEY"
|
||||||
_savedeployconf DEPLOY_TRUENAS_HOSTNAME "$DEPLOY_TRUENAS_HOSTNAME"
|
_savedeployconf DEPLOY_TRUENAS_HOSTNAME "$DEPLOY_TRUENAS_HOSTNAME"
|
||||||
_savedeployconf DEPLOY_TRUENAS_PROTOCOL "$DEPLOY_TRUENAS_PROTOCOL"
|
_savedeployconf DEPLOY_TRUENAS_PROTOCOL "$DEPLOY_TRUENAS_PROTOCOL"
|
||||||
|
_savedeployconf DEPLOY_TRUENAS_PORT "$DEPLOY_TRUENAS_PORT"
|
||||||
_info "TrueNAS health: OK"
|
_info "TrueNAS health: OK"
|
||||||
|
|
||||||
########## System info
|
########## System info
|
||||||
|
|||||||