-
Notifications
You must be signed in to change notification settings - Fork 1
/
entrypoint.sh
executable file
·46 lines (36 loc) · 1.14 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
#!/bin/sh
set -e
for i in "passwd" "group" "shadow" "login.defs"; do
if [ ! -f "/etc/${i}" ]; then
cp "/conf/${i}" "/etc/${i}"
fi
done
if [ x"${WORKERS}" = "x" ]; then
WORKERS="10"
fi
CFGFILE="/conf/dante.conf"
if [ x"${IP6}" = "x" ]; then
IP6=`ip -6 r | grep '^default' || echo ""`
if [ x"${IP6}" != "x" ]; then
CFGFILE="/conf/dante6.conf"
fi
fi
if [ x"${INTERFACE}" = "x" ]; then
INTERFACE=`ip r | grep '^default' | grep -o 'dev[ ]*[^ ]*' | grep -o '[^ ]*$' || echo ""`
fi
if [ x"${INTERFACE}" != "x" ]; then
sed -i 's/external\:.*$/external: '"${INTERFACE}"'/' "${CFGFILE}"
fi
if [ x"${PORT}" != "x" ]; then
# internal: 0.0.0.0 port = 1080
sed -i 's/\(internal\:.*port[ ]*=[ ]*\)[^ ]*\(.*\)$/\1'"${PORT}"'\2/' "${CFGFILE}"
echo "${PORT}" > /tmp/dante_port
fi
if [ x"${USER}" != "x" -a x"${PASS}" != "x" ]; then
echo "${USER} ${PASS}"
if ! getent passwd "${USER}"; then
adduser -D -H -S "${USER}"
fi
echo "${USER}:${PASS}" | chpasswd -c SHA256
fi
exec "sockd" "-f" "${CFGFILE}" "-N" "${WORKERS}"