Created
June 1, 2020 21:33
-
-
Save Mhs-220/2340b477dacbcf0365b6a4f14bc0b6f2 to your computer and use it in GitHub Desktop.
Auto Renew SSL for Cpanel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo $CERTBOT_TOKEN | |
echo $CERTBOT_VALIDATION > $CERTBOT_TOKEN | |
ftp -n $FTP_ADDR << END_SCRIPT | |
quote USER $FTP_USER | |
quote PASS $FTP_PASS | |
binary | |
put "$CERTBOT_TOKEN" | |
quit | |
END_SCRIPT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
rm -f ./$CERTBOT_TOKEN | |
ftp -n $FTP_ADDR << END_SCRIPT | |
quote USER $FTP_USER | |
quote PASS $FTP_PASS | |
binary | |
delete $CERTBOT_TOKEN | |
quit | |
END_SCRIPT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
echo "Create Temp Environement..." | |
FOLDER_PATH=/tmp/$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1) | |
mkdir $FOLDER_PATH | |
mkdir $FOLDER_PATH/log | |
mkdir $FOLDER_PATH/config | |
echo "Successfully created in $FOLDER_PATH" | |
echo "Request for certificate..." | |
certbot -n --agree-tos --manual-public-ip-logging-ok \ | |
--manual-auth-hook certbot-authenticate.sh \ | |
--manual-cleanup-hook certbot-cleanup.sh \ | |
-m $EMAIL \ | |
-d $DOMAIN | |
--manual --preferred-challenges http \ | |
--config-dir $FOLDER_PATH/config \ | |
--work-dir $FOLDER_PATH \ | |
--logs-dir $FOLDER_PATH/log \ | |
certonly | |
CERT=$(cat $FOLDER_PATH/config/live/$DOMAIN/cert.pem) | |
KEY=$(cat $FOLDER_PATH/config/live/$DOMAIN/privkey.pem) | |
BUNDLE=$(cat $FOLDER_PATH/config/live/$DOMAIN/chain.pem) | |
echo "Setting on Cpanel..." | |
curl \ | |
--user "$CPANEL_USERNAME:$CPANEL_PASSWORD" \ | |
--data-urlencode "cert=$CERT" \ | |
--data-urlencode "key=$KEY" \ | |
--data-urlencode "cabundle=$BUNDLE" \ | |
"$CPANEL_URL/execute/SSL/install_ssl?domain=$DOMAIN" | |
echo "Done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment