Last active
June 17, 2021 11:55
-
-
Save kristijorgji/d869f337f0692fc1616839911a6266b0 to your computer and use it in GitHub Desktop.
letencrypt-copy-live.sh
This file contains hidden or 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/env bash | |
# @kristijorgji | |
# This script copies all the live certbot/letsencrypt certificates to the dest you specify as first argument | |
# Example: | |
# bash letsencrypt-copy-live /home/ubuntu/certificates | |
DEST=$1 | |
cd /etc/letsencrypt/live; | |
pwd=$(pwd); | |
for dir in ./*/ # list directories in the form "/tmp/dirname/" | |
do | |
dir=${dir%*/} # remove the trailing "/" | |
#currentDomain=$(basename $pwd); | |
currentDomain=$(echo "${dir##*/}"); | |
mkdir -p $DEST/$currentDomain; | |
echo "Current domain $currentDomain" | |
for filename in ./$currentDomain/*; do | |
name=$(basename $filename); | |
realPath=$(readlink -f $filename); | |
fileDest="$DEST/$currentDomain/$name"; | |
echo "Will copy $name to $fileDest"; | |
cp $realPath $fileDest; | |
done | |
done | |
exit; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment