-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patholympusmodules
212 lines (174 loc) · 5.83 KB
/
olympusmodules
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
#!/bin/bash
function valid_ip()
{
local ip=$1
local stat=1
if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
OIFS=$IFS
IFS='.'
ip=($ip)
IFS=$OIFS
[[ ${ip[0]} -le 255 && ${ip[1]} -le 255 \
&& ${ip[2]} -le 255 && ${ip[3]} -le 255 ]]
stat=$?
fi
return $stat
}
#########################################################################################
function port_is_ok() {
local port="$1"
local -i port_num=$(to_int "${port}" 2>/dev/null)
if (( $port_num < 1 || $port_num > 65535 )) ; then
return 1
else
return 0
fi
}
function to_int {
local -i num="10#${1}"
echo "${num}"
}
#########################################################################################
AllFile=true
FILE=/etc/asterisk/http.conf
if ! [ -f "$FILE" ]; then
echo "$FILE does not exist , Asterisk is not installed correctly !!"
AllFile=false
fi
FILE=/etc/asterisk/sip.conf
if ! [ -f "$FILE" ]; then
echo "$FILE does not exist , Asterisk is not installed correctly !!"
AllFile=false
fi
FILE=/etc/asterisk/extensions.conf
if ! [ -f "$FILE" ]; then
echo "$FILE does not exist , Asterisk is not installed correctly !!"
AllFile=false
fi
FILE=/etc/kurento/modules/kurento/WebRtcEndpoint.conf.ini
if ! [ -f "$FILE" ]; then
echo "$FILE does not exist , Kurento is not installed correctly !!"
AllFile=false
fi
##############################################################################################
if [ "$AllFile" = true ] ; then
echo "Enter the IP address of this server - or enter q to skip :"
read srvip
if ! [ "$srvip" = 'q' ] ; then
while ! valid_ip $srvip
do
echo "Bad IP Address"
echo "Please Re-Enter the IP address of this server - or enter q to skip : :"
read srvip
done
if valid_ip $srvip
then
sed -i "s+bindaddr=.*+bindaddr=$srvip+g" "/etc/asterisk/http.conf"
sed -i "s+tlsbindaddr=.*+tlsbindaddr=$srvip:8089+g" "/etc/asterisk/http.conf"
sed -i "s+realm=.*+realm=$srvip+g" "/etc/asterisk/sip.conf"
sed -i "s+udpbindaddr=.*+udpbindaddr=$srvip+g" "/etc/asterisk/sip.conf"
#sed -i "s/10.20.30.215/$srvip/g" "/etc/asterisk/http.conf"
#sed -i "s/10.20.30.215/$srvip/g" "/etc/asterisk/sip.conf"
else echo "Bad IP Address"
fi
fi
########################################################################################
echo "Enter the STUN IP Address - or enter q to skip :"
read stunIP
if ! [ "$stunIP" = 'q' ] ; then
while ! valid_ip $stunIP
do
echo "Bad STUN IP Address"
echo "Please Re-Enter the STUN IP address :"
read stunIP
done
if valid_ip $stunIP
then
sed -i "s+;stunServerAddress=<IpAddress>+stunServerAddress=$stunIP+g" "/etc/kurento/modules/kurento/WebRtcEndpoint.conf.ini"
sed -i "s+stunServerAddress=.*+stunServerAddress=$stunIP+g" "/etc/kurento/modules/kurento/WebRtcEndpoint.conf.ini"
else echo "Bad STUN IP Address"
fi
fi
############################################################################################
echo "Enter the STUN Port number - or enter q to skip :"
read stunprt
if ! [ "$stunprt" = 'q' ] ; then
while ! port_is_ok $stunprt ; do
echo "STUN Port number is not Valid !!"
echo "Enter a Valid STUN Port number:"
read stunprt
done
sed -i "s+;stunServerPort=<Port>+stunServerPort=$stunprt+g" "/etc/kurento/modules/kurento/WebRtcEndpoint.conf.ini"
sed -i "s+stunServerPort=.*+stunServerPort=$stunprt+g" "/etc/kurento/modules/kurento/WebRtcEndpoint.conf.ini"
fi
##############################################################################################
echo "Enter the CUCM IP Address - or enter q to skip :"
read cucmIP
if ! [ "$cucmIP" = 'q' ] ; then
while ! valid_ip $cucmIP
do
echo "Bad CUCM IP Address"
echo "Please Re-Enter the CUCM IP address :"
read cucmIP
done
if valid_ip $cucmIP
then
sed -i "s+^host=[0-9].*+host=$cucmIP+g" "/etc/asterisk/sip.conf"
else echo "Bad CUCM IP Address"
fi
fi
##############################################################################################
echo "Enter the CUCM Port - or enter q to skip :"
read cucmprt
if ! [ "$cucmprt" = 'q' ] ; then
while ! port_is_ok $cucmprt ; do
echo "CUCM Port number is not Valid !!"
echo "Enter a Valid CUCM Port number:"
read cucmprt
done
sed -i "s+\bport\b=.*+port=$cucmprt+g" "/etc/asterisk/sip.conf"
fi
#############################################################################################
echo "Enter the full path for crt file - or enter q to skip:"
read crt
if ! [ "$crt" = 'q' ] ; then
while ! [ -f "$crt" ]; do
echo "$crt does not exist , Please enter a valid crt file !!"
read crt
done
#if ! [ -f "$crt" ]; then
# echo "$crt does not exist"
#else
sed -i "s+tlscertfile=.*+tlscertfile=$crt+g" "/etc/asterisk/http.conf"
sed -i "s+dtlscertfile=.*+dtlscertfile=$crt+g" "/etc/asterisk/sip.conf"
#fi
fi
echo "Enter the full path for key file - or enter q to skip:"
read crt1
if ! [ "$crt1" = 'q' ] ; then
while ! [ -f "$crt1" ]; do
echo "$crt1 does not exist , Please enter a valid key file !!"
read crt1
done
sed -i "s+tlsprivatekey=.*+tlsprivatekey=$crt1+g" "/etc/asterisk/http.conf"
sed -i "s+dtlsprivatekey=.*+dtlsprivatekey=$crt1+g" "/etc/asterisk/sip.conf"
fi
##########################################################################################
echo "Enter the Username for asterisk - or enter q to skip:"
read un1
if ! [ "$un1" = 'q' ] ; then
sed -i "s+^\[[0-9].*+\[$un1\]+g" "/etc/asterisk/sip.conf"
sed -i "s+username=.*+username=$un1+g" "/etc/asterisk/sip.conf"
sed -i "s+^exten => [0-9].*+exten => $un1,1,Dial(SIP/$un1)+g" "/etc/asterisk/extensions.conf"
fi
####################################################################
echo "Enter the password for asterisk user - or enter q to skip:"
read ps1
if ! [ "$ps1" = 'q' ] ; then
sed -i "s+secret=.*+secret=$ps1+g" "/etc/asterisk/sip.conf"
fi
fi
service asterisk stop
service asterisk start
service kurento-media-server stop
service kurento-media-server start