ucswitchSetup.sh
4.81 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
# 作者:石晓旭
#!/bin/bash
echo "[`date`] [DEBUG] ############################# ucswitchSetup.sh start ##########################"
#安装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"
else
echo "[`date`] [ERROR] ucswitchSetup.sh Failed to install git"
exit 1
fi
else
echo "[`date`] [DEBUG] ucswitchSetup.sh install git already exits"
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"
else
echo "[`date`] [ERROR] ucswitchSetup.sh Failed to git clone ucswitch"
fi
else
echo "[`date`] [DEBUG] ucswitchSetup.sh git clone ucswitch already exits"
fi
#安装依赖
cd ${ucswitchDirectory} cd && ./depends_install.sh "${ucswitchDirectory}" "${dependsUrl}/fs/libs/"
if [ $? -eq 0 ];then
echo "[`date`] [DEBUG] ucswitchSetup.sh depends_install success"
else
echo "[`date`] [ERROR] ucswitchSetup.sh Failed to depends_install"
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}/conf/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"
else
echo "[`date`] [ERROR] ucswitchSetup.sh Failed to bootstrap.sh"
exit 1
fi
cd ${ucswitchDirectory} && ./configure.sh "${ucswitchDirectory}"
if [ $? -eq 0 ];then
echo "[`date`] [DEBUG] ucswitchSetup.sh configure.sh success"
else
echo "[`date`] [ERROR] ucswitchSetup.sh Failed to configure.sh"
exit 1
fi
cd ${ucswitchDirectory} && make && make install
if [ $? -eq 0 ];then
echo "[`date`] [DEBUG] ucswitchSetup.sh install ucswitch success"
else
echo "[`date`] [ERROR] ucswitchSetup.sh Failed to install ucswitch"
exit 1
fi
#替换配置
cd ${autoDirectory}
if [ ! -d "/usr/local/freeswitch" ];then
echo "[`date`] [ERROR] ucswitchSetup.sh Failed to replace scripts and config"
exit 1
fi
if [ ! -f "${autoDirectory}/sounds.tar.gz" ];then
wget $fsSoundsUrl
if [ $? -ne 0 ];then
exit 1
fi
fi
if [ ! -f "${autoDirectory}/sbin.tar.gz" ];then
wget $fsSbinUrl
if [ $? -ne 0 ];then
exit 1
fi
fi
if [ ! -f "${autoDirectory}/scripts.tar.gz" ];then
wget $fsScriptsUrl
if [ $? -ne 0 ];then
exit 1
fi
fi
if [ ! -f "${autoDirectory}/conf.tar.gz" ];then
wget $fsConfUrl
if [ $? -ne 0 ];then
exit 1
fi
fi
tar -xzvf ${autoDirectory}/sbin.tar.gz -C /
if [ $? -eq 0 ];then
echo "[`date`] [DEBUG] ucswitchSetup.sh replace sbin success"
else
echo "[`date`] [ERROR] ucswitchSetup.sh Failed to replace sbin"
exit 1
fi
tar -xzvf ${autoDirectory}/scripts.tar.gz -C /usr/local/freeswitch/
if [ $? -eq 0 ];then
echo "[`date`] [DEBUG] ucswitchSetup.sh replace scripts success"
else
echo "[`date`] [ERROR] ucswitchSetup.sh Failed to replace scripts"
exit 1
fi
tar -xzvf ${autoDirectory}/conf.tar.gz -C /usr/local/freeswitch/
if [ $? -eq 0 ];then
echo "[`date`] [DEBUG] ucswitchSetup.sh replace conf success"
else
echo "[`date`] [ERROR] ucswitchSetup.sh Failed to replace conf"
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"
else
echo "[`date`] [ERROR] ucswitchSetup.sh Failed to install sounds"
exit 1
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"
else
echo "[`date`] [ERROR] ucswitchSetup.sh Failed to config switch.xml ucswitchname"
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"
else
echo "[`date`] [ERROR] ucswitchSetup.sh Failed to config vars.xml local_ip_v4"
exit 1
fi
# 优化 #
cat /etc/fstab | grep /usr/local/freeswitch/db
if [ $? -ne 0 ];then
echo "tmpfs /usr/local/freeswitch/db tmpfs size=100m 0 0" >> /etc/fstab
fi
cat /etc/fstab | grep /home/sharedfs/records
if [ $? -ne 0 ];then
echo "tmpfs /home/sharedfs/records tmpfs size=2048m 0 0" >> /etc/fstab
fi
mkdir -p /home/sharedfs/records
/bin/mount -a
if [ $? -ne 0 ];then
exit 1
fi
echo "[`date`] [DEBUG] ############################# ucswitchSetup.sh end ##########################"