Dump Asterisk Realtime Voicemail users into Voicemail.conf
While I’ve been lazy about updating my site, I have not been lazy with writing new scripts and coming up with ideas to write about.
The first in the set that I’m going to make public is a script to dump your Asterisk Realtime Voicemail database users into a flat voicemail.conf file. I used this technique while troubleshooting to revert back to the standard setup while I was working on the realtime config.
#!/bin/bash function get_mailbox { mailbox=$( mysql -u dbuser --password=dbpass asterisk -e "select mailbox from voicemail_users where uniqueid = '$i'") mailbox=`echo $mailbox | awk '{print $2}'` } function get_password { password=$(mysql -u dbuser --password=dbpass asterisk -e "select password from voicemail_users where uniqueid = '$i'") password=`echo $password | awk '{print $2}'` } function get_fullname { name=$(mysql -u dbuser --password=dbpass asterisk -e "select fullname from voicemail_users where uniqueid = '$i'") name=`echo $name | awk '{print $2}'` } function get_email { email=$(mysql -u dbuser --password=dbpass asterisk -e "select email from voicemail_users where uniqueid = '$i'") email=`echo $email | awk '{print $2}'` } function write_file { echo "$mailbox => $password,$name,$email,,attach=yes|saycid=no|envelope=no|delete=no" >> /root/test_dump.txt } for (( i=1; i<=151; i++)) do get_mailbox get_password get_fullname get_email write_file done
