-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-entrypoint.sh
More file actions
executable file
·61 lines (49 loc) · 2.5 KB
/
docker-entrypoint.sh
File metadata and controls
executable file
·61 lines (49 loc) · 2.5 KB
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
#!/usr/bin/env bash
set -e
. /docker-entrypoint-common.sh
if [ "$1" = "unitd" -o "$1" = "unitd-debug" ]; then
if find "/var/lib/unit/" -type f -print -quit 2>/dev/null | grep -q .; then
ngx_notice "/var/lib/unit/ is not empty, skipping initial configuration..."
else
if find "/docker-entrypoint.d/" -mindepth 1 -print -quit 2>/dev/null | grep -q .; then
ngx_info "/docker-entrypoint.d/ is not empty, launching Unit daemon to perform initial configuration..."
/usr/sbin/$1 --control unix:/var/run/control.unit.sock
while [ ! -S /var/run/control.unit.sock ]; do
ngx_info "waiting for control socket to be created..."
sleep 0.1
done
# even when the control socket exists, it does not mean unit has finished initialisation
# this curl call will get a reply once unit is fully launched
curl -s -X GET --unix-socket /var/run/control.unit.sock http://localhost/
ngx_info "looking for shell scripts in /docker-entrypoint.d/..."
for f in $(find /docker-entrypoint.d/ -type f -name "*.sh"); do
ngx_info "launching $f"
"$f"
done
ngx_info "looking for certificate bundles in /docker-entrypoint.d/..."
for f in $(find /docker-entrypoint.d/ -type f -name "*.pem"); do
ngx_info "uploading certificates bundle: $f"
curl_put $f "certificates/$(basename $f .pem)"
done
ngx_info "looking for configuration snippets in /docker-entrypoint.d/..."
for f in $(find /docker-entrypoint.d/ -type f -name "*.json"); do
ngx_info "applying configuration $f"
curl_put $f "config"
done
# warn on filetypes we don't know what to do with
for f in $(find /docker-entrypoint.d/ -type f -not -name "*.sh" -not -name "*.json" -not -name "*.pem"); do
ngx_notice "ignoring $f"
done
ngx_info "stopping Unit daemon after initial configuration..."
kill -TERM $(cat /var/run/unit.pid)
while [ -S /var/run/control.unit.sock ]; do
ngx_info "waiting for control socket to be removed..."
sleep 0.1
done
ngx_notice "unit initial configuration complete; ready for start up..."
else
ngx_notice "/docker-entrypoint.d/ is empty, skipping initial configuration..."
fi
fi
fi
exec "$@"