Update addmailbox script (bug #404)
[asterisk/asterisk.git] / contrib / scripts / addmailbox
1 #!/bin/sh
2 clear
3 VMHOME=/var/spool/asterisk/voicemail
4 SNDHOME=/var/lib/asterisk/sounds
5 echo
6 echo "Enter Voicemail Context of the mailbox you are creating."
7 echo "The context is the value between the square brackets in"
8 echo "the voicemail.conf file."
9 echo "(DEFAULT: default)"
10 echo -n "Voicemail Context: "
11 read context
12 echo
13 echo "Enter the Mailbox number of the voicemail box you are creating." 
14 echo -n "Mailbox Number: "
15 read mailbox
16
17 context=${context:-default}
18
19 if [ ! -e "${VMHOME}/${context}" ]
20         then
21         echo
22         echo "New Voicemail context.."
23         echo "Creating Voicemail context directory..."
24         mkdir -p ${VMHOME}/${context}
25 fi
26
27 echo
28 echo "Creating Voicemail directory..." 
29 mkdir -p ${VMHOME}/${context}/${mailbox}
30 echo "Creating INBOX..."
31 mkdir -p ${VMHOME}/${context}/${mailbox}/INBOX
32 echo "Creating Default greetings..."
33 cat ${SNDHOME}/vm-theperson.gsm > ${VMHOME}/${context}/${mailbox}/unavail.gsm
34 cat ${SNDHOME}/vm-theperson.gsm > ${VMHOME}/${context}/${mailbox}/busy.gsm
35 cat ${SNDHOME}/vm-extension.gsm > ${VMHOME}/${context}/${mailbox}/greet.gsm
36 nums=`echo $mailbox | sed 's/./ \0/g'`
37 for x in $nums; do
38         cat ${SNDHOME}/digits/${x}.gsm >> ${VMHOME}/${context}/${mailbox}/unavail.gsm
39         cat ${SNDHOME}/digits/${x}.gsm >> ${VMHOME}/${context}/${mailbox}/busy.gsm
40         cat ${SNDHOME}/digits/${x}.gsm >> ${VMHOME}/${context}/${mailbox}/greet.gsm
41 done
42 cat ${SNDHOME}/vm-isunavail.gsm >> ${VMHOME}/${context}/${mailbox}/unavail.gsm
43 cat ${SNDHOME}/vm-isonphone.gsm >> ${VMHOME}/${context}/${mailbox}/busy.gsm
44 echo "Complete."
45