Created
April 13, 2020 22:10
-
-
Save darylounet/b73584de44209ccb1ce1b3c56c486a7a to your computer and use it in GitHub Desktop.
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 | |
# @Author Cyril Aknine <[email protected]> | |
# Sophos XG Let's Encrypt certificate update script | |
# It uses huge workaround due to Sophos XG limitations : | |
# - can't update a certificate when it's used by WAF | |
# - can't update FirewallRule trough API to use another certificate | |
# - can't SCP a file trough SSH | |
# So ok it's ugly, but it's not the only one... | |
SOPHOS_IP="192.168.0.254" | |
SOPHOS_CERT_NAME="MyCertificate" | |
DOMAIN_NAME="example.com" | |
CERT_PEM=$(</etc/letsencrypt/live/$DOMAIN_NAME/fullchain.pem) | |
CERT_KEY=$(</etc/letsencrypt/live/$DOMAIN_NAME/privkey.pem) | |
( | |
sleep 2 | |
echo "5" | |
sleep 2 | |
echo "3" | |
echo "printf \"%s\" \"$CERT_PEM\" > \"/conf/certificate/$SOPHOS_CERT_NAME.pem\"" | |
echo "printf \"%s\" \"$CERT_KEY\" > \"/conf/certificate/private/$SOPHOS_CERT_NAME.key\"" | |
echo "service WAF:restart -ds nosync" | |
echo "service apache:restart -ds nosync" | |
echo "exit" | |
sleep 2 | |
echo "0" | |
sleep 2 | |
echo "0" | |
) | ssh -tt admin@$SOPHOS_IP |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment