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