-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
boot_run.sh
executable file
·66 lines (56 loc) · 2.73 KB
/
boot_run.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
#!/bin/bash
# OpenSIPS Docker bootstrap
MYSQL_PWD=${MYSQL_PWD:-"passwd"}
EXTERNAL_IP=$(cat /etc/public_ip.txt)
#EXTERNAL_IP=$(ip route get 8.8.8.8 | awk '{print $NF; exit}')
ADVERTISED_IP=${ADVERTISED_IP:-$EXTERNAL_IP}
ADVERTISED_PORT=${ADVERTISED_PORT:-"5060"}
ADVERTISED_RANGE_FIRST=${ADVERTISED_RANGE_FIRST:-"20000"}
ADVERTISED_RANGE_LAST=${ADVERTISED_RANGE_LAST:-"20100"}
WSS_PORT=${WSS_PORT:-"5061"}
HOMER_SERVER=${HOMER_SERVER:-"de9.sipcapture.io"}
HOMER_PORT=${HOMER_PORT:-"9060"}
HOST_IP=$(ip route get 8.8.8.8 | head -n +1 | tr -s " " | cut -d " " -f 7)
echo "Your IP : ${HOST_IP}"
echo "Public IP : ${EXTERNAL_IP}"
echo "HEP Backend : ${HOMER_SERVER}:${HOMER_PORT}"
echo -e "Advertised IP:PORT : ${ADVERTISED_IP}:${ADVERTISED_PORT}\n\n"
echo -e "Advertised RTP Range : ${ADVERTISED_RANGE_FIRST}-${ADVERTISED_RANGE_LAST}\n\n"
# Starting MySQL
service mysql start
# Auto Create Database
expect -c "
spawn /usr/local/sbin/opensipsdbctl create \"\"
expect \"MySQL password for root: \"
send \"${MYSQL_PWD}\r\"
expect \"Install presence related tables? (y/n):\"
send \"y\r\"
expect \"Install tables for imc cpl siptrace domainpolicy carrierroute userblacklist b2b cachedb_sql registrant call_center fraud_detection emergency? (y/n)\"
send \"y\r\"
expect \"END\"
"
# Configure opensips.cfg
sed -i "s/advertised_address=.*/advertised_address=\"${ADVERTISED_IP}\"/g" /usr/local/etc/opensips/opensips.cfg
#sed -i "s/listen=udp.*/listen=udp:${HOST_IP}:${ADVERTISED_PORT}/g" /usr/local/etc/opensips/opensips.cfg
#sed -i "s/listen=tcp.*/listen=ws:${HOST_IP}:${ADVERTISED_PORT}/g" /usr/local/etc/opensips/opensips.cfg
#sed -i "s/^listen=udp.*/listen=udp:${HOST_IP}:${ADVERTISED_PORT}/g" /etc/opensips/opensips.cfg
# Configure HOMER target
sed -i "s/127.0.0.1:9060/${HOMER_SERVER}:${HOMER_PORT}/g" /usr/local/etc/opensips/opensips.cfg
sed -i "s/[hid]127.0.0.1:9060/[hid]${HOMER_SERVER}:${HOMER_PORT}/g" /usr/local/etc/opensips/opensips.cfg
#sed -i "s/127.0.0.1:6090/${HOMER_SERVER}:${HOMER_PORT}/g" /usr/local/etc/opensips/opensips.cfg
# Prepare RTPEngine modules
#mkdir /lib/modules/$(uname -r)/updates
#cp -u /rtpengine/xt_RTPENGINE.ko "/lib/modules/$(uname -r)/updates/xt_RTPENGINE.ko"
#depmod -a
#modprobe xt_RTPENGINE
#mkdir /recording
# Starting RTPEngine process
# echo 'del 0' > /proc/rtpengine/control || true
# rtpengine-recording --config-file=/etc/rtpengine/rtpengine-recording.conf
rtpengine -p /var/run/rtpengine.pid --interface=$HOST_IP!$ADVERTISED_IP -n 127.0.0.1:60000 -c 127.0.0.1:60001 -m $ADVERTISED_RANGE_FIRST -M $ADVERTISED_RANGE_LAST -E -L 6 \
--homer=${HOMER_SERVER}:${HOMER_PORT} --homer-protocol=udp --homer-id=8888 \
# --foreground true --log-stderr false \
--table=0 &
# Starting OpenSIPS process
/usr/local/sbin/opensips -c
/usr/local/sbin/opensips -FE