forked from ant-media/Ant-Media-Server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
change_server_mode.sh
47 lines (36 loc) · 1.71 KB
/
change_server_mode.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
MODE=$1
USE_GLOBAL_IP="false"
if [ $MODE = "cluster" ]
then
echo "Mode: cluster"
DB_TYPE=mongodb
MONGO_SERVER_IP=$2
cp /usr/local/antmedia/conf/jee-container-cluster.xml /usr/local/antmedia/conf/jee-container.xml
if [ ! -z "$3" ]; then
USE_GLOBAL_IP=$3
fi
else
echo "Mode: standalone"
DB_TYPE=mapdb
MONGO_SERVER_IP=localhost
cp /usr/local/antmedia/conf/jee-container-standalone.xml /usr/local/antmedia/conf/jee-container.xml
fi
LIVEAPP_PROPERTIES_FILE=/usr/local/antmedia/webapps/LiveApp/WEB-INF/red5-web.properties
WEBRTCAPP_PROPERTIES_FILE=/usr/local/antmedia/webapps/WebRTCAppEE/WEB-INF/red5-web.properties
CONSOLEAPP_PROPERTIES_FILE=/usr/local/antmedia/webapps/root/WEB-INF/red5-web.properties
RED5_PROPERTIES_FILE=/usr/local/antmedia/conf/red5.properties
sed -i 's/clusterdb.host=.*/clusterdb.host='$MONGO_SERVER_IP'/' $RED5_PROPERTIES_FILE
sed -i 's/useGlobalIp=.*/useGlobalIp='$USE_GLOBAL_IP'/' $RED5_PROPERTIES_FILE
sed -i 's/db.type=.*/db.type='$DB_TYPE'/' $LIVEAPP_PROPERTIES_FILE
sed -i 's/db.host=.*/db.host='$MONGO_SERVER_IP'/' $LIVEAPP_PROPERTIES_FILE
sed -i 's/db.type=.*/db.type='$DB_TYPE'/' $WEBRTCAPP_PROPERTIES_FILE
sed -i 's/db.host=.*/db.host='$MONGO_SERVER_IP'/' $WEBRTCAPP_PROPERTIES_FILE
sed -i 's/db.type=.*/db.type='$DB_TYPE'/' $CONSOLEAPP_PROPERTIES_FILE
sed -i 's/db.host=.*/db.host='$MONGO_SERVER_IP'/' $CONSOLEAPP_PROPERTIES_FILE
LOCAL_IPv4=`ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p'`
HOST_NAME=`cat /proc/sys/kernel/hostname`
HOST_LINE="$LOCAL_IPv4 $HOST_NAME"
sed -i '/'$HOST_NAME'/d' /etc/hosts
echo "$HOST_LINE" | tee -a /etc/hosts
echo "Ant Media Server will be restarted in $MODE mode."
service antmedia restart