-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun
executable file
·48 lines (36 loc) · 890 Bytes
/
run
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
40
41
42
43
44
45
46
47
48
#!/bin/sh
SUDO="sudo"
$SUDO 2>/dev/null
if [ "$?" = "127" ] # command sudo NOT found
then
SUDO=""
fi
while :
do
host_name=`cat config.json | grep host_name | cut -f4 -d'"'`
if [ "$host_name" != "" ]
then
$SUDO cp /etc/letsencrypt/live/$host_name/privkey.pem https-privkey.pem
$SUDO cp /etc/letsencrypt/live/$host_name/fullchain.pem https-fullchain.pem
uid=`id -u`
gid=`id -g`
$SUDO chown $uid:$gid https-privkey.pem
chmod 400 https-privkey.pem
fi
if [ -e "./cmd/watchtower/watchtower" ]
then
./cmd/watchtower/watchtower
else
cd cmd/watchtower && go run .
fi
if [ "$?" = "123" ] # some error
then
alert_url=`cat config.json | grep watchtower_failure_alert_url | cut -f4 -d'"'`
if [ "$alert_url" != "" ]
then
echo curl -v -d "'{\"error\":\"unknown\"}'" "'$alert_url'"
curl -d "'{\"error\":\"unknown\"}'" "$alert_url"
fi
fi
sleep 2
done