ucswitchSetup.sh
7.65 KB
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# 作者:石晓旭
#!/bin/bash
echo "[`date`] [DEBUG] ############################# ucswitchSetup.sh start ##########################" >> ${ucswitchSetupLogFile}
#安装git
bGitNotInstall=`rpm -qa | grep git- | wc -l`
if [ ${bGitNotInstall} -eq 0 ];then
yum -y install git
if [ $? -eq 0 ];then
echo "[`date`] [DEBUG] ucswitchSetup.sh install git success" >> ${ucswitchSetupLogFile}
else
echo "[`date`] [ERROR] ucswitchSetup.sh Failed to install git" >> ${ucswitchSetupLogFile}
exit 1
fi
else
echo "[`date`] [DEBUG] ucswitchSetup.sh install git already exits" >> ${ucswitchSetupLogFile}
fi
#下载ucswitch代码
if [ ! -d ${ucswitchDirectory} ];then
git clone -b "${gitBranch}" "http://${gitUser}:${gitPassword}@${gitUrl}"
if [ $? -eq 0 ];then
echo "[`date`] [DEBUG] ucswitchSetup.sh git clone ucswitch success" >> ${ucswitchSetupLogFile}
else
echo "[`date`] [ERROR] ucswitchSetup.sh Failed to git clone ucswitch" >> ${ucswitchSetupLogFile}
fi
else
echo "[`date`] [DEBUG] ucswitchSetup.sh git clone ucswitch already exits" >> ${ucswitchSetupLogFile}
fi
#安装依赖
cd ${ucswitchDirectory} cd && ./depends_install.sh "${ucswitchDirectory}" "${ucswitchSetupLogFile}" "${dependsUrl}/libs/"
if [ $? -eq 0 ];then
echo "[`date`] [DEBUG] ucswitchSetup.sh depends_install success" >> ${ucswitchSetupLogFile}
else
echo "[`date`] [ERROR] ucswitchSetup.sh Failed to depends_install" >> ${ucswitchSetupLogFile}
fi
#hiredis 打个补丁,否者fs无法识别他安装了。
if [ ! -d "/usr/local/lib/pkgconfig" ];then
mkdir -p "/usr/local/lib/pkgconfig"
fi
if [ ! -f "/usr/local/lib/pkgconfig/hiredis.pc" ];then
cp -f ${autoDirectory}/hiredis.pc /usr/local/lib/pkgconfig/hiredis.pc
fi
echo "/usr/local/lib" > /etc/ld.so.conf.d/hiredis-x86_64.conf
/sbin/ldconfig
#编译代码
cd ${ucswitchDirectory} && ./bootstrap.sh -j
if [ $? -eq 0 ];then
echo "[`date`] [DEBUG] ucswitchSetup.sh bootstrap.sh success" >> ${ucswitchSetupLogFile}
else
echo "[`date`] [ERROR] ucswitchSetup.sh Failed to bootstrap.sh" >> ${ucswitchSetupLogFile}
exit 1
fi
cd ${ucswitchDirectory} && ./configure.sh "${ucswitchDirectory}" "${ucswitchSetupLogFile}"
if [ $? -eq 0 ];then
echo "[`date`] [DEBUG] ucswitchSetup.sh configure.sh success" >> ${ucswitchSetupLogFile}
else
echo "[`date`] [ERROR] ucswitchSetup.sh Failed to configure.sh" >> ${ucswitchSetupLogFile}
exit 1
fi
cd ${ucswitchDirectory} && make && make install
if [ $? -eq 0 ];then
echo "[`date`] [DEBUG] ucswitchSetup.sh install ucswitch success" >> ${ucswitchSetupLogFile}
else
echo "[`date`] [ERROR] ucswitchSetup.sh Failed to install ucswitch" >> ${ucswitchSetupLogFile}
exit 1
fi
#替换配置
if [ ! -d "/usr/local/freeswitch" ];then
echo "[`date`] [ERROR] ucswitchSetup.sh Failed to replace scripts and config" >> ${ucswitchSetupLogFile}
exit 1
fi
cp -rf "${ucswitchDirectory}/uswitch_patch/scripts" "/usr/local/freeswitch"
if [ $? -ne 0 ];then
echo "[`date`] [ERROR] ucswitchSetup.sh Failed to cp scripts" >> ${ucswitchSetupLogFile}
exit 1
else
echo "[`date`] [DEBUG] ucswitchSetup.sh cp scripts" >> ${ucswitchSetupLogFile}
fi
cp -rf "${ucswitchDirectory}/uswitch_patch/conf" "/usr/local/freeswitch"
if [ $? -ne 0 ];then
echo "[`date`] [ERROR] ucswitchSetup.sh Failed to cp conf" >> ${ucswitchSetupLogFile}
exit 1
else
echo "[`date`] [DEBUG] ucswitchSetup.sh cp conf" >> ${ucswitchSetupLogFile}
fi
#修改配置
#switchname
sed -i "s%ucswitchName%${ucswitchName}%g" /usr/local/freeswitch/conf/autoload_configs/switch.conf.xml
if [ $? -eq 0 ];then
echo "[`date`] [DEBUG] ucswitchSetup.sh config switch.xml ucswitchname success" >> ${ucswitchSetupLogFile}
else
echo "[`date`] [ERROR] ucswitchSetup.sh Failed to config switch.xml ucswitchname" >> ${ucswitchSetupLogFile}
exit 1
fi
sed -i "s%ucswitchIp%${ucswitchIp}%g" /usr/local/freeswitch/conf/vars.xml
if [ $? -eq 0 ];then
echo "[`date`] [DEBUG] ucswitchSetup.sh config vars.xml local_ip_v4 success" >> ${ucswitchSetupLogFile}
else
echo "[`date`] [ERROR] ucswitchSetup.sh Failed to config vars.xml local_ip_v4" >> ${ucswitchSetupLogFile}
exit 1
fi
sed -i "s%ucswitchDbIp%${ucswitchDbIp}%g" /usr/local/freeswitch/conf/vars.xml
if [ $? -eq 0 ];then
echo "[`date`] [DEBUG] ucswitchSetup.sh config vars.xml database ip success" >> ${ucswitchSetupLogFile}
else
echo "[`date`] [ERROR] ucswitchSetup.sh Failed to config vars.xml database ip" >> ${ucswitchSetupLogFile}
exit 1
fi
sed -i "s%ucswitchDbPort%${ucswitchDbPort}%g" /usr/local/freeswitch/conf/vars.xml
if [ $? -eq 0 ];then
echo "[`date`] [DEBUG] ucswitchSetup.sh config vars.xml database port success" >> ${ucswitchSetupLogFile}
else
echo "[`date`] [ERROR] ucswitchSetup.sh Failed to config vars.xml database port" >> ${ucswitchSetupLogFile}
exit 1
fi
sed -i "s%ucswitchRedisPort%${redisPort}%g" /usr/local/freeswitch/conf/vars.xml
if [ $? -eq 0 ];then
echo "[`date`] [DEBUG] ucswitchSetup.sh config vars.xml redis port success" >> ${ucswitchSetupLogFile}
else
echo "[`date`] [ERROR] ucswitchSetup.sh Failed to config vars.xml redis port" >> ${ucswitchSetupLogFile}
exit 1
fi
sed -i "s%ucswitchRedisIp%${redisServer}%g" /usr/local/freeswitch/conf/vars.xml
if [ $? -eq 0 ];then
echo "[`date`] [DEBUG] ucswitchSetup.sh config vars.xml redis ip success" >> ${ucswitchSetupLogFile}
else
echo "[`date`] [ERROR] ucswitchSetup.sh Failed to config vars.xml redis ip" >> ${ucswitchSetupLogFile}
exit 1
fi
sed -i "s%ucswitchRedisPort%${redisPort}%g" /usr/local/freeswitch/conf/autoload_configs/uccc_redis.conf.xml
if [ $? -eq 0 ];then
echo "[`date`] [DEBUG] ucswitchSetup.sh config uccc_redis port success" >> ${ucswitchSetupLogFile}
else
echo "[`date`] [ERROR] ucswitchSetup.sh Failed to config uccc_redis port" >> ${ucswitchSetupLogFile}
exit 1
fi
sed -i "s%ucswitchRedisIp%${redisServer}%g" /usr/local/freeswitch/conf/autoload_configs/uccc_redis.conf.xml
if [ $? -eq 0 ];then
echo "[`date`] [DEBUG] ucswitchSetup.sh config uccc_redis ip success" >> ${ucswitchSetupLogFile}
else
echo "[`date`] [ERROR] ucswitchSetup.sh Failed to config uccc_redis ip" >> ${ucswitchSetupLogFile}
exit 1
fi
sed -i "s%ucswitchRedisPort%${redisPort}%g" /usr/local/freeswitch/conf/autoload_configs/hiredis.conf.xml
if [ $? -eq 0 ];then
echo "[`date`] [DEBUG] ucswitchSetup.sh config hiredis port success" >> ${ucswitchSetupLogFile}
else
echo "[`date`] [ERROR] ucswitchSetup.sh Failed to config hiredis port" >> ${ucswitchSetupLogFile}
exit 1
fi
sed -i "s%ucswitchRedisIp%${redisServer}%g" /usr/local/freeswitch/conf/autoload_configs/hiredis.conf.xml
if [ $? -eq 0 ];then
echo "[`date`] [DEBUG] ucswitchSetup.sh config hiredis ip success" >> ${ucswitchSetupLogFile}
else
echo "[`date`] [ERROR] ucswitchSetup.sh Failed to config hiredis ip" >> ${ucswitchSetupLogFile}
exit 1
fi
sed -i "s%ucswitchCdrUrl%${cdrUrl}%g" /usr/local/freeswitch/conf/autoload_configs/uccc_json_cdr.conf.xml
if [ $? -eq 0 ];then
echo "[`date`] [DEBUG] ucswitchSetup.sh config uccc cdr url success" >> ${ucswitchSetupLogFile}
else
echo "[`date`] [ERROR] ucswitchSetup.sh Failed to config uccc cdr url" >> ${ucswitchSetupLogFile}
exit 1
fi
#安装音乐文件。
cd ${autoDirectory}
wget "${dependsUrl}/sounds/sounds.tar.gz"
if [ $? -eq 0 ];then
echo "[`date`] [DEBUG] ucswitchSetup.sh down sounds success" >> ${ucswitchSetupLogFile}
else
echo "[`date`] [ERROR] ucswitchSetup.sh Failed to down sounds" >> ${ucswitchSetupLogFile}
exit 1
fi
tar -xzvf ${autoDirectory}/sounds.tar.gz -C /usr/local/freeswitch/
if [ $? -eq 0 ];then
echo "[`date`] [DEBUG] ucswitchSetup.sh install sounds success" >> ${ucswitchSetupLogFile}
else
echo "[`date`] [ERROR] ucswitchSetup.sh Failed to install sounds" >> ${ucswitchSetupLogFile}
exit 1
fi
echo "[`date`] [DEBUG] ############################# ucswitchSetup.sh end ##########################" >> ${ucswitchSetupLogFile}