annotate host/renewSsl.sh @ 2038:b4b3017ac28d acme-tiny tip

cleanup setup dir
author Violet7
date Sat, 08 Nov 2025 04:53:29 -0800
parents a4435e2e3417
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1632
0344a535b1db add doc
fffilimonov
parents:
diff changeset
1 #!/bin/bash
0344a535b1db add doc
fffilimonov
parents:
diff changeset
2
2037
a4435e2e3417 Edit scripts to use acme-tiny
Violet7
parents: 1758
diff changeset
3 cd "$1" || exit 1
a4435e2e3417 Edit scripts to use acme-tiny
Violet7
parents: 1758
diff changeset
4 ROOTPWD=$(pwd)
1632
0344a535b1db add doc
fffilimonov
parents:
diff changeset
5
2037
a4435e2e3417 Edit scripts to use acme-tiny
Violet7
parents: 1758
diff changeset
6 for SITEROOT in "$ROOTPWD"/sites/*; do
a4435e2e3417 Edit scripts to use acme-tiny
Violet7
parents: 1758
diff changeset
7 # Skip if not a directory
a4435e2e3417 Edit scripts to use acme-tiny
Violet7
parents: 1758
diff changeset
8 [ -d "$SITEROOT" ] || continue
a4435e2e3417 Edit scripts to use acme-tiny
Violet7
parents: 1758
diff changeset
9
a4435e2e3417 Edit scripts to use acme-tiny
Violet7
parents: 1758
diff changeset
10 DOMAIN=$(basename "$SITEROOT")
a4435e2e3417 Edit scripts to use acme-tiny
Violet7
parents: 1758
diff changeset
11 echo "Processing domain: $DOMAIN"
a4435e2e3417 Edit scripts to use acme-tiny
Violet7
parents: 1758
diff changeset
12
a4435e2e3417 Edit scripts to use acme-tiny
Violet7
parents: 1758
diff changeset
13 mkdir -p "$SITEROOT/site/.well-known/acme-challenge"
1632
0344a535b1db add doc
fffilimonov
parents:
diff changeset
14
2037
a4435e2e3417 Edit scripts to use acme-tiny
Violet7
parents: 1758
diff changeset
15 python3 "$ROOTPWD/acme_tiny.py" \
a4435e2e3417 Edit scripts to use acme-tiny
Violet7
parents: 1758
diff changeset
16 --account-key "$ROOTPWD/local/tiny_account.key" \
a4435e2e3417 Edit scripts to use acme-tiny
Violet7
parents: 1758
diff changeset
17 --csr "$SITEROOT/$DOMAIN.csr" \
a4435e2e3417 Edit scripts to use acme-tiny
Violet7
parents: 1758
diff changeset
18 --acme-dir "$SITEROOT/site/.well-known/acme-challenge" \
a4435e2e3417 Edit scripts to use acme-tiny
Violet7
parents: 1758
diff changeset
19 > "/tmp/$DOMAIN.crt"
1632
0344a535b1db add doc
fffilimonov
parents:
diff changeset
20
2037
a4435e2e3417 Edit scripts to use acme-tiny
Violet7
parents: 1758
diff changeset
21 # check if exists
a4435e2e3417 Edit scripts to use acme-tiny
Violet7
parents: 1758
diff changeset
22 if [ -f "$SITEROOT/fullchain.cer" ]; then
a4435e2e3417 Edit scripts to use acme-tiny
Violet7
parents: 1758
diff changeset
23 mv "$SITEROOT/fullchain.cer" "$SITEROOT/fullchain.cer.old"
a4435e2e3417 Edit scripts to use acme-tiny
Violet7
parents: 1758
diff changeset
24 fi
a4435e2e3417 Edit scripts to use acme-tiny
Violet7
parents: 1758
diff changeset
25
a4435e2e3417 Edit scripts to use acme-tiny
Violet7
parents: 1758
diff changeset
26 mv "/tmp/$DOMAIN.crt" "$SITEROOT/fullchain.cer"
a4435e2e3417 Edit scripts to use acme-tiny
Violet7
parents: 1758
diff changeset
27
a4435e2e3417 Edit scripts to use acme-tiny
Violet7
parents: 1758
diff changeset
28 echo "Renewed certificate for $DOMAIN"
a4435e2e3417 Edit scripts to use acme-tiny
Violet7
parents: 1758
diff changeset
29 done
a4435e2e3417 Edit scripts to use acme-tiny
Violet7
parents: 1758
diff changeset
30
a4435e2e3417 Edit scripts to use acme-tiny
Violet7
parents: 1758
diff changeset
31 sudo /usr/local/bin/nginx -s reload
a4435e2e3417 Edit scripts to use acme-tiny
Violet7
parents: 1758
diff changeset
32 echo "Nginx reloaded."