mirror of
https://github.com/acmesh-official/acme.sh.git
synced 2025-05-07 18:54:12 +00:00
feat: Add deploy script for HP iLO (using Redfish REST API)
This commit is contained in:
parent
e88442cb46
commit
6b0b520ec2
78
deploy/hpilo.sh
Normal file
78
deploy/hpilo.sh
Normal file
@ -0,0 +1,78 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Deploy script for HPE iLO4
|
||||
#
|
||||
# The following environment variables are
|
||||
# needed for the deploy script to work:
|
||||
#
|
||||
# ```sh
|
||||
# export HPILO_USERNAME=admin
|
||||
# export HPILO_PASSWORD=secret
|
||||
# export HPILO_HOST=ilo.example.com
|
||||
#
|
||||
# acme.sh --deploy -d ilo.example.com --deploy-hook hpilo
|
||||
# ```
|
||||
|
||||
######## Public functions #####################
|
||||
|
||||
#domain keyfile certfile cafile fullchain
|
||||
hpilo_deploy() {
|
||||
_cdomain="$1"
|
||||
_ckey="$2"
|
||||
_ccert="$3"
|
||||
_cca="$4"
|
||||
_cfullchain="$5"
|
||||
|
||||
if [ -f "$DOMAIN_CONF" ]; then
|
||||
# shellcheck disable=SC1090
|
||||
. "$DOMAIN_CONF"
|
||||
fi
|
||||
|
||||
_debug _cdomain "$_cdomain"
|
||||
_debug _ckey "$_ckey"
|
||||
_debug _ccert "$_ccert"
|
||||
_debug _cca "$_cca"
|
||||
_debug _cfullchain "$_cfullchain"
|
||||
|
||||
# iLO host is optional, use _cdomain if not provided
|
||||
if [ -n "$HPILO_HOST" ]; then
|
||||
Le_Deploy_ilo_host="$HPILO_HOST"
|
||||
_savedomainconf Le_Deploy_ilo_host "$Le_Deploy_ilo_host"
|
||||
elif [ -z "$Le_Deploy_ilo_host" ]; then
|
||||
_debug "Using _cdomain as iLO host, set HPILO_HOST if not correct."
|
||||
Le_Deploy_ilo_host="$_cdomain"
|
||||
fi
|
||||
|
||||
# iLO username is required
|
||||
if [ -z "$HPILO_USERNAME" ]; then
|
||||
if [ -z "$Le_Deploy_ilo_username" ]; then
|
||||
_err "HPILO_USERNAME is not defined."
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
Le_Deploy_ilo_username="$HPILO_USERNAME"
|
||||
_savedomainconf Le_Deploy_ilo_username "$Le_Deploy_ilo_username"
|
||||
fi
|
||||
|
||||
# iLO password is required
|
||||
if [ -z "$HPILO_PASSWORD" ]; then
|
||||
if [ -z "$Le_Deploy_ilo_password" ]; then
|
||||
_err "HPILO_PASSWORD is not defined."
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
Le_Deploy_ilo_password="$HPILO_PASSWORD"
|
||||
_savedomainconf Le_Deploy_ilo_password "$Le_Deploy_ilo_password"
|
||||
fi
|
||||
|
||||
_info "Attempting to deploy certificate '$_ccert' to '$Le_Deploy_ilo_host'"
|
||||
|
||||
curl -sS -k -X POST -H "Content-Type: application/json" -d "{ \"Action\": \"ImportCertificate\", \"Certificate\": \"$(cat "$_ccert")\" }" -u "${Le_Deploy_ilo_username}":"${Le_Deploy_ilo_password}" "https://${Le_Deploy_ilo_host}/redfish/v1/Managers/1/SecurityService/HttpsCert/"
|
||||
_ret="$?"
|
||||
|
||||
if [ "$_ret" != "0" ]; then
|
||||
_err "Error code $_ret returned from iLO Redfish API"
|
||||
fi
|
||||
|
||||
return $_ret
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user