Code standard fixes

This commit is contained in:
eddul-h 2021-10-14 10:10:45 +02:00 committed by GitHub
parent 94d9fdf9c5
commit 437f052fe2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,34 +16,31 @@ openmediavault_deploy() {
_debug _cca "$_cca"
_debug _cfullchain "$_cfullchain"
if [ -z "$DEPLOY_OMV_USER" ]
then
if [ -z "$DEPLOY_OMV_USER" ]; then
DEPLOY_OMV_USER="admin"
fi
# 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
if [ -z "$_uuid" ]; then
echo "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
if [ -z "$_uuid" ]; then
echo "An error occured while creating the certificate"
return 1
fi
fi
echo "Domain $_cdomain has uuid: $_uuid"
_fullchain=$(cat "$_cfullchain" | jq -aRs .)
_key=$(cat "$_ckey" | jq -aRs .)
_date=$(echo "$(date)")
_fullchain=$(jq <"$_cfullchain" -aRs .)
_key=$(jq <"$_ckey" -aRs .)
#echo "$_fullchain"
#echo "$_key"
echo "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\"}'"
_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"