-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall_ant-media-server-rhel.sh
128 lines (103 loc) · 2.79 KB
/
install_ant-media-server-rhel.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
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/bin/bash
#
# Download latest ant media server and run this script by giving the zip file
# ./install_ant-media-server.sh ant-media-server-*.zip
# If you want to save setting from previous installation add argument true
# ./install_ant-media-server.sh ant-media-server-*.zip true
AMS_BASE=/usr/local/antmedia
BACKUP_DIR="/usr/local/antmedia-backup-"$(date +"%Y-%m-%d_%H-%M-%S")
SAVE_SETTINGS=false
restore_settings() {
#app settings
files[0]=/webapps/LiveApp/WEB-INF/red5-web.properties
files[1]=/webapps/ConsoleApp/WEB-INF/red5-web.properties
files[2]=/webapps/WebRTCApp/WEB-INF/red5-web.properties
files[3]=/webapps/WebRTCAppEE/WEB-INF/red5-web.properties
files[4]=/webapps/root/WEB-INF/red5-web.properties
#db files
files[5]=/liveapp.db
files[6]=/server.db
files[7]=/webrtcapp.db
files[8]=/webrtcappee.db
#copy app settings
for file in ${files[*]}
do
if [ -f $BACKUP_DIR$file ]; then
$SUDO cp $BACKUP_DIR$file $AMS_BASE$file
fi
done
echo "Settings are restored."
}
check() {
OUT=$1
if [ $OUT -ne 0 ]; then
echo "There is a problem in installing the ant media server. Please send the log of this console to [email protected]"
exit $OUT
fi
}
if [ -z "$1" ]; then
echo "Please give the Ant Media Server zip file as parameter"
echo "$0 ant-media-server-....zip"
exit 1
fi
if [ ! -z "$2" ]; then
SAVE_SETTINGS=$2
fi
SUDO="sudo"
if ! [ -x "$(command -v sudo)" ]; then
SUDO=""
fi
$SUDO yum update -y
check $?
$SUDO yum install java-1.8.0-openjdk unzip jsvc -y
check $?
openjfxExists=`yum search openjfx | wc -l`
if [ "$openjfxExists" -gt "0" ];
then
$SUDO yum install openjfx -y
fi
unzip $1
check $?
if ! [ -d $AMS_BASE ]; then
$SUDO mv ant-media-server $AMS_BASE
check $?
else
$SUDO mv $AMS_BASE $BACKUP_DIR
check $?
$SUDO mv ant-media-server $AMS_BASE
check $?
fi
$SUDO sed -i '/JAVA_HOME="\/usr\/lib\/jvm\/java-8-oracle"/c\JAVA_HOME="\/usr\/lib\/jvm\/java-1.8.0-openjdk"' $AMS_BASE/antmedia
check $?
$SUDO cp $AMS_BASE/antmedia /etc/init.d/
check $?
$SUDO update-rc.d antmedia defaults
check $?
$SUDO update-rc.d antmedia enable
check $?
$SUDO mkdir $AMS_BASE/log
check $?
if ! [ $(getent passwd | grep antmedia.*$AMS_BASE) ] ; then
$SUDO useradd -d $AMS_BASE/ -s /bin/false -r antmedia
check $?
fi
$SUDO chown -R antmedia:antmedia $AMS_BASE/
check $?
$SUDO service antmedia stop
$SUDO service antmedia start
OUT=$?
if [ $OUT -eq 0 ]; then
if [ $SAVE_SETTINGS == "true" ]; then
sleep 5
$SUDO service antmedia stop
restore_settings
check $?
$SUDO chown -R antmedia:antmedia $AMS_BASE/
check $?
$SUDO service antmedia start
check $?
fi
echo "Ant Media Server is started"
else
echo "There is a problem in installing the ant media server. Please send the log of this console to [email protected]"
fi