comparison host/renewSsl.sh @ 2076:385ab09fb2ca ssltesting

initial draft
author Violet7
date Tue, 09 Dec 2025 16:37:56 -0800
parents b934176dfcf1
children cdc9a31c6f71
comparison
equal deleted inserted replaced
2075:db677318ce63 2076:385ab09fb2ca
1 #!/bin/bash 1 #!/bin/bash
2 set -e 2 set -e
3 3
4 # for now - fschmidt 4 if [ -n "$1" ]; then
5 echo 'totally fucked up' 5 cd "$1" || echo "no first argument passed, staying in cwd"
6 exit 1 6 fi
7
8 cd "$1" || exit 1
9 7
10 ROOTPWD=$(pwd) 8 ROOTPWD=$(pwd)
9 # this awkward method is used for portability
10 ROOTPWDOWNER=$(ls -ld $ROOTPWD | awk '{printf "%s", $3}')
11
12 # change to owner of host/ if running as root
13 # prevents nginx being unable to read files owned by root
14 if [ "$(id -u)" -eq 0 ]; then
15 echo "switching to $ROOTPWDOWNER in order to preserve permissions"
16 exec sudo -u $ROOTPWDOWNER "$0" "$@"
17 fi
18
11 KEYFILE="$ROOTPWD/local/tiny_account.key" 19 KEYFILE="$ROOTPWD/local/tiny_account.key"
12 for SITEROOT in "$ROOTPWD"/sites/*; do 20 for SITEROOT in "$ROOTPWD"/sites/*; do
13 { 21 {
14 # Skip if not a directory 22 # Skip if not a directory
15 [ -d "$SITEROOT" ] || continue 23 [ -d "$SITEROOT" ] || continue
32 40
33 "$ROOTPWD/acme_tiny" \ 41 "$ROOTPWD/acme_tiny" \
34 --account-key "$KEYFILE" \ 42 --account-key "$KEYFILE" \
35 --csr "$CSRFILE" \ 43 --csr "$CSRFILE" \
36 --acme-dir "$CHALLENGEDIR" \ 44 --acme-dir "$CHALLENGEDIR" \
37 > "$TMPOUT" 45 >"$TMPOUT"
46
47 wc -c <$TMPOUT
48
49 # If TMPOUT is empty, something failed.
50 if [ ! -s "$TMPOUT" ]; then
51 echo "Error: $TMPOUT is empty - please see previous output for details.\nContinuing to next domain..."
52 rm -f "$TMPOUT"
53 continue
54 fi
38 55
39 # check if exists 56 # check if exists
40 if [ -f "$FULLCHAIN" ]; then 57 if [ -f "$FULLCHAIN" ]; then
41 mv $FULLCHAIN "$FULLCHAIN.old" 58 mv $FULLCHAIN "$FULLCHAIN.old"
42 fi 59 fi