Skip to content

Instantly share code, notes, and snippets.

@NotYusta
Last active February 17, 2024 05:58
Show Gist options
  • Save NotYusta/4b3a0db8f3606c2c668539b8a469b032 to your computer and use it in GitHub Desktop.
Save NotYusta/4b3a0db8f3606c2c668539b8a469b032 to your computer and use it in GitHub Desktop.
Install certificate and replace all certificate subdomains with domain's one.
#!/bin/sh
DOMAIN_NAME=""
CERTIFICATE_PATH="/etc/letsencrypt/live"
# MAKE SURE USE \ TO PREVENT TRAILING SPACES.
PRIVATE_KEY=""
PUBLIC_CERT=""
rm -rfv "$CERTIFICATE_PATH/$DOMAIN_NAME"
mkdir -pv "$CERTIFICATE_PATH/$DOMAIN_NAME"
echo "$PUBLIC_CERT" | sudo tee -a "$CERTIFICATE_PATH/$DOMAIN_NAME/fullchain.pem"
echo "$PRIVATE_KEY" | sudo tee -a "$CERTIFICATE_PATH/$DOMAIN_NAME/privkey.pem"
# SBD = Subdomain
for SBDFOLDER in $CERTIFICATE_PATH/*$DOMAIN_NAME; do
if [ ! -d $dir ]; then
echo "skipped $SBDFOLDER"
continue
fi
echo "installing $SBDFOLDER"
cp -rv "$CERTIFICATE_PATH/$DOMAIN_NAME/." "$SBDFOLDER"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment