-
Notifications
You must be signed in to change notification settings - Fork 4
/
run_app
executable file
·81 lines (50 loc) · 2.07 KB
/
run_app
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
./lets-proxy &
source /root/mo
echo "$ADDITIONAL_CONFIG" > /etc/nginx/conf.d/additional_config.conf.template
perl -pi.bak -e 's/\$\$/\$/g' /etc/nginx/conf.d/additional_config.conf.template # replace $$ to $ for rancher
cat /etc/nginx/conf.d/additional_config.conf.template | mo > /etc/nginx/conf.d/additional_config.conf
cd /
cron
cat /letsencrypt_retrieve_keys.cron /nginx_restart.cron > /tmp/cron.tab
crontab /tmp/cron.tab
bash letsencrypt_retrieve_keys.sh
if [ -z "$LOCAL_RUN" ]; then
rm -rf /etc/nginx/conf.d-local
fi
(inotifywait -m -r '/opt/containers/' -e create -e moved_to | grep --line-buffered nginx | grep --line-buffered -E '.conf$' | while read path action file; do
nginx -s reload
done;) &
(inotifywait -m -r '/etc/letsencrypt/live/' -e create -e moved_to | grep --line-buffered nginx | grep --line-buffered -E '.pem$' | while read path action file; do
bash /letsencrypt_retrieve_keys.sh
nginx -s reload
done;) &
if [ -z "$DNS_RESOLVER" ]; then
if [ -z "$DOCKER_VERSION" ]; then
echo Cannot run without DOCKER_VERSION
exit 255;
fi
cd /root/ && wget https://get.docker.com/builds/Linux/x86_64/docker-"$DOCKER_VERSION".tgz && tar zxvf docker-"$DOCKER_VERSION".tgz && ln -s /root/docker/docker /usr/bin/docker
if [ -S /usr/lib/systemd/system/host/docker.socket ]; then
ln -s /usr/lib/systemd/system/host/docker.socket /var/run/docker.sock
fi
if [ -S /var/run/host/docker.sock ]; then
ln -s /var/run/host/docker.sock /var/run/docker.sock
fi
(while true; do bash /docker_hostnames.sh; sleep 5; done &)
sleep 5
(while true; do dnsmasq -k; sleep 5; done &)
sleep 5
export DNS_RESOLVER=127.0.0.1
fi
if [ -z "$CONTAINER_DNS_TEMPLATE" ]; then
export CONTAINER_DNS_TEMPLATE='$name.lo'
fi
if [ -z "$CONTAINER_VERSION_DNS_TEMPLATE" ]; then
export CONTAINER_VERSION_DNS_TEMPLATE='$name.$version.lo'
fi
cat /etc/nginx/conf.d/containers.conf.template | mo > /etc/nginx/conf.d/containers.conf
(while true; do nginx -g 'daemon off;'; sleep 5; done &)
sleep 5
nginx -s reload
sleep infinity