Mercurial Hosting > luan
view host/renewSsl.sh @ 2052:caeaf6e76467 acme-tiny
minor
| author | Violet7 |
|---|---|
| date | Tue, 11 Nov 2025 19:07:25 -0800 |
| parents | 1f4c590bf0ae |
| children |
line wrap: on
line source
#!/bin/bash set -e cd "$1" || exit 1 ROOTPWD=$(pwd) KEYFILE="$ROOTPWD/local/tiny_account.key" for SITEROOT in "$ROOTPWD"/sites/*; do { # Skip if not a directory [ -d "$SITEROOT" ] || continue DOMAIN=$(basename "$SITEROOT") CSRFILE="$SITEROOT/$DOMAIN.csr" FULLCHAIN="$SITEROOT/fullchain.cer" CHALLENGEDIR="$SITEROOT/site/.well-known/acme-challenge" TMPOUT="/tmp/$DOMAIN.crt" echo "Processing domain: $DOMAIN" # local_https.sh does not create a csr file, assume # it is a self-signed local cert if it doesn't exist if [ ! -f "$CSRFILE" ]; then echo "CSR file not found, assuming self-signed and skipping." continue fi mkdir -p "$CHALLENGEDIR" ./$ROOTPWD/acme_tiny \ --account-key "$KEYFILE" \ --csr "$CSRFILE" \ --acme-dir "$CHALLENGEDIR" \ > "$TMPOUT" # check if exists if [ -f "$FULLCHAIN" ]; then mv $FULLCHAIN "$FULLCHAIN.old" fi mv "$TMPOUT" "$FULLCHAIN" echo "Renewed certificate for $DOMAIN" } || { echo "Error processing $SITEROOT — skipping." } done sudo /usr/local/bin/nginx -s reload -c "$(pwd)/local/nginx.conf" echo "Nginx reloaded."
