From 907540501013e71cd4d1f6f0039301b0f713c63d Mon Sep 17 00:00:00 2001 From: windgmbh <49904312+windgmbh@users.noreply.github.com> Date: Thu, 6 May 2021 17:21:40 +0200 Subject: [PATCH] XCP-ng deploy hook: Remove hyphen --- deploy/{xcp-ng.sh => xcp_ng.sh} | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) rename deploy/{xcp-ng.sh => xcp_ng.sh} (77%) diff --git a/deploy/xcp-ng.sh b/deploy/xcp_ng.sh similarity index 77% rename from deploy/xcp-ng.sh rename to deploy/xcp_ng.sh index c322dcae..deb87b7b 100755 --- a/deploy/xcp-ng.sh +++ b/deploy/xcp_ng.sh @@ -5,8 +5,8 @@ XAPI_SSL_PATH="/etc/xensource/xapi-ssl.pem" XCP_NG_BACKUP_DIR="/tmp/$(uuidgen)" -# xcp-ng_deploy deploys the new certificate to XCP-ng. -xcp-ng_deploy() { +# xcp_ng_deploy deploys the new certificate to XCP-ng. +xcp_ng_deploy() { _cdomain="$1" _ckey="$2" _ccert="$3" @@ -19,25 +19,25 @@ xcp-ng_deploy() { _debug _cca "$_cca" _debug _cfullchain "$_cfullchain" - if [[ $(_xcp-ng_backup_certificate) -ne 0 ]]; then + if [[ $(_xcp_ng_backup_certificate) -ne 0 ]]; then return 1 fi _debug "Deploying certificate with 'xe host-server-certificate-install'" if [[ $(sudo xe host-server-certificate-install certificate="${_ccert}" private-key="${_ckey}" certificate-chain="${_cca}") -ne 0 ]]; then - if [[ $(_xcp-ng_backup_restore) -eq 0 ]]; then - xcp-ng_backup_delete 2>&1 + if [[ $(_xcp_ng_backup_restore) -eq 0 ]]; then + xcp_ng_backup_delete 2>&1 fi return 1 fi _info "Certificate was deployed successfully." - _xcp-ng_backup_delete 2>&1 + _xcp_ng_backup_delete 2>&1 return 0 } -# _xcp-ng_backup_certificate saves the current certificate to a temporary folder. +# _xcp_ng_backup_certificate saves the current certificate to a temporary folder. # The folder can be read/ written by the current user only (chmod 600). -_xcp-ng_backup_certificate() { +_xcp_ng_backup_certificate() { if [[ $(whoami) != "root" ]]; then _debug "Running as non-root user. Certificate backup not supported." exit 0 @@ -55,20 +55,20 @@ _xcp-ng_backup_certificate() { return 0 } -# _xcp-ng_backup_restore restores the backup made by _xcp-ng_backup_certificate. +# _xcp_ng_backup_restore restores the backup made by _xcp_ng_backup_certificate. # It is called when something went wrong deploying the certificate. -_xcp-ng_backup_restore() { +_xcp_ng_backup_restore() { if [[ $(mv "${XCP_NG_BACKUP_DIR}/xapi-ssl.pem" "${XAPI_SSL_PATH}") -eq 0 ]]; then _info "Certificate restoration successful." return 0 else - _err "Certificate restoration from '${XCP-NG_BACKUP_DIR}' not possible." + _err "Certificate restoration from '${XCP_NG_BACKUP_DIR}' not possible." return 1 fi } -# _xcp-ng_backup_delete deletes the backup folder. -_xcp-ng_backup_delete() { +# _xcp_ng_backup_delete deletes the backup folder. +_xcp_ng_backup_delete() { if [[ $(rm -rf "${XCP_NG_BACKUP_DIR}") -eq 0 ]]; then _debug "Certificate backup deleted." else @@ -76,12 +76,12 @@ _xcp-ng_backup_delete() { fi } -# _xcp-ng_xapi_restart restarts the XAPI service the certificate was deployed to. +# _xcp_ng_xapi_restart restarts the XAPI service the certificate was deployed to. # This is only neeeded when the old certificate had to be restored. -_xcp-ng_xapi_restart() { +_xcp_ng_xapi_restart() { if [[ $(systemctl restart xapi) -ne 0 ]]; then _err "XAPI did not restart properly after deployment. Restoring old certificate for now." - if [[ $(_xcp-ng_backup_restore) -ne 0 ]]; then + if [[ $(_xcp_ng_backup_restore) -ne 0 ]]; then _err "Could not restore the old certificate!!!" fi if [[ $(systemctl restart xapi) -ne 0 ]]; then