Skip to content

Instantly share code, notes, and snippets.

@jeena
Created August 10, 2023 01:29
Show Gist options
  • Save jeena/af2636734c02d6bce826d96171b36f6a to your computer and use it in GitHub Desktop.
Save jeena/af2636734c02d6bce826d96171b36f6a to your computer and use it in GitHub Desktop.
#!/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