Update nodemgmt-scripts.sh
This commit is contained in:
@@ -1684,7 +1684,7 @@ VCENTER-SSL(){
|
|||||||
VCCERTDAYS=$(${FOLDER}/ssl-cert-check/ssl-cert-check -p 443 -s ${VCHOSTNAME} -N)
|
VCCERTDAYS=$(${FOLDER}/ssl-cert-check/ssl-cert-check -p 443 -s ${VCHOSTNAME} -N)
|
||||||
VCCERTDAYS=${VCCERTDAYS#*=}
|
VCCERTDAYS=${VCCERTDAYS#*=}
|
||||||
|
|
||||||
if [ "${VCCERTDAYS}" -gt "29" ]; then
|
if [ "${VCCERTDAYS}" -lt "29" ]; then
|
||||||
echo -e "${idsCL[Green]}Certificate is still valid for ${VCCERTDAYS} days yet, no noeed to update${idsCL[Default]}"
|
echo -e "${idsCL[Green]}Certificate is still valid for ${VCCERTDAYS} days yet, no noeed to update${idsCL[Default]}"
|
||||||
exit 0
|
exit 0
|
||||||
else
|
else
|
||||||
@@ -1694,26 +1694,26 @@ VCENTER-SSL(){
|
|||||||
|
|
||||||
echo -en "${idsCL[LightCyan]}Updating certificate on vCenter... ${idsCL[Default]}"
|
echo -en "${idsCL[LightCyan]}Updating certificate on vCenter... ${idsCL[Default]}"
|
||||||
|
|
||||||
SESSION_ID=$(curl -s -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'vmware-use-header-authn: test' --header 'vmware-api-session-id: null' -u $CRED "$SERVER/rest/com/vmware/cis/session" --insecure | python3 -c "import sys, json; print(json.load(sys.stdin)['value'])")
|
# SESSION_ID=$(curl -s -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'vmware-use-header-authn: test' --header 'vmware-api-session-id: null' -u $CRED "$SERVER/rest/com/vmware/cis/session" --insecure | python3 -c "import sys, json; print(json.load(sys.stdin)['value'])")
|
||||||
|
#
|
||||||
PRIVKEY=$(awk -v ORS='\\n' '1' "$CERTDIR/privkey.pem")
|
# PRIVKEY=$(awk -v ORS='\\n' '1' "$CERTDIR/privkey.pem")
|
||||||
CERT=$(awk -v ORS='\\n' '1' "$CERTDIR/cert.pem")
|
# CERT=$(awk -v ORS='\\n' '1' "$CERTDIR/cert.pem")
|
||||||
|
#
|
||||||
REQUEST_BODY="{ \"spec\" : { \"cert\" : \"$CERT\", \"key\" : \"$PRIVKEY\" } }"
|
# REQUEST_BODY="{ \"spec\" : { \"cert\" : \"$CERT\", \"key\" : \"$PRIVKEY\" } }"
|
||||||
|
#
|
||||||
curl --insecure -X PUT "$SERVER/rest/vcenter/certificate-management/vcenter/tls" \
|
# curl --insecure -X PUT "$SERVER/rest/vcenter/certificate-management/vcenter/tls" \
|
||||||
-H "vmware-api-session-id: $SESSION_ID" \
|
# -H "vmware-api-session-id: $SESSION_ID" \
|
||||||
-H "Content-type: application/json" \
|
# -H "Content-type: application/json" \
|
||||||
-d "$REQUEST_BODY"
|
# -d "$REQUEST_BODY"
|
||||||
|
#
|
||||||
curl --insecure -X DELETE "$SERVER/rest/com/vmware/cis/session" -H "vmware-api-session-id: $SESSION_ID"
|
# curl --insecure -X DELETE "$SERVER/rest/com/vmware/cis/session" -H "vmware-api-session-id: $SESSION_ID"
|
||||||
echo -e "${idsCL[Green]}Done${idsCL[Default]}"
|
echo -e "${idsCL[Green]}Done${idsCL[Default]}"
|
||||||
echo
|
echo
|
||||||
echo -en "${idsCL[LightCyan]}Stopping vCenter services... ${idsCL[Default]}"
|
echo -en "${idsCL[LightCyan]}Stopping vCenter services... ${idsCL[Default]}"
|
||||||
ssh -i ~/.ssh/id_rsa root@vcenter.scity.us 'service-control --stop --all >/dev/null 2>&1'
|
#ssh -i ~/.ssh/id_rsa root@vcenter.scity.us 'service-control --stop --all' >/dev/null 2>&1
|
||||||
echo -e "${idsCL[Green]}Done${idsCL[Default]}"
|
echo -e "${idsCL[Green]}Done${idsCL[Default]}"
|
||||||
echo -en "${idsCL[LightCyan]}Starting vCenter services... ${idsCL[Default]}"
|
echo -en "${idsCL[LightCyan]}Starting vCenter services... ${idsCL[Default]}"
|
||||||
ssh -i ~/.ssh/id_rsa root@vcenter.scity.us 'service-control --start --all >/dev/null 2>&1'
|
ssh -i ~/.ssh/id_rsa root@vcenter.scity.us 'service-control --start --all' >/dev/null 2>&1
|
||||||
echo -e "${idsCL[Green]}Done${idsCL[Default]}"
|
echo -e "${idsCL[Green]}Done${idsCL[Default]}"
|
||||||
echo
|
echo
|
||||||
echo -e "${idsCL[Green]}The vCenter certifcate has been updated${idsCL[Default]}"
|
echo -e "${idsCL[Green]}The vCenter certifcate has been updated${idsCL[Default]}"
|
||||||
|
|||||||
Reference in New Issue
Block a user