|
@@ -1,497 +0,0 @@
|
1
|
|
-#!/bin/bash
|
2
|
|
-#
|
3
|
|
-# .---. . .
|
4
|
|
-# | | |
|
5
|
|
-# |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
|
6
|
|
-# | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
|
7
|
|
-# ' ' --' --' -' - -' ' ' -' -' -' ' - --'
|
8
|
|
-#
|
9
|
|
-# Freedom in the Cloud
|
10
|
|
-#
|
11
|
|
-# SIP functions
|
12
|
|
-#
|
13
|
|
-# License
|
14
|
|
-# =======
|
15
|
|
-#
|
16
|
|
-# Copyright (C) 2014-2016 Bob Mottram <bob@freedombone.net>
|
17
|
|
-#
|
18
|
|
-# This program is free software: you can redistribute it and/or modify
|
19
|
|
-# it under the terms of the GNU Affero General Public License as published by
|
20
|
|
-# the Free Software Foundation, either version 3 of the License, or
|
21
|
|
-# (at your option) any later version.
|
22
|
|
-#
|
23
|
|
-# This program is distributed in the hope that it will be useful,
|
24
|
|
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
25
|
|
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
26
|
|
-# GNU Affero General Public License for more details.
|
27
|
|
-#
|
28
|
|
-# You should have received a copy of the GNU Affero General Public License
|
29
|
|
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
30
|
|
-
|
31
|
|
-VARIANTS=''
|
32
|
|
-
|
33
|
|
-IN_DEFAULT_INSTALL=0
|
34
|
|
-SHOW_ON_ABOUT=0
|
35
|
|
-
|
36
|
|
-SIP_SERVER_PASSWORD=
|
37
|
|
-SIP_PORT=5060
|
38
|
|
-SIP_TLS_PORT=5061
|
39
|
|
-
|
40
|
|
-TURN_PORT=3478
|
41
|
|
-TURN_TLS_PORT=5349
|
42
|
|
-TURN_NONCE=
|
43
|
|
-
|
44
|
|
-sip_variables=(ONION_ONLY
|
45
|
|
- MY_USERNAME
|
46
|
|
- SIP_PORT
|
47
|
|
- SIP_TLS_PORT
|
48
|
|
- SIP_SERVER_PASSWORD
|
49
|
|
- TURN_PORT
|
50
|
|
- TURN_TLS_PORT
|
51
|
|
- TURN_NONCE)
|
52
|
|
-
|
53
|
|
-function logging_on_sip {
|
54
|
|
- echo -n ''
|
55
|
|
-}
|
56
|
|
-
|
57
|
|
-function logging_off_sip {
|
58
|
|
- echo -n ''
|
59
|
|
-}
|
60
|
|
-
|
61
|
|
-function remove_user_sip {
|
62
|
|
- remove_username="$1"
|
63
|
|
- ${PROJECT_NAME}-rmsipuser ${remove_username}
|
64
|
|
-
|
65
|
|
- ${PROJECT_NAME}-pass -u $remove_username --rmapp sip
|
66
|
|
-
|
67
|
|
- # remove user from SIP TURN/STUN
|
68
|
|
- if [ -f /etc/turnserver/turnusers.txt ]; then
|
69
|
|
- sed -i "/${remove_username}:/d" /etc/turnserver/turnusers.txt
|
70
|
|
- fi
|
71
|
|
-}
|
72
|
|
-
|
73
|
|
-function add_user_sip {
|
74
|
|
- new_username="$1"
|
75
|
|
- new_user_password="$2"
|
76
|
|
-
|
77
|
|
- ${PROJECT_NAME}-pass -u $new_username -a sip -p "$new_user_password"
|
78
|
|
-
|
79
|
|
- SIP_EXTENSION=$(${PROJECT_NAME}-sipfreeext)
|
80
|
|
- ${PROJECT_NAME}-addsipuser -u $new_username -e $SIP_EXTENSION -p "$new_user_password"
|
81
|
|
- if [ ! "$?" = "0" ]; then
|
82
|
|
- echo '1'
|
83
|
|
- return
|
84
|
|
- fi
|
85
|
|
-
|
86
|
|
- # add user to the sipwitch group
|
87
|
|
- if [ -f /etc/sipwitch.conf ]; then
|
88
|
|
- chmod 600 /etc/shadow
|
89
|
|
- chmod 600 /etc/gshadow
|
90
|
|
- usermod -aG sipwitch $new_username
|
91
|
|
- chmod 0000 /etc/shadow
|
92
|
|
- chmod 0000 /etc/gshadow
|
93
|
|
- fi
|
94
|
|
-
|
95
|
|
- # add user for SIP STUN/TURN
|
96
|
|
- if [ -d /etc/turnserver ]; then
|
97
|
|
- if grep -q "DEFAULT_DOMAIN_NAME" $CONFIGURATION_FILE; then
|
98
|
|
- read_config_param "DEFAULT_DOMAIN_NAME"
|
99
|
|
- echo "${new_username}:${new_user_password}:${DEFAULT_DOMAIN_NAME}:authorized" >> /etc/turnserver/turnusers.txt
|
100
|
|
- fi
|
101
|
|
- fi
|
102
|
|
-
|
103
|
|
- echo '0'
|
104
|
|
-}
|
105
|
|
-
|
106
|
|
-function install_interactive_sip {
|
107
|
|
- echo -n ''
|
108
|
|
- APP_INSTALLED=1
|
109
|
|
-}
|
110
|
|
-
|
111
|
|
-function change_password_sip {
|
112
|
|
- curr_username="$1"
|
113
|
|
- new_user_password="$2"
|
114
|
|
-
|
115
|
|
- #${PROJECT_NAME}-pass -u "$curr_username" -a sip -p "$new_user_password"
|
116
|
|
-}
|
117
|
|
-
|
118
|
|
-function reconfigure_sip {
|
119
|
|
- echo -n ''
|
120
|
|
-}
|
121
|
|
-
|
122
|
|
-function upgrade_sip {
|
123
|
|
- # remove the original sipwitch daemon if it exists
|
124
|
|
- if [ -f /etc/init.d/sipwitch ]; then
|
125
|
|
- rm -f /etc/init.d/sipwitch
|
126
|
|
- fi
|
127
|
|
-}
|
128
|
|
-
|
129
|
|
-function backup_local_sip {
|
130
|
|
- if [ -f /etc/sipwitch.conf ]; then
|
131
|
|
- echo $"Backing up SIP settings"
|
132
|
|
- temp_backup_dir=/root/tempsipbackup
|
133
|
|
- if [ ! -d $temp_backup_dir ]; then
|
134
|
|
- mkdir -p $temp_backup_dir
|
135
|
|
- fi
|
136
|
|
- cp -f /etc/sipwitch.conf $temp_backup_dir
|
137
|
|
- backup_directory_to_usb $temp_backup_dir sip
|
138
|
|
- echo $"SIP settings backup complete"
|
139
|
|
- fi
|
140
|
|
-}
|
141
|
|
-
|
142
|
|
-function restore_local_sip {
|
143
|
|
- if [ -d $USB_MOUNT/backup/sip ]; then
|
144
|
|
- echo $"Restoring SIP settings"
|
145
|
|
- temp_restore_dir=/root/tempsip
|
146
|
|
- function_check restore_directory_from_usb
|
147
|
|
- restore_directory_from_usb $temp_restore_dir sip
|
148
|
|
- if [ -d $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup ]; then
|
149
|
|
- cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/sipwitch.conf /etc/sipwitch.conf
|
150
|
|
- else
|
151
|
|
- cp -f $temp_restore_dir/sipwitch.conf /etc/sipwitch.conf
|
152
|
|
- fi
|
153
|
|
- if [ ! "$?" = "0" ]; then
|
154
|
|
- rm -rf $temp_restore_dir
|
155
|
|
- function_check set_user_permissions
|
156
|
|
- set_user_permissions
|
157
|
|
- backup_unmount_drive
|
158
|
|
- exit 3679
|
159
|
|
- fi
|
160
|
|
- rm -rf $temp_restore_dir
|
161
|
|
- systemctl restart sipwitch
|
162
|
|
- echo $"Restore of SIP settings complete"
|
163
|
|
- fi
|
164
|
|
-}
|
165
|
|
-
|
166
|
|
-function backup_remote_sip {
|
167
|
|
- if [ -f /etc/sipwitch.conf ]; then
|
168
|
|
- echo $"Backing up SIP settings"
|
169
|
|
- temp_backup_dir=/root/tempsipbackup
|
170
|
|
- if [ ! -d $temp_backup_dir ]; then
|
171
|
|
- mkdir -p $temp_backup_dir
|
172
|
|
- fi
|
173
|
|
- cp -f /etc/sipwitch.conf $temp_backup_dir
|
174
|
|
- backup_directory_to_friend $temp_backup_dir sip
|
175
|
|
- echo $"Backup SIP settings complete"
|
176
|
|
- fi
|
177
|
|
-}
|
178
|
|
-
|
179
|
|
-function restore_remote_sip {
|
180
|
|
- temp_restore_dir=/root/tempsip
|
181
|
|
- function_check restore_directory_from_friend
|
182
|
|
- restore_directory_from_friend $temp_restore_dir sip
|
183
|
|
- if [ -d $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup ]; then
|
184
|
|
- cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/sipwitch.conf /etc/sipwitch.conf
|
185
|
|
- else
|
186
|
|
- cp -f $temp_restore_dir/sipwitch.conf /etc/sipwitch.conf
|
187
|
|
- fi
|
188
|
|
- if [ ! "$?" = "0" ]; then
|
189
|
|
- rm -rf $temp_restore_dir
|
190
|
|
- function_check set_user_permissions
|
191
|
|
- set_user_permissions
|
192
|
|
- backup_unmount_drive
|
193
|
|
- exit 3679
|
194
|
|
- fi
|
195
|
|
- rm -rf $temp_restore_dir
|
196
|
|
- systemctl restart sipwitch
|
197
|
|
-}
|
198
|
|
-
|
199
|
|
-function remove_sip {
|
200
|
|
- firewall_remove ${TURN_PORT}
|
201
|
|
- firewall_remove ${TURN_TLS_PORT} tcp
|
202
|
|
- firewall_remove ${SIP_PORT}
|
203
|
|
- firewall_remove ${SIP_TLS_PORT}
|
204
|
|
-
|
205
|
|
- function_check remove_onion_service
|
206
|
|
- remove_onion_service sip ${SIP_PORT}
|
207
|
|
-
|
208
|
|
- apt-get -yq remove --purge sipwitch
|
209
|
|
- apt-get -yq remove --purge turnserver
|
210
|
|
- if [ -f /etc/sipwitch.conf ]; then
|
211
|
|
- rm /etc/sipwitch.conf
|
212
|
|
- fi
|
213
|
|
- if [ -d /etc/turnserver ]; then
|
214
|
|
- rm -rf /etc/turnserver
|
215
|
|
- fi
|
216
|
|
- remove_completion_param install_sip
|
217
|
|
- remove_completion_param configure_firewall_for_turn
|
218
|
|
- remove_completion_param configure_firewall_for_sip4
|
219
|
|
-}
|
220
|
|
-
|
221
|
|
-function configure_firewall_for_turn {
|
222
|
|
- if [[ $ONION_ONLY != "no" ]]; then
|
223
|
|
- return
|
224
|
|
- fi
|
225
|
|
- firewall_add TURN ${TURN_PORT}
|
226
|
|
- firewall_add "TURN TLS" ${TURN_TLS_PORT} tcp
|
227
|
|
-}
|
228
|
|
-
|
229
|
|
-
|
230
|
|
-function configure_firewall_for_sip4 {
|
231
|
|
- if [[ $ONION_ONLY != "no" ]]; then
|
232
|
|
- return
|
233
|
|
- fi
|
234
|
|
- firewall_add SIP ${SIP_PORT}
|
235
|
|
- firewall_add "SIP TLS" ${SIP_TLS_PORT}
|
236
|
|
-}
|
237
|
|
-
|
238
|
|
-function update_sipwitch_daemon {
|
239
|
|
- if [ ! -f /etc/init.d/sipwitch ]; then
|
240
|
|
- return
|
241
|
|
- fi
|
242
|
|
-
|
243
|
|
- systemctl stop sipwitch
|
244
|
|
-
|
245
|
|
- # remove the original sipwitch daemon if it exists
|
246
|
|
- if [ -f /etc/init.d/sipwitch ]; then
|
247
|
|
- rm -f /etc/init.d/sipwitch
|
248
|
|
- fi
|
249
|
|
-
|
250
|
|
- # daemon
|
251
|
|
- echo '[Unit]' > /etc/systemd/system/sipwitch.service
|
252
|
|
- echo 'Description=GNU SIP Witch, a SIP telephony service daemon.' >> /etc/systemd/system/sipwitch.service
|
253
|
|
- echo 'After=network.target' >> /etc/systemd/system/sipwitch.service
|
254
|
|
- echo '' >> /etc/systemd/system/sipwitch.service
|
255
|
|
- echo '[Service]' >> /etc/systemd/system/sipwitch.service
|
256
|
|
- echo 'Type=simple' >> /etc/systemd/system/sipwitch.service
|
257
|
|
- echo 'Group=sipwitch' >> /etc/systemd/system/sipwitch.service
|
258
|
|
- echo 'PIDFile=/var/run/sipwitch/pidfile' >> /etc/systemd/system/sipwitch.service
|
259
|
|
- echo 'EnvironmentFile=-/etc/conf.d/sipwitch' >> /etc/systemd/system/sipwitch.service
|
260
|
|
- echo 'EnvironmentFile=-/etc/sipwitch.conf' >> /etc/systemd/system/sipwitch.service
|
261
|
|
- echo 'EnvironmentFile=-/etc/default/sipwitch' >> /etc/systemd/system/sipwitch.service
|
262
|
|
- echo 'ExecStartPre=-/bin/rm -f /var/run/sipwitch/control' >> /etc/systemd/system/sipwitch.service
|
263
|
|
- echo "ExecStart=/usr/sbin/sipw -f \$OPTIONS -P$SIP_PORT" >> /etc/systemd/system/sipwitch.service
|
264
|
|
- echo 'Restart=always' >> /etc/systemd/system/sipwitch.service
|
265
|
|
- echo 'NotifyAccess=main' >> /etc/systemd/system/sipwitch.service
|
266
|
|
- echo '' >> /etc/systemd/system/sipwitch.service
|
267
|
|
- echo '[Install]' >> /etc/systemd/system/sipwitch.service
|
268
|
|
- echo 'WantedBy=multi-user.target' >> /etc/systemd/system/sipwitch.service
|
269
|
|
-
|
270
|
|
- systemctl enable sipwitch
|
271
|
|
- systemctl daemon-reload
|
272
|
|
- systemctl start sipwitch
|
273
|
|
-}
|
274
|
|
-
|
275
|
|
-function install_sip_main {
|
276
|
|
- if [[ $(app_is_installed sip_main) == "1" ]]; then
|
277
|
|
- return
|
278
|
|
- fi
|
279
|
|
-
|
280
|
|
- apt-get -yq install sipwitch
|
281
|
|
-
|
282
|
|
- if [ -f $IMAGE_PASSWORD_FILE ]; then
|
283
|
|
- SIP_SERVER_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
|
284
|
|
- else
|
285
|
|
- if [ ! $SIP_SERVER_PASSWORD ]; then
|
286
|
|
- SIP_SERVER_PASSWORD="$(create_password ${MINIMUM_PASSWORD_LENGTH})"
|
287
|
|
- fi
|
288
|
|
- fi
|
289
|
|
-
|
290
|
|
- echo '<?xml version="1.0"?>' > /etc/sipwitch.conf
|
291
|
|
- echo '<sipwitch>' >> /etc/sipwitch.conf
|
292
|
|
- echo '<provision>' >> /etc/sipwitch.conf
|
293
|
|
-
|
294
|
|
- echo "<user id=\"$MY_USERNAME\">" >> /etc/sipwitch.conf
|
295
|
|
- echo '<extension>201</extension>' >> /etc/sipwitch.conf
|
296
|
|
- echo "<secret>$SIP_SERVER_PASSWORD</secret>" >> /etc/sipwitch.conf
|
297
|
|
- echo "<display>$MY_USERNAME 201</display>" >> /etc/sipwitch.conf
|
298
|
|
- echo '</user>' >> /etc/sipwitch.conf
|
299
|
|
-
|
300
|
|
- echo '</provision>' >> /etc/sipwitch.conf
|
301
|
|
- echo '<access>' >> /etc/sipwitch.conf
|
302
|
|
- echo '</access>' >> /etc/sipwitch.conf
|
303
|
|
- echo '<stack>' >> /etc/sipwitch.conf
|
304
|
|
- echo " <localnames>$DEFAULT_DOMAIN_NAME</localnames>" >> /etc/sipwitch.conf
|
305
|
|
- echo ' <mapped>200</mapped>' >> /etc/sipwitch.conf
|
306
|
|
- echo ' <threading>2</threading>' >> /etc/sipwitch.conf
|
307
|
|
- echo ' <interface>*</interface>' >> /etc/sipwitch.conf
|
308
|
|
- echo ' <dumping>false</dumping>' >> /etc/sipwitch.conf
|
309
|
|
- echo ' <system>system</system>' >> /etc/sipwitch.conf
|
310
|
|
- echo ' <anon>anonymous</anon>' >> /etc/sipwitch.conf
|
311
|
|
- echo '</stack>' >> /etc/sipwitch.conf
|
312
|
|
- echo '<timers>' >> /etc/sipwitch.conf
|
313
|
|
- echo ' <!-- ring every 4 seconds -->' >> /etc/sipwitch.conf
|
314
|
|
- echo ' <ring>4</ring>' >> /etc/sipwitch.conf
|
315
|
|
- echo ' <!-- call forward no answer after x rings -->' >> /etc/sipwitch.conf
|
316
|
|
- echo ' <cfna>4</cfna>' >> /etc/sipwitch.conf
|
317
|
|
- echo ' <!-- call reset to clear cid in stack, 6 seconds -->' >> /etc/sipwitch.conf
|
318
|
|
- echo ' <reset>6</reset>' >> /etc/sipwitch.conf
|
319
|
|
- echo '</timers>' >> /etc/sipwitch.conf
|
320
|
|
- echo '<!-- we have 2xx numbers plus space for external users -->' >> /etc/sipwitch.conf
|
321
|
|
- echo '<registry>' >> /etc/sipwitch.conf
|
322
|
|
- echo ' <prefix>200</prefix>' >> /etc/sipwitch.conf
|
323
|
|
- echo ' <range>100</range>' >> /etc/sipwitch.conf
|
324
|
|
- echo ' <keysize>77</keysize>' >> /etc/sipwitch.conf
|
325
|
|
- echo ' <mapped>200</mapped>' >> /etc/sipwitch.conf
|
326
|
|
- echo ' <!-- <realm>GNU Telephony</realm> -->' >> /etc/sipwitch.conf
|
327
|
|
- echo '</registry>' >> /etc/sipwitch.conf
|
328
|
|
- echo '<routing>' >> /etc/sipwitch.conf
|
329
|
|
- echo '</routing>' >> /etc/sipwitch.conf
|
330
|
|
- echo '</sipwitch>' >> /etc/sipwitch.conf
|
331
|
|
-
|
332
|
|
- sed -i 's|#PLUGINS=|PLUGINS=|g' /etc/default/sipwitch
|
333
|
|
- sed -i 's|PLUGINS=.*|PLUGINS="zeroconf subscriber forward"|g' /etc/default/sipwitch
|
334
|
|
- groupadd sipwitch
|
335
|
|
- chmod 600 /etc/shadow
|
336
|
|
- chmod 600 /etc/gshadow
|
337
|
|
- usermod -aG sipwitch $MY_USERNAME
|
338
|
|
- chmod 0000 /etc/shadow
|
339
|
|
- chmod 0000 /etc/gshadow
|
340
|
|
-
|
341
|
|
- SIP_ONION_HOSTNAME=$(add_onion_service sip ${SIP_PORT} ${SIP_PORT})
|
342
|
|
-
|
343
|
|
- ${PROJECT_NAME}-pass -u $MY_USERNAME -a sip -p "$SIP_SERVER_PASSWORD"
|
344
|
|
-
|
345
|
|
- function_check configure_firewall_for_sip4
|
346
|
|
- configure_firewall_for_sip4
|
347
|
|
- install_completed sip_main
|
348
|
|
-}
|
349
|
|
-
|
350
|
|
-function install_sip_turn {
|
351
|
|
- if [[ $(app_is_installed sip_turn) == "1" ]]; then
|
352
|
|
- return
|
353
|
|
- fi
|
354
|
|
-
|
355
|
|
- apt-get -yq install turnserver
|
356
|
|
-
|
357
|
|
- # create a nonce if needed
|
358
|
|
- if [ ! $TURN_NONCE ]; then
|
359
|
|
- TURN_NONCE="$(create_password 30)"
|
360
|
|
- fi
|
361
|
|
-
|
362
|
|
- function_check create_site_certificate
|
363
|
|
- create_site_certificate $DEFAULT_DOMAIN_NAME 'yes'
|
364
|
|
-
|
365
|
|
- echo '##' > /etc/turnserver/turnserver.conf
|
366
|
|
- echo '# TurnServer configuration file.' >> /etc/turnserver/turnserver.conf
|
367
|
|
- echo '#' >> /etc/turnserver/turnserver.conf
|
368
|
|
- echo '' >> /etc/turnserver/turnserver.conf
|
369
|
|
- echo '## Public IPv4 address of any relayed address (if not set, no relay for IPv4).' >> /etc/turnserver/turnserver.conf
|
370
|
|
- echo '## To have multiple address, separate addresses with a comma' >> /etc/turnserver/turnserver.conf
|
371
|
|
- echo '## (i.e. listen_address = { "172.16.0.1", "172.17.0.1" }).' >> /etc/turnserver/turnserver.conf
|
372
|
|
- echo "listen_address = { \"192.168.0.1\" }" >> /etc/turnserver/turnserver.conf
|
373
|
|
- echo '' >> /etc/turnserver/turnserver.conf
|
374
|
|
- echo '## Public IPv6 address of any relayed address (if not set, no relay for IPv6).' >> /etc/turnserver/turnserver.conf
|
375
|
|
- echo '## To have multiple address, separate address with a comma' >> /etc/turnserver/turnserver.conf
|
376
|
|
- echo '## (i.e. listen_addressv6 = { "2001:db8:1::1", "2001:db8:2::1" }).' >> /etc/turnserver/turnserver.conf
|
377
|
|
- echo "#listen_addressv6 = { \"2001:db8::1\" }" >> /etc/turnserver/turnserver.conf
|
378
|
|
- echo '' >> /etc/turnserver/turnserver.conf
|
379
|
|
- echo '## UDP listening port.' >> /etc/turnserver/turnserver.conf
|
380
|
|
- echo "udp_port = $TURN_PORT" >> /etc/turnserver/turnserver.conf
|
381
|
|
- echo '' >> /etc/turnserver/turnserver.conf
|
382
|
|
- echo '## TCP listening port.' >> /etc/turnserver/turnserver.conf
|
383
|
|
- echo "tcp_port = $TURN_PORT" >> /etc/turnserver/turnserver.conf
|
384
|
|
- echo '' >> /etc/turnserver/turnserver.conf
|
385
|
|
- echo '## TLS listening port.' >> /etc/turnserver/turnserver.conf
|
386
|
|
- echo "tls_port = $TURN_TLS_PORT" >> /etc/turnserver/turnserver.conf
|
387
|
|
- echo '' >> /etc/turnserver/turnserver.conf
|
388
|
|
- echo '## TLS support.' >> /etc/turnserver/turnserver.conf
|
389
|
|
- echo 'tls = true' >> /etc/turnserver/turnserver.conf
|
390
|
|
- echo '' >> /etc/turnserver/turnserver.conf
|
391
|
|
- echo '## DTLS support. It is an experimental feature and is not defined in TURN' >> /etc/turnserver/turnserver.conf
|
392
|
|
- echo '## standard.' >> /etc/turnserver/turnserver.conf
|
393
|
|
- echo 'dtls = false' >> /etc/turnserver/turnserver.conf
|
394
|
|
- echo '' >> /etc/turnserver/turnserver.conf
|
395
|
|
- echo '## Maximum allocation port number.' >> /etc/turnserver/turnserver.conf
|
396
|
|
- echo 'max_port = 65535' >> /etc/turnserver/turnserver.conf
|
397
|
|
- echo '' >> /etc/turnserver/turnserver.conf
|
398
|
|
- echo '## Minimum allocation port number.' >> /etc/turnserver/turnserver.conf
|
399
|
|
- echo '' >> /etc/turnserver/turnserver.conf
|
400
|
|
- echo 'min_port = 49152' >> /etc/turnserver/turnserver.conf
|
401
|
|
- echo '' >> /etc/turnserver/turnserver.conf
|
402
|
|
- echo '## TURN-TCP support.' >> /etc/turnserver/turnserver.conf
|
403
|
|
- echo '' >> /etc/turnserver/turnserver.conf
|
404
|
|
- echo 'turn_tcp = true' >> /etc/turnserver/turnserver.conf
|
405
|
|
- echo '' >> /etc/turnserver/turnserver.conf
|
406
|
|
- echo '## TURN-TCP buffering mode:' >> /etc/turnserver/turnserver.conf
|
407
|
|
- echo '## - true, use userspace buffering;' >> /etc/turnserver/turnserver.conf
|
408
|
|
- echo '## - false, use kernel buffering.' >> /etc/turnserver/turnserver.conf
|
409
|
|
- echo 'tcp_buffer_userspace = true' >> /etc/turnserver/turnserver.conf
|
410
|
|
- echo '' >> /etc/turnserver/turnserver.conf
|
411
|
|
- echo '## TURN-TCP maximum buffer size.' >> /etc/turnserver/turnserver.conf
|
412
|
|
- echo 'tcp_buffer_size = 32768' >> /etc/turnserver/turnserver.conf
|
413
|
|
- echo '' >> /etc/turnserver/turnserver.conf
|
414
|
|
- echo '## Daemon mode.' >> /etc/turnserver/turnserver.conf
|
415
|
|
- echo 'daemon = true' >> /etc/turnserver/turnserver.conf
|
416
|
|
- echo '' >> /etc/turnserver/turnserver.conf
|
417
|
|
- echo '## Unprivileged user.' >> /etc/turnserver/turnserver.conf
|
418
|
|
- echo '## If you want to use this feature create a system user.' >> /etc/turnserver/turnserver.conf
|
419
|
|
- echo '## On Linux: adduser --system --group turnserver' >> /etc/turnserver/turnserver.conf
|
420
|
|
- echo 'unpriv_user = turnserver' >> /etc/turnserver/turnserver.conf
|
421
|
|
- echo '' >> /etc/turnserver/turnserver.conf
|
422
|
|
- echo '## Realm value.' >> /etc/turnserver/turnserver.conf
|
423
|
|
- echo "realm = \"$DEFAULT_DOMAIN_NAME\"" >> /etc/turnserver/turnserver.conf
|
424
|
|
- echo '' >> /etc/turnserver/turnserver.conf
|
425
|
|
- echo '## Nonce key.' >> /etc/turnserver/turnserver.conf
|
426
|
|
- echo "nonce_key = \"$TURN_NONCE\"" >> /etc/turnserver/turnserver.conf
|
427
|
|
- echo '' >> /etc/turnserver/turnserver.conf
|
428
|
|
- echo '## Max relay per username.' >> /etc/turnserver/turnserver.conf
|
429
|
|
- echo 'max_relay_per_username = 5' >> /etc/turnserver/turnserver.conf
|
430
|
|
- echo '' >> /etc/turnserver/turnserver.conf
|
431
|
|
- echo '## Allocation lifetime.' >> /etc/turnserver/turnserver.conf
|
432
|
|
- echo 'allocation_lifetime = 1800' >> /etc/turnserver/turnserver.conf
|
433
|
|
- echo '' >> /etc/turnserver/turnserver.conf
|
434
|
|
- echo '## Allocation bandwidth limitation (in KBytes/s).' >> /etc/turnserver/turnserver.conf
|
435
|
|
- echo '## 0 value means bandwidth quota disabled.' >> /etc/turnserver/turnserver.conf
|
436
|
|
- echo 'bandwidth_per_allocation = 150' >> /etc/turnserver/turnserver.conf
|
437
|
|
- echo '' >> /etc/turnserver/turnserver.conf
|
438
|
|
- echo '## Restricted user bandwidth (in KBytes/s).' >> /etc/turnserver/turnserver.conf
|
439
|
|
- echo '## 0 value means bandwidth limitation disabled.' >> /etc/turnserver/turnserver.conf
|
440
|
|
- echo 'restricted_bandwidth = 10' >> /etc/turnserver/turnserver.conf
|
441
|
|
- echo '' >> /etc/turnserver/turnserver.conf
|
442
|
|
- echo '## Denied addresses.' >> /etc/turnserver/turnserver.conf
|
443
|
|
- echo '' >> /etc/turnserver/turnserver.conf
|
444
|
|
- echo '# disallow relaying to localhost' >> /etc/turnserver/turnserver.conf
|
445
|
|
- echo 'denied_address {' >> /etc/turnserver/turnserver.conf
|
446
|
|
- echo ' address = "127.0.0.1"' >> /etc/turnserver/turnserver.conf
|
447
|
|
- echo ' mask = "8"' >> /etc/turnserver/turnserver.conf
|
448
|
|
- echo ' port = 0' >> /etc/turnserver/turnserver.conf
|
449
|
|
- echo '}' >> /etc/turnserver/turnserver.conf
|
450
|
|
- echo '' >> /etc/turnserver/turnserver.conf
|
451
|
|
- echo '# disallow relaying to ip6-localhost' >> /etc/turnserver/turnserver.conf
|
452
|
|
- echo 'denied_address {' >> /etc/turnserver/turnserver.conf
|
453
|
|
- echo ' address = "::1"' >> /etc/turnserver/turnserver.conf
|
454
|
|
- echo ' mask = "128"' >> /etc/turnserver/turnserver.conf
|
455
|
|
- echo ' port = 0' >> /etc/turnserver/turnserver.conf
|
456
|
|
- echo '}' >> /etc/turnserver/turnserver.conf
|
457
|
|
- echo '' >> /etc/turnserver/turnserver.conf
|
458
|
|
- echo '## Certification Authority file.' >> /etc/turnserver/turnserver.conf
|
459
|
|
- echo "ca_file = \"/etc/ssl/certs/ca-certificates.crt\"" >> /etc/turnserver/turnserver.conf
|
460
|
|
- echo '' >> /etc/turnserver/turnserver.conf
|
461
|
|
- echo '## Server certificate file.' >> /etc/turnserver/turnserver.conf
|
462
|
|
- if [ -f /etc/ssl/certs/$DEFAULT_DOMAIN_NAME.pem ]; then
|
463
|
|
- echo "cert_file = \"/etc/ssl/certs/$DEFAULT_DOMAIN_NAME.pem\"" >> /etc/turnserver/turnserver.conf
|
464
|
|
- else
|
465
|
|
- if [ -f /etc/ssl/certs/$DEFAULT_DOMAIN_NAME.crt ]; then
|
466
|
|
- echo "cert_file = \"/etc/ssl/certs/$DEFAULT_DOMAIN_NAME.crt\"" >> /etc/turnserver/turnserver.conf
|
467
|
|
- fi
|
468
|
|
- fi
|
469
|
|
- echo '' >> /etc/turnserver/turnserver.conf
|
470
|
|
- echo '## Private key file.' >> /etc/turnserver/turnserver.conf
|
471
|
|
- echo "private_key_file = \"/etc/ssl/certs/$DEFAULT_DOMAIN_NAME.key\"" >> /etc/turnserver/turnserver.conf
|
472
|
|
- echo '' >> /etc/turnserver/turnserver.conf
|
473
|
|
- echo '## Account method.' >> /etc/turnserver/turnserver.conf
|
474
|
|
- echo "account_method = \"file\"" >> /etc/turnserver/turnserver.conf
|
475
|
|
- echo '' >> /etc/turnserver/turnserver.conf
|
476
|
|
- echo '## Account file (if account_method = file).' >> /etc/turnserver/turnserver.conf
|
477
|
|
- echo "account_file = \"/etc/turnserver/turnusers.txt\"" >> /etc/turnserver/turnserver.conf
|
478
|
|
- echo '' >> /etc/turnserver/turnserver.conf
|
479
|
|
- echo '## mod_tmpuser.' >> /etc/turnserver/turnserver.conf
|
480
|
|
- echo 'mod_tmpuser = false' >> /etc/turnserver/turnserver.conf
|
481
|
|
-
|
482
|
|
- echo "${MY_USERNAME}:password:${DEFAULT_DOMAIN_NAME}:authorized" > /etc/turnserver/turnusers.txt
|
483
|
|
-
|
484
|
|
- systemctl restart turnserver
|
485
|
|
-
|
486
|
|
- function_check configure_firewall_for_turn
|
487
|
|
- configure_firewall_for_turn
|
488
|
|
- install_completed sip_turn
|
489
|
|
-}
|
490
|
|
-
|
491
|
|
-function install_sip {
|
492
|
|
- install_sip_main
|
493
|
|
- update_sipwitch_daemon
|
494
|
|
- APP_INSTALLED=1
|
495
|
|
-}
|
496
|
|
-
|
497
|
|
-# NOTE: deliberately no exit 0
|