From 53dba6bfafcdede53971a6398a4bf13dd8252330 Mon Sep 17 00:00:00 2001 From: eddul-h <31884309+eddul-h@users.noreply.github.com> Date: Fri, 15 Oct 2021 10:08:17 +0200 Subject: [PATCH] Update openmediavault.sh Improve log/debug, fix shellcheck SC2034 --- deploy/openmediavault.sh | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/deploy/openmediavault.sh b/deploy/openmediavault.sh index f7cb4fd2..220f59ce 100644 --- a/deploy/openmediavault.sh +++ b/deploy/openmediavault.sh @@ -23,36 +23,35 @@ openmediavault_deploy() { # shellcheck disable=SC2086 _uuid=$(omv-rpc -u "$DEPLOY_OMV_USER" 'CertificateMgmt' 'getList' '{"start": 0, "limit": -1}' | jq -r '.data[] | select(.name=="/CN='$_cdomain'") | .uuid') if [ -z "$_uuid" ]; then - echo "Domain $_cdomain has no certificate in Openmediavault, creating it!" + _info "[OMV deploy-hook] Domain $_cdomain has no certificate in Openmediavault, creating it!" _uuid=$(omv-rpc -u "$DEPLOY_OMV_USER" 'CertificateMgmt' 'create' '{"cn": "test.example.com", "size": 4096, "days": 3650, "c": "", "st": "", "l": "", "o": "", "ou": "", "email": ""}' | jq -r '.uuid') if [ -z "$_uuid" ]; then - echo "An error occured while creating the certificate" + _err "[OMB deploy-hook] An error occured while creating the certificate" return 1 fi fi - echo "Domain $_cdomain has uuid: $_uuid" + _info "[OMV deploy-hook] Domain $_cdomain has uuid: $_uuid" _fullchain=$(jq <"$_cfullchain" -aRs .) _key=$(jq <"$_ckey" -aRs .) - #echo "$_fullchain" - #echo "$_key" + _debug _fullchain "$_fullchain" + _debug _key "$_key" - echo "Updating key and certificate in Openmediavault" + _info "[OMV deploy-hook] Updating key and certificate in Openmediavault" _command="omv-rpc -u $DEPLOY_OMV_USER 'CertificateMgmt' 'set' '{\"uuid\":\"$_uuid\", \"certificate\":$_fullchain, \"privatekey\":$_key, \"comment\":\"acme.sh deployed $(date)\"}'" _result=$(eval "$_command") - #echo "$_command" - #echo "$_result" + _debug _command "$_command" + _debug _result "$_result" - echo "Asking Openmediavault to apply changes... (this could take some time, hang in there)" + _info "[OMV deploy-hook] Asking Openmediavault to apply changes... (this could take some time, hang in there)" _command="omv-rpc -u $DEPLOY_OMV_USER 'Config' 'applyChanges' '{\"modules\":[\"certificates\"], \"force\": false}'" _result=$(eval "$_command") - #echo "$_command" - #echo "$_result" + _debug _command "$_command" + _debug _result "$_result" return 0 - }