forked from telephoneorg/docker-freeswitch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint
executable file
·113 lines (82 loc) · 3.52 KB
/
entrypoint
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/bin/bash -l
set -e
[[ -f /etc/entrypoint ]] && . /etc/entrypoint
[[ -f /etc/default/$APP ]] && . /etc/default/$APP
# options: debug info notice warning err crit alert console
: readonly ${FREESWITCH_LOG_LEVEL:=info}
: readonly ${FREESWITCH_LOG_COLOR:=true}
# RTP port range settings
: declare -ir ${FREESWITCH_RTP_PORT_RANGE:=16384-32768}
: readonly ${MOD_KAZOO_LISTEN_IP:=0.0.0.0}
# if true, sets -nonat flag on freeswitch
: readonly ${FREESWITCH_DISABLE_NAT_DETECTION:=true}
: readonly ${FREESWITCH_SEND_ALL_HEADERS:=true}
# settings for sipcapture
: readonly ${FREESWITCH_CAPTURE_SERVER:=false}
: readonly ${FREESWITCH_CAPTURE_IP:=127.0.0.1}
# Enable TLS here
: readonly ${FREESWITCH_TLS_ENABLE:=false}
log::m-info "Rewriting kazoo.conf.xml ..."
tee /etc/freeswitch/autoload_configs/kazoo.conf.xml <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<configuration name="kazoo.conf" description="General purpose Erlang C-node produced to better fit the Kazoo project">
<settings>
<param name="listen-ip" value="$MOD_KAZOO_LISTEN_IP" />
<param name="listen-port" value="8031" />
<param name="cookie-file" value="$HOME/.erlang.cookie" />
<!--<param name="cookie" value="change_me" />-->
<param name="shortname" value="false" />
<param name="nodename" value="freeswitch" />
<!--<param name="kazoo-var-prefix" value="ecallmgr" />-->
<!--<param name="compat-rel" value="12"/> -->
<param name="send-all-headers" value="$FREESWITCH_SEND_ALL_HEADERS" />
</settings>
</configuration>
EOF
log::m-info "Setting $APP log level $FREESWITCH_LOG_LEVEL ..."
tee /etc/freeswitch/autoload_configs/console.conf.xml <<EOF
<configuration name="console.conf" description="Console Logger">
<settings>
<param name="colorize" value="$FREESWITCH_LOG_COLOR"/>
<param name="loglevel" value="${FREESWITCH_LOG_LEVEL,,}"/>
</settings>
<mappings>
<map name="all" value="console,debug,info,notice,warning,err,crit,alert"/>
</mappings>
</configuration>
EOF
log::m-info "Setting tls settings ..."
sed -i "/\"tls\"/s/value=\".*\"/value=\"$FREESWITCH_TLS_ENABLE\"/" /etc/freeswitch/sip_profiles/sipinterface_1.xml
grep '"tls"' $_
log::m-info "Setting RTP Port Range Min/Max on switch.conf.xml ..."
sed -i "/rtp-start-port/s/value=\".*\"/value=\"${FREESWITCH_RTP_PORT_RANGE%-*}\"/" /etc/freeswitch/autoload_configs/switch.conf.xml
sed -i "/rtp-end-port/s/value=\".*\"/value=\"${FREESWITCH_RTP_PORT_RANGE#*-}\"/" $_
grep 'rtp-' $_
if [[ $FREESWITCH_CAPTURE_SERVER = true ]]; then
log::m-info "Enabling capture server ..."
sed -i "/global_settings/a \
\ <param name=\"capture-server\" value=\"udp:${FREESWITCH_CAPTURE_IP}:9060;hep=3;capture_id=200\"/>" /etc/freeswitch/autoload_configs/sofia.conf.xml
grep capture-server $_
sed -i "/<!-- SIP -->/a \
\ <param name=\"sip-capture\" value=\"yes\"/>" /etc/freeswitch/sip_profiles/sipinterface_1.xml
grep sip-capture $_
fi
log::m-info "Ensuring volume dirs ..."
mkdir -p /volumes/ram/{log,run,db,cache,http_cache}
log::m-info "Setting ulimits ..."
set-limits freeswitch
if linux::cap::is-disabled 'net_raw'; then
linux::cap::show-warning 'net_raw'
fi
log::m-info "Ensuring permissions ..."
chown -R $USER:$USER ~ /etc/freeswitch
fixattrs
log::m-info "Building arguments ..."
CMD_ARGS=(-c -rp -nf -u $USER -g $USER)
[[ $FREESWITCH_DISABLE_NAT_DETECTION = true ]] && \
CMD_ARGS+=(-nonat)
set -- ${CMD_ARGS[@]}
log::m-info "Starting $APP ..."
cd ~
gosu $USER epmd -daemon
exec freeswitch "$@"