forked from orboan-docker/docker-centos-supervisor-ssh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.sh
executable file
·48 lines (39 loc) · 1.34 KB
/
bootstrap.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
40
41
42
43
44
45
46
47
48
#!/bin/bash
set -e
set -u
# Supervisord default params
SUPERVISOR_PARAMS='-c /etc/supervisord.conf'
# Create directories for supervisor's UNIX socket and logs (which might be missing
# as container might start with /data mounted from another data-container).
mkdir -p /data/conf /data/run /data/logs
chmod 711 /data/conf /data/run /data/logs
if [ "$(ls /config/init/)" ]; then
for init in /config/init/*.sh; do
. $init
done
fi
# We have TTY, so probably an interactive container...
if test -t 0; then
# Run supervisord detached...
supervisord $SUPERVISOR_PARAMS
# Some command(s) has been passed to container? Execute them and exit.
# No commands provided? Run bash.
if [[ $@ ]]; then
eval $@
else
export PS1='[\u@\h : \w]\$ '
/bin/bash
fi
# Detached mode? Run supervisord in foreground, which will stay until container is stopped.
else
# If some extra params were passed, execute them before.
# @TODO It is a bit confusing that the passed command runs *before* supervisord,
# while in interactive mode they run *after* supervisor.
# Not sure about that, but maybe when any command is passed to container,
# it should be executed *always* after supervisord? And when the command ends,
# container exits as well.
if [[ $@ ]]; then
eval $@
fi
supervisord -n $SUPERVISOR_PARAMS
fi