wcs-dynexport : intégration du basculement vers PostgreSQL (suite)
[progfou.git] / voip / asterisk-update.sh
CommitLineData
0ad0d6e8
P
1#!/bin/bash
2# asterisk-update.sh - outil de mise à jour des comptes asterisk
3# Copyright ©2010 Agence universitaire de la Francophonie
4# http://www.auf.org/
5# Licence : GNU General Public License, version 3
6# Auteur : Progfou <jean-christophe.andre@auf.org>
7# Création : 2008-01-23
8# Mise à jour : 2010-04-19
9
10WORKDIR="/etc/asterisk/auf"
11
12# cf /usr/share/doc/asterisk-config-auf-connexions/liste-serveurs
13GLOBALPREFIX="008441"
14LOCALPREFIX=""
15
16COMMENTCHAR=";"
17
18cd "$WORKDIR" || exit -1
19umask 0227
20for f in iax.local sip.local extensions.local voicemail.local
21do
22 echo "${COMMENTCHAR} Auto-generated file, don't edit!" > "${f}.auto"
23 chown root:asterisk "${f}.auto"
24 chmod 0440 "${f}.auto"
25done
26
27IFS=":"
28grep -v '^#' comptes.txt |
29while read EXTEN FULLNAME CIDNAME USERNAME SECRET VOICEMAILCODE REST
30do
31 cat >> iax.local.auto << __EOF__
32
33${COMMENTCHAR} ${FULLNAME}
34[${USERNAME}]
35type=friend
36callerid="${CIDNAME}" <${GLOBALPREFIX}${EXTEN}>
37mailbox=${LOCALPREFIX}${EXTEN}@AUF
38user=${USERNAME}
39secret=${SECRET}
40host=dynamic
41context=AUF
42disallow=all
43allow=ulaw
44allow=gsm
45__EOF__
46
47 cat >> sip.local.auto << __EOF__
48
49${COMMENTCHAR} ${FULLNAME}
50[${USERNAME}]
51type=friend
52callerid="${CIDNAME}" <${GLOBALPREFIX}${EXTEN}>
53mailbox=${LOCALPREFIX}${EXTEN}@AUF
54user=${USERNAME}
55secret=${SECRET}
56host=dynamic
57context=AUF
58call-limit=10
58cc55d8 59;busy-level=1
0ad0d6e8
P
60nat=no
61disallow=all
62allow=ulaw
63allow=gsm
64allow=h264
65allow=h263p
66allow=h263
67allow=h261
68__EOF__
69
70 cat >> extensions.local.auto << __EOF__
71${COMMENTCHAR} ${FULLNAME}
72exten => ${EXTEN},1,Macro(AUFDial,${USERNAME})
58cc55d8
P
73exten => ${EXTEN},hint,SIP/${USERNAME}&IAX2/${USERNAME}
74exten => ${USERNAME},1,Macro(AUFDial,${USERNAME})
75exten => ${USERNAME},hint,SIP/${USERNAME}&IAX2/${USERNAME}
0ad0d6e8
P
76__EOF__
77 if [ -n "${LOCALPREFIX}" ] ; then
78 cat >> extensions.local.auto << __EOF__
79exten => ${LOCALPREFIX}${EXTEN},1,Macro(AUFDial,${USERNAME})
58cc55d8 80exten => ${LOCALPREFIX}${EXTEN},hint,SIP/${USERNAME}&IAX2/${USERNAME}
0ad0d6e8
P
81__EOF__
82 fi
83
84 cat >> voicemail.local.auto << __EOF__
85${COMMENTCHAR} ${FULLNAME}
86${LOCALPREFIX}${EXTEN} => -${VOICEMAILCODE},${CIDNAME},${USERNAME}@auf.org
87__EOF__
88done
89
58cc55d8
P
90rasterisk -x "iax2 reload"
91rasterisk -x "sip reload"
92rasterisk -x "dialplan reload"
93rasterisk -x "module reload app_voicemail.so"