forked from cloudpatron/cloudpatron
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.sh
38 lines (33 loc) · 922 Bytes
/
entrypoint.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
#!/bin/bash
set -o errexit
set -o nounset
set -o pipefail
set -o xtrace
# Require variables.
if [ -z "${CLOUDPATRON_HTTP_HOST-}" ] ; then
echo "Environment variable CLOUDPATRON_HTTP_HOST required. Exiting."
exit 1
fi
# Allow optional variables.
if [ -z "${CLOUDPATRON_BACKLINK-}" ] ; then
export CLOUDPATRON_BACKLINK=""
fi
# cloudpatron service
if ! test -d /etc/sv/cloudpatron ; then
mkdir /etc/sv/cloudpatron
cat <<RUNIT >/etc/sv/cloudpatron/run
#!/bin/sh
exec /usr/bin/cloudpatron --http-host "${CLOUDPATRON_HTTP_HOST}" --backlink "${CLOUDPATRON_BACKLINK}"
RUNIT
chmod +x /etc/sv/cloudpatron/run
# cloudpatron service log
mkdir /etc/sv/cloudpatron/log
mkdir /etc/sv/cloudpatron/log/main
cat <<RUNIT >/etc/sv/cloudpatron/log/run
#!/bin/sh
exec svlogd -tt ./main
RUNIT
chmod +x /etc/sv/cloudpatron/log/run
ln -s /etc/sv/cloudpatron /etc/service/cloudpatron
fi
exec $@