Created
May 23, 2023 05:51
-
-
Save void285/0c7b65f6e98cd5f156b4c2f9a155e62f to your computer and use it in GitHub Desktop.
After migrating letsencrypt to a new server, you may encounter with errors like "SSLCertificateFile: file '/etc/letsencrypt/live/example.com/fullchain.pem' does not exist or is empty", this script fix it.
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 | |
domains=`ls /etc/letsencrypt/archive/` | |
for domain in $domains; do | |
max=`ls -v /etc/letsencrypt/archive/${domain} | grep cert | tail -n 1 | grep -oP "\d+"` | |
echo "create symlink for ${domain} version ${max}" | |
cd /etc/letsencrypt/live/${domain} | |
rm cert.pem privkey.pem chain.pem fullchain.pem | |
ln -s ../../archive/${domain}/cert${max}.pem cert.pem | |
ln -s ../../archive/${domain}/privkey${max}.pem privkey.pem | |
ln -s ../../archive/${domain}/chain${max}.pem chain.pem | |
ln -s ../../archive/${domain}/fullchain${max}.pem fullchain.pem | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment