[Asterisk-Users] Numbered Voicemails even with delete option!

David Waugh David.Waugh at eicon.com
Mon Mar 20 02:32:03 MST 2006


Hello,

Thought people might be interested in this.

I want my voicemails emailed to a person and not stored on my asterisk
server. However, I want them to have a sequential number. I found that
if I set the option delete=1 in my voicemail.conf file for the mailbox,
then the numbering would keep being restarted.

I wrote this shell script to fool Asterisk into numbering my voicemails
sequentially even though I delete them. The files asterisk required are
replced with 2 byte files with the same name. It's these files that
asterisk uses for numbering the voicemails.

In voicemail.conf change your voicemail user so that emails are no
longer deleted.

1234 => 4242,Eicon Support,voicemail

Here is the shell script. Watch out for line wraps!! This script should
be run as a cron job at whatever interval you like.

NOTE: This is my first shell script so I'm sure it can be improved!

*******************************************************
[root at centos INBOX]# more /etc/asterisk/voicemail-clean 

cd /var/spool/asterisk/voicemail/default/1234/INBOX

#Only move files that are not currently in use that are over 3 bytes
find /var/spool/asterisk/voicemail/default/1234/INBOX -mmin +1 -and
-size +3c -exec cp {}
 /tmp \;

#replace contents of these files with 0 to save space

#find /tmp -name 'msg*.*' -and -type f -exec echo 0 >{} \;

for i in /tmp/msg*.gsm
do
  echo 0 >$i
done

for i in /tmp/msg*.txt
do
  echo 0 >$i
done

if [ -f /tmp/msg\*.txt ]
then
  rm -f msg\\*.txt
  rm -f msg\\*.gsm
fi

#delete any wav or WAV files
rm -f /tmp/*.wav
rm -f /tmp/*.WAV

#Delete any files that are not currently being used
find /var/spool/asterisk/voicemail/default/1234/INBOX -mmin +1 -and
-type f -and -size +3
c -exec rm -f {} \;

#Copy our changed files back to the directory to fool asterisk!
cp -f /tmp/msg*.* /var/spool/asterisk/voicemail/default/1234/INBOX/
rm -rf /tmp/msg*.*
#Cleanup
rm -f /var/spool/asterisk/voicemail/default/1234/INBOX/msg\*.gsm
rm -f /var/spool/asterisk/voicemail/default/1234/INBOX/msg\*.txt

************************************************************************
***



More information about the asterisk-users mailing list