David Waugh
2006-Mar-20 02:32 UTC
[Asterisk-Users] Numbered Voicemails even with delete option!
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@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 ************************************************************************ ***
trixter aka Bret McDanel
2006-Mar-20 03:20 UTC
[Asterisk-Users] Numbered Voicemails even with delete option!
On Mon, 2006-03-20 at 09:32 +0000, David Waugh wrote:> NOTE: This is my first shell script so I'm sure it can be improved! >noted, in that spirit see notes below ...> ******************************************************* > [root@centos INBOX]# more /etc/asterisk/voicemail-clean > > cd /var/spool/asterisk/voicemail/default/1234/INBOX >this appears to be redundant since you specify the full path in the find below ... It doesnt hurt anything though.> #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 \; >why cp em to /tmp? Seems a waste given what you do with the files in /tmp later...> #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 >after putting a 0\n in each file you then rm it without doing anything else ... Why waste the time copying them earlier, then making the files contain only 0\n just to rm em?> #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*.*But if those exited they were deleted above ...> #Cleanup > rm -f /var/spool/asterisk/voicemail/default/1234/INBOX/msg\*.gsm > rm -f /var/spool/asterisk/voicemail/default/1234/INBOX/msg\*.txt >If by some chance they were able to survive the previous copies, deletes, then copied again, you make sure they dont survive any further :) how about this, would it do what you want (note I am basically using what you started out with) It also makes em 0 bytes instead of 2 :) And it works on more than one user at a time, although that may not be desired. The size +3c may need to be altered since it wont have 2 bytes, but it shouldnt hurt anything to leave it, I left it becuase that is what you started out doing, although for other reasons. touch /tmp/vm.$$ for i in /var/spool/asterisk/voicemail/default/*; do find $i/INBOX -mmin +1 -and -size +3c -and -name \*.wav \ -exec rm {} \; find $i/INBOX -mmin +1 -and -size +3c -and -name \*.WAV \ -exec rm {} \; find $i/INBOX -mmin +1 -and -size +3c \ -exec cp -f /tmp/vm.$$ {} \; done rm /tmp/vm.$$ This of course could still be optimized further, but to keep it simple I decided to use what you originally did as a base... app_voicemail can detect a gap in the sequencing between any rm and creation of a replacement file, so I create a dummy file in /tmp then cp that over the desired file to avoid that. find is not that processor friendly so you will want to watch out if you have a large number of users/voicemails. I also dont see that big of a point in doing this, after how many years and hundreds of thousands of voicemails that a user has listened to do you finally reset that number? or do you want a life count forever? Further the way app_voicemail works the larger that directory is the more processing that is required to find the next available sequence number ... -- Trixter http://www.0xdecafbad.com Bret McDanel Belfast IE +44 28 9099 6461 DE +49 801 777 555 3402 Utrecht NL +31 306 553058 US WA +1 360 207 0479 US NY +1 516 687 5200 FreeWorldDialup: 635378 http://www.sacaug.org/ Sacramento Asterisk Users Group -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part Url : http://lists.digium.com/pipermail/asterisk-users/attachments/20060320/bae2f31b/attachment.pgp
David Waugh
2006-Mar-20 04:49 UTC
[Asterisk-Users] Numbered Voicemails even with delete option!
Thanks Bret for the input. Your solution seems a lot neater=) I had problems with "globbing" I think it is called. I kept getting files name being created called "msg*.txt" which caused me problems later. I think your way removes this. The reason I was doing this was for testing purposes. I was making many thousands of calls to the asterisk server as a stress test, and then emailing them across. - Nothing really useful in the real world. -----Original Message----- From: asterisk-users-bounces@lists.digium.com [mailto:asterisk-users-bounces@lists.digium.com] On Behalf Of trixter aka Bret McDanel Sent: 20 March 2006 10:21 To: Asterisk Users Mailing List - Non-Commercial Discussion Subject: Re: [Asterisk-Users] Numbered Voicemails even with delete option! On Mon, 2006-03-20 at 09:32 +0000, David Waugh wrote:> NOTE: This is my first shell script so I'm sure it can be improved! >noted, in that spirit see notes below ...> ******************************************************* > [root@centos INBOX]# more /etc/asterisk/voicemail-clean > > cd /var/spool/asterisk/voicemail/default/1234/INBOX >this appears to be redundant since you specify the full path in the find below ... It doesnt hurt anything though.> #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 \; >why cp em to /tmp? Seems a waste given what you do with the files in /tmp later...> #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 >after putting a 0\n in each file you then rm it without doing anything else ... Why waste the time copying them earlier, then making the files contain only 0\n just to rm em?> #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*.*But if those exited they were deleted above ...> #Cleanup > rm -f /var/spool/asterisk/voicemail/default/1234/INBOX/msg\*.gsm > rm -f /var/spool/asterisk/voicemail/default/1234/INBOX/msg\*.txt >If by some chance they were able to survive the previous copies, deletes, then copied again, you make sure they dont survive any further :) how about this, would it do what you want (note I am basically using what you started out with) It also makes em 0 bytes instead of 2 :) And it works on more than one user at a time, although that may not be desired. The size +3c may need to be altered since it wont have 2 bytes, but it shouldnt hurt anything to leave it, I left it becuase that is what you started out doing, although for other reasons. touch /tmp/vm.$$ for i in /var/spool/asterisk/voicemail/default/*; do find $i/INBOX -mmin +1 -and -size +3c -and -name \*.wav \ -exec rm {} \; find $i/INBOX -mmin +1 -and -size +3c -and -name \*.WAV \ -exec rm {} \; find $i/INBOX -mmin +1 -and -size +3c \ -exec cp -f /tmp/vm.$$ {} \; done rm /tmp/vm.$$ This of course could still be optimized further, but to keep it simple I decided to use what you originally did as a base... app_voicemail can detect a gap in the sequencing between any rm and creation of a replacement file, so I create a dummy file in /tmp then cp that over the desired file to avoid that. find is not that processor friendly so you will want to watch out if you have a large number of users/voicemails. I also dont see that big of a point in doing this, after how many years and hundreds of thousands of voicemails that a user has listened to do you finally reset that number? or do you want a life count forever? Further the way app_voicemail works the larger that directory is the more processing that is required to find the next available sequence number ... -- Trixter http://www.0xdecafbad.com Bret McDanel Belfast IE +44 28 9099 6461 DE +49 801 777 555 3402 Utrecht NL +31 306 553058 US WA +1 360 207 0479 US NY +1 516 687 5200 FreeWorldDialup: 635378 http://www.sacaug.org/ Sacramento Asterisk Users Group
Hi, Has anyone had experience installing AMP/FreePBX on Asterisk Business Edition? The main issue we have come across is FreePBX requires a dependency "PHP-PEAR" &"PHP-GD" which is not available on RedHat RHEL3 (ES) Thanks James
James Sturges wrote:> Hi, > > Has anyone had experience installing AMP/FreePBX on Asterisk Business > Edition? > > The main issue we have come across is FreePBX requires a dependency > "PHP-PEAR" &"PHP-GD" which is not available on RedHat RHEL3 (ES) > > Thanks > > James > > _______________________________________________ > --Bandwidth and Colocation provided by Easynews.com -- > > Asterisk-Users mailing list > To UNSUBSCRIBE or update options visit: > http://lists.digium.com/mailman/listinfo/asterisk-usersgoogle is your friend.... http://us3.php.net/gd http://pear.php.net/ -- . -----BEGIN GEEK CODE BLOCK----- Version: 3.1 GCS/GIT> d-@ s+:+ a? C+++ BLHIS$ U+++ P+> L+++ !E W+++$ N++ o+ K w-- PS+++ PE@ Y+ PGP++ t 5? X !R tv+ b- DI-- D G e+> h---- r+++ y++++ ------END GEEK CODE BLOCK------ . -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: OpenPGP digital signature Url : http://lists.digium.com/pipermail/asterisk-users/attachments/20060320/f9c22ab4/signature.pgp
Google is a good friend, unfortunately the system admin who represent the company we are installing is not so. They a requiring an audited stable platform, aka Asterisk Business Edition. So when we say we need to install non-certified package onto their Enterprise Server, they say na! Thanks James -----Original Message----- From: asterisk-users-bounces@lists.digium.com [mailto:asterisk-users-bounces@lists.digium.com] On Behalf Of Derek Whitten Sent: Monday, 20 March 2006 11:19 PM To: Asterisk Users Mailing List - Non-Commercial Discussion Subject: Re: [Asterisk-Users] AMP and ABE James Sturges wrote:> Hi, > > Has anyone had experience installing AMP/FreePBX on Asterisk Business > Edition? > > The main issue we have come across is FreePBX requires a dependency > "PHP-PEAR" &"PHP-GD" which is not available on RedHat RHEL3 (ES) > > Thanks > > James > > _______________________________________________ > --Bandwidth and Colocation provided by Easynews.com -- > > Asterisk-Users mailing list > To UNSUBSCRIBE or update options visit: > http://lists.digium.com/mailman/listinfo/asterisk-usersgoogle is your friend.... http://us3.php.net/gd http://pear.php.net/ -- . -----BEGIN GEEK CODE BLOCK----- Version: 3.1 GCS/GIT> d-@ s+:+ a? C+++ BLHIS$ U+++ P+> L+++ !E W+++$ N++ o+ K w-- PS+++ PE@ Y+ PGP++ t 5? X !R tv+ b- DI-- D G e+> h---- r+++ y++++ ------END GEEK CODE BLOCK------ .