-
Notifications
You must be signed in to change notification settings - Fork 6
/
run.sh
executable file
·39 lines (31 loc) · 1.63 KB
/
run.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
site_ids=$(serveradmin settings web:customSites | grep ':serverName = ' | awk -F '=' '{print $1}' | grep -E -o '[0-9]+')
for site_id in $site_ids; do
certificate=$(serveradmin settings web:customSites | grep "web:customSites:_array_index:$site_id:sslCertificateIdentifier" | awk -F '=' '{print $2}' | awk -F '"' '{print $2}')
if [ "$certificate" = "" ]; then
continue
fi
serverName=$(serveradmin settings web:customSites | grep "web:customSites:_array_index:$site_id:serverName" | awk -F '=' '{print $2}' | awk -F '"' '{print $2}')
serverAliases=$(serveradmin settings web:customSites | grep "web:customSites:_array_index:$site_id:serverAlias" | awk -F '=' '{print $2}' | awk -F '"' '{print $2}')
documentRoot=$(serveradmin settings web:customSites | grep "web:customSites:_array_index:$site_id:documentRoot" | awk -F '=' '{print $2}' | awk -F '"' '{print $2}')
echo $serverName $serverAliases $certificate $documentRoot
BASEDIR=$(dirname $0)/dehydrated
if [ "${BASEDIR:0:1}" = "." ]; then
BASEDIR=$(pwd)/$BASEDIR
fi
WELLKNOWN="$documentRoot/.well-known/acme-challenge"
mkdir -p $WELLKNOWN
curl -sL http://$serverName/.well-known/acme-challenge | grep -qv '404 Not Found'
if [ "$?" != "0" ]; then
echo "The acme-challenge directory appears to be inaccessible."
echo "Please make sure you don't have a whole-site Redirect or ProxyPass on $serverName."
exit 1
fi
echo "WELLKNOWN=$WELLKNOWN; BASEDIR=$BASEDIR" > config
CMD=$(dirname $0)/dehydrated/dehydrated
PARAMS="--cron --hook $(dirname $0)/hooks.sh --domain $serverName"
for dom in $serverAliases; do
PARAMS="$PARAMS --domain $dom"
done
$CMD $* $PARAMS
done