|
31 | 31 |
|
32 | 32 | for var in $(env | grep -P 'DOMAIN_\d+' | sed -e 's/=.*//'); do |
33 | 33 | cur_domains=${!var}; |
34 | | - |
35 | 34 | declare -a arr=$cur_domains; |
36 | 35 |
|
37 | 36 | DOMAINDIRECTORY="/etc/letsencrypt/live/${arr[0]}"; |
38 | 37 | dom=""; |
39 | 38 | for i in "${arr[@]}" |
40 | 39 | do |
41 | | - let exitcode=tries=0 |
| 40 | + let validated=tries=0 |
42 | 41 | until [ $tries -ge $MAXRETRIES ] |
43 | 42 | do |
44 | 43 | tries=$[$tries+1] |
45 | | - certbot-auto certonly --dry-run "${args[@]}" -d "$i" | grep -q 'The dry run was successful.' && break |
46 | | - exitcode=$? |
47 | | - |
48 | | - if [ $tries -eq $MAXRETRIES ]; then |
49 | | - printf "${RED}Unable to verify domain ownership after ${tries} attempts.${NC}\n" |
| 44 | + certbot certonly --dry-run "${args[@]}" -d "$i" | grep -q 'The dry run was successful.' |
| 45 | + if [ $? -eq 0 ]; then |
| 46 | + validated=1 |
| 47 | + break |
50 | 48 | else |
51 | | - printf "${RED}Unable to verify domain ownership, we try again in ${TIMEOUT} seconds.${NC}\n" |
52 | | - sleep $TIMEOUT |
| 49 | + if [ $tries -eq $MAXRETRIES ]; then |
| 50 | + printf "${RED}Unable to verify domain ownership after ${tries} attempts.${NC}\n" |
| 51 | + else |
| 52 | + printf "${RED}Unable to verify domain ownership, we try again in ${TIMEOUT} seconds.${NC}\n" |
| 53 | + sleep $TIMEOUT |
| 54 | + fi |
53 | 55 | fi |
54 | | - done |
55 | 56 |
|
56 | | - if [ $exitcode -eq 0 ]; then |
| 57 | + done |
| 58 | + echo "Validated is $validated" |
| 59 | + if [ $validated -eq 1 ]; then |
57 | 60 | printf "Domain $i successfully validated\n" |
58 | 61 | dom="$dom -d $i" |
59 | 62 | fi |
60 | 63 | done |
61 | | - |
| 64 | + |
62 | 65 | #only if we have successfully validated at least a single domain we have to continue |
63 | 66 | if [ -n "$dom" ]; then |
64 | 67 | # check if DOMAINDIRECTORY exists, if it exists use --cert-name to prevent 0001 0002 0003 folders |
65 | 68 | if [ -d "$DOMAINDIRECTORY" ]; then |
66 | | - printf "\nUse certbot-auto certonly %s --cert-name %s\n" "${args[*]}" "${arr[0]}"; |
67 | | - certbot-auto certonly "${args[@]}" --cert-name "${arr[0]}" $dom |
| 69 | + printf "\nUse certbot certonly %s --cert-name %s\n" "${args[*]}" "${arr[0]}"; |
| 70 | + certbot certonly "${args[@]}" --cert-name "${arr[0]}" $dom |
68 | 71 | else |
69 | | - printf "\nUse certbot-auto certonly %s\n" "${args[*]}"; |
70 | | - certbot-auto certonly "${args[@]}" $dom |
| 72 | + printf "\nUse certbot certonly %s\n" "${args[*]}"; |
| 73 | + certbot certonly "${args[@]}" $dom |
71 | 74 | fi |
72 | 75 | fi |
73 | 76 |
|
|
0 commit comments