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