-
Notifications
You must be signed in to change notification settings - Fork 2
/
docker-entrypoint.sh
executable file
·63 lines (48 loc) · 1.23 KB
/
docker-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
#!/usr/bin/env bash
set -e
if [[ -n "${DEBUG}" ]]; then
set -x
fi
ssh_dir=/home/wodby/.ssh
_gotpl() {
if [[ -f "/etc/gotpl/$1" ]]; then
gotpl "/etc/gotpl/$1" > "$2"
fi
}
init_sshd() {
_gotpl "sshd_config.tmpl" "/etc/ssh/sshd_config"
printenv | xargs -I{} echo {} | awk ' \
BEGIN { FS = "=" }; { \
if ($1 != "HOME" \
&& $1 != "PWD" \
&& $1 != "PATH" \
&& $1 != "SHLVL") { \
\
print ""$1"="$2"" \
} \
}' > "${ssh_dir}/environment"
sudo gen_ssh_keys "rsa" "${SSHD_HOST_KEYS_DIR}"
}
init_git() {
git config --global user.email "${GIT_USER_EMAIL}"
git config --global user.name "${GIT_USER_NAME}"
}
process_templates() {
_gotpl ssh_config.tmpl "${ssh_dir}/config"
_gotpl unicorn.init.d.tmpl /etc/init.d/unicorn
_gotpl unicorn.conf.rb.tmpl /usr/local/etc/unicorn.rb
_gotpl puma.conf.rb.tmpl /usr/local/etc/puma.rb
}
sudo init_container
init_git
process_templates
chmod +x /etc/init.d/unicorn
if [[ "${@:1:2}" == "sudo /usr/sbin/sshd" ]]; then
init_sshd
fi
exec_init_scripts
if [[ "${1}" == "make" ]]; then
exec "${@}" -f /usr/local/bin/actions.mk
else
exec "${@}"
fi