Skip to content

Instantly share code, notes, and snippets.

@Nepherte
Last active January 13, 2022 05:00
Show Gist options
  • Save Nepherte/131c8c5f796aac238688c992afc4a127 to your computer and use it in GitHub Desktop.
Save Nepherte/131c8c5f796aac238688c992afc4a127 to your computer and use it in GitHub Desktop.
Let's Encrypt hook to deploy an SSL certificate onto a Synology NAS for nginx.
#!/usr/bin/env bash
set -e
function deploy_to_synology {
# The id of the certificate on the Synology NAS.
local CERT_ID="crFPXQ"
# The packages on the Synology NAS that use the certificate.
local CERT_PKGS="system 4b4b117d-07d1-49db-9b42-7e1281cf3326"
# The key to use to login to the Synology NAS.
local SSH_KEY="/root/.ssh/osiris"
# The user and hostname of the Synology NAS.
local HOST="[email protected]"
# Create import directory on Synoloy NAS.
ssh -i $SSH_KEY $HOST mkdir -p /tmp/certificate/$CERT_ID
# Upload the certificate to the Synology NAS.
scp -i $SSH_KEY $RENEWED_LINEAGE/*.pem $HOST:/tmp/certificate/$CERT_ID
# Import the certificate into the Synology NAS.
ssh -i $SSH_KEY $HOST sudo /usr/local/bin/synology-import-ssl.sh $CERT_ID $CERT_PKGS
}
for domain in $RENEWED_DOMAINS; do
case $domain in
osiris.nepherte.com)
deploy_to_synology
;;
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment