w.c.s : ajout d'un champ wcs_comments lors de l'extraction.
[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 nat=no
60 disallow=all
61 allow=ulaw
62 allow=gsm
63 allow=h264
64 allow=h263p
65 allow=h263
66 allow=h261
67 __EOF__
68
69 cat >> extensions.local.auto << __EOF__
70 ${COMMENTCHAR} ${FULLNAME}
71 exten => ${EXTEN},1,Macro(AUFDial,${USERNAME})
72 exten => ${USERNAME},1,Goto(${EXTEN},1)
73 __EOF__
74 if [ -n "${LOCALPREFIX}" ] ; then
75 cat >> extensions.local.auto << __EOF__
76 exten => ${LOCALPREFIX}${EXTEN},1,Macro(AUFDial,${USERNAME})
77 __EOF__
78 fi
79
80 cat >> voicemail.local.auto << __EOF__
81 ${COMMENTCHAR} ${FULLNAME}
82 ${LOCALPREFIX}${EXTEN} => -${VOICEMAILCODE},${CIDNAME},${USERNAME}@auf.org
83 __EOF__
84 done
85
86 rasterisk -x reload