-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
executable file
·74 lines (67 loc) · 1.4 KB
/
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
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
#!/bin/bash
set -e
bops_log() {
local type="$1"; shift
printf '%s [%s] [Entrypoint]: %s\n' "$(date --rfc-3339=seconds)" "$type" "$*"
}
bops_note() {
bops_log Note "$@"
}
bops_warn() {
bops_log Warn "$@" >&2
}
# usage: docker_process_init_files [file [file [...]]]
# ie: docker_process_init_files /always-initdb.d/*
# process initializer files, based on file extensions
docker_process_init_files() {
echo
local f
for f; do
case "$f" in
*.sh)
if [ -x "$f" ]; then
bops_note "$0: running $f"
"$f"
else
bops_note "$0: sourcing $f"
. "$f"
fi
;;
*.bin)
if [ -x "$f" ]; then
bops_note "$0: running $f"
"$f"
fi
;;
*.env)
bops_note "$0: sourcing $f"
. "$f"
;;
*) bops_warn "$0: ignoring $f" ;;
esac
echo
done
}
if [ ! -z "${SAILOR_PASSWORD}" ]; then
bops_note "$0: setting sailor password"
echo "${SAILOR_PASSWORD}" | chpasswd
fi
# For user convenience.
# Bind mount /docker-entrypoint.d directory with you own addon init .sh, .bin or .env files.
if [ -d "/docker-entrypoint.d" ]; then
docker_process_init_files /docker-entrypoint.d/*
fi
if [ ! -z "${BOPS_SSH}" ]; then
bops_note "$0: running sshd"
mkdir -p /run/sshd
if [ -z "${BOPS_SSH_OPT}" ]; then
/usr/sbin/sshd -e -D
else
/usr/sbin/sshd ${BOPS_SSH_OPT}
fi
fi
if [ ! -z "${BOPS_KEEP_RUNNING}" ]; then
tail -f /dev/null
else
exec "$@"
fi