Created
August 10, 2023 01:29
-
-
Save jeena/af2636734c02d6bce826d96171b36f6a 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
#!/usr/bin/bash | |
SERVER="example.com" | |
USER="jdoe" | |
DOMAIN="$1" | |
LIVE="/etc/letsencrypt/live/$DOMAIN" | |
ARCHIVE="/etc/letsencrypt/archive/$DOMAIN" | |
CONF="/etc/letsencrypt/renewal/$DOMAIN.conf" | |
CERTS="$DOMAIN-certs.tar.gz" | |
echo "Exporting $DOMAIN" | |
if [ -d "$LIVE" ]; then | |
if [ -d "$ARCHIVE" ]; then | |
if [ -f "$CONF" ]; then | |
tar -czvf "$CERTS" "$LIVE" "$ARCHIVE" "$CONF" | |
echo "Copy: scp $CERTS $USER@$SERVER:" | |
echo "Now execute on $SERVER:" | |
echo "cd / && sudo tar -xvf ~/$DOMAIN-certs.tar.gz && sudo nginx -s reload" | |
else | |
echo "No such file $CONF" | |
fi | |
else | |
echo "No such domain in /etc/letsencrypt/archive $DOMAIN" | |
fi | |
else | |
echo "No such domain in /etc/letsencrypt/live $DOMAIN" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment