|
|
|
@ -9,7 +9,7 @@
|
|
|
|
|
#
|
|
|
|
|
# Following environment variables must be set:
|
|
|
|
|
#
|
|
|
|
|
# export DEPLOY_TRUENAS_APIKEY="<API_KEY_GENERATED_IN_THE_WEB_UI"
|
|
|
|
|
# export DEPLOY_TRUENAS_APIKEY="<API_KEY_GENERATED_IN_THE_WEB_UI>"
|
|
|
|
|
#
|
|
|
|
|
# The following environmental variables may be set if you don't like their
|
|
|
|
|
# default values:
|
|
|
|
@ -64,6 +64,11 @@ truenas_deploy() {
|
|
|
|
|
_response=$(_get "$_api_url/system/state")
|
|
|
|
|
_info "TrueNAS system state: $_response."
|
|
|
|
|
|
|
|
|
|
_info "Getting TrueNAS version"
|
|
|
|
|
_response=$(_get "$_api_url/system/version")
|
|
|
|
|
_info "TrueNAS system version: $_response"
|
|
|
|
|
_truenas_version=$(echo "$_response" | cut -d '-' -f 3)
|
|
|
|
|
|
|
|
|
|
if [ -z "$_response" ]; then
|
|
|
|
|
_err "Unable to authenticate to $_api_url."
|
|
|
|
|
_err 'Check your connection settings are correct, e.g.'
|
|
|
|
@ -115,6 +120,10 @@ truenas_deploy() {
|
|
|
|
|
|
|
|
|
|
_debug3 _activate_result "$_activate_result"
|
|
|
|
|
|
|
|
|
|
_truenas_version_23_10="23.10.0.0"
|
|
|
|
|
_truenas_version_24_10="24.10.0.0"
|
|
|
|
|
|
|
|
|
|
if [ "$(echo -e "$_truenas_version_23_10\n$_truenas_version" | sort -V | head -n 1)" != "$_truenas_version_23_10" ]; then
|
|
|
|
|
_info "Checking if WebDAV certificate is the same as the TrueNAS web UI"
|
|
|
|
|
_webdav_list=$(_get "$_api_url/webdav")
|
|
|
|
|
_webdav_cert_id=$(echo "$_webdav_list" | grep '"certssl":' | tr -d -- '"certsl: ,')
|
|
|
|
@ -138,29 +147,6 @@ truenas_deploy() {
|
|
|
|
|
_info "WebDAV certificate is not configured or is not the same as TrueNAS web UI"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
_info "Checking if FTP certificate is the same as the TrueNAS web UI"
|
|
|
|
|
_ftp_list=$(_get "$_api_url/ftp")
|
|
|
|
|
_ftp_cert_id=$(echo "$_ftp_list" | grep '"ssltls_certificate":' | tr -d -- '"certislfa:_ ,')
|
|
|
|
|
|
|
|
|
|
if [ "$_ftp_cert_id" = "$_active_cert_id" ]; then
|
|
|
|
|
_info "Updating the FTP certificate"
|
|
|
|
|
_debug _ftp_cert_id "$_ftp_cert_id"
|
|
|
|
|
_ftp_data="{\"ssltls_certificate\": \"${_cert_id}\"}"
|
|
|
|
|
_activate_ftp_cert="$(_post "$_ftp_data" "$_api_url/ftp" "" "PUT" "application/json")"
|
|
|
|
|
_ftp_new_cert_id=$(echo "$_activate_ftp_cert" | _json_decode | grep '"ssltls_certificate":' | sed -n 's/.*: \([0-9]\{1,\}\),\{0,1\}$/\1/p')
|
|
|
|
|
if [ "$_ftp_new_cert_id" -eq "$_cert_id" ]; then
|
|
|
|
|
_info "FTP certificate updated successfully"
|
|
|
|
|
else
|
|
|
|
|
_err "Unable to set FTP certificate"
|
|
|
|
|
_debug3 _activate_ftp_cert "$_activate_ftp_cert"
|
|
|
|
|
_debug3 _ftp_new_cert_id "$_ftp_new_cert_id"
|
|
|
|
|
return 1
|
|
|
|
|
fi
|
|
|
|
|
_debug3 _activate_ftp_cert "$_activate_ftp_cert"
|
|
|
|
|
else
|
|
|
|
|
_info "FTP certificate is not configured or is not the same as TrueNAS web UI"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
_info "Checking if S3 certificate is the same as the TrueNAS web UI"
|
|
|
|
|
_s3_list=$(_get "$_api_url/s3")
|
|
|
|
|
_s3_cert_id=$(echo "$_s3_list" | grep '"certificate":' | tr -d -- '"certifa:_ ,')
|
|
|
|
@ -183,7 +169,9 @@ truenas_deploy() {
|
|
|
|
|
else
|
|
|
|
|
_info "S3 certificate is not configured or is not the same as TrueNAS web UI"
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ "$(echo -e "$_truenas_version_24_10\n$_truenas_version" | sort -V | head -n 1)" != "$_truenas_version_24_10" ]; then
|
|
|
|
|
_info "Checking if any chart release Apps is using the same certificate as TrueNAS web UI. Tool 'jq' is required"
|
|
|
|
|
if _exists jq; then
|
|
|
|
|
_info "Query all chart release"
|
|
|
|
@ -204,6 +192,30 @@ truenas_deploy() {
|
|
|
|
|
else
|
|
|
|
|
_info "Tool 'jq' does not exists, skip chart release checking"
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
_info "Checking if FTP certificate is the same as the TrueNAS web UI"
|
|
|
|
|
_ftp_list=$(_get "$_api_url/ftp")
|
|
|
|
|
_ftp_cert_id=$(echo "$_ftp_list" | grep '"ssltls_certificate":' | tr -d -- '"certislfa:_ ,')
|
|
|
|
|
|
|
|
|
|
if [ "$_ftp_cert_id" = "$_active_cert_id" ]; then
|
|
|
|
|
_info "Updating the FTP certificate"
|
|
|
|
|
_debug _ftp_cert_id "$_ftp_cert_id"
|
|
|
|
|
_ftp_data="{\"ssltls_certificate\": \"${_cert_id}\"}"
|
|
|
|
|
_activate_ftp_cert="$(_post "$_ftp_data" "$_api_url/ftp" "" "PUT" "application/json")"
|
|
|
|
|
_ftp_new_cert_id=$(echo "$_activate_ftp_cert" | _json_decode | grep '"ssltls_certificate":' | sed -n 's/.*: \([0-9]\{1,\}\),\{0,1\}$/\1/p')
|
|
|
|
|
if [ "$_ftp_new_cert_id" -eq "$_cert_id" ]; then
|
|
|
|
|
_info "FTP certificate updated successfully"
|
|
|
|
|
else
|
|
|
|
|
_err "Unable to set FTP certificate"
|
|
|
|
|
_debug3 _activate_ftp_cert "$_activate_ftp_cert"
|
|
|
|
|
_debug3 _ftp_new_cert_id "$_ftp_new_cert_id"
|
|
|
|
|
return 1
|
|
|
|
|
fi
|
|
|
|
|
_debug3 _activate_ftp_cert "$_activate_ftp_cert"
|
|
|
|
|
else
|
|
|
|
|
_info "FTP certificate is not configured or is not the same as TrueNAS web UI"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
_info "Deleting old certificate"
|
|
|
|
|
_delete_result="$(_post "" "$_api_url/certificate/id/$_active_cert_id" "" "DELETE" "application/json")"
|
|
|
|
|