OK, this is the script called from externnotify. Basically externnotify calls the script and passes the context, extension, and number of new messages every time someone accesses their voicemail. So if I left a message on extension 12, it would pass "default, 12, 1" to the script. The script keeps a log at /var/log/asterisk/mwi, so be sure to rotate that log if you leave it enabled.
#!/bin/bash
MAILBOX=$2
MESSAGES=$3
if [ "$MAILBOX" -gt 50 ]; then
echo "Not an Avaya phone on extension $MAILBOX - exiting" >> /var/log/asterisk/mwi
exit
fi
if [ "$MESSAGES" -gt 0 ]; then
echo "Turning on mwi on $MAILBOX" >> /var/log/asterisk/mwi
echo "Channel: Zap/g0/#09$MAILBOX" > $MAILBOX.call
else
echo "Turning off mwi on $MAILBOX" >> /var/log/asterisk/mwi
echo "Channel: Zap/g0/#10$MAILBOX" > $MAILBOX.call
fi
echo "MaxRetries: 2" >> $MAILBOX.call
echo "RetryTime: 60" >> $MAILBOX.call
echo "WaitTime: 30" >> $MAILBOX.call
echo "Context: custom-vmnotify" >> $MAILBOX.call
echo "Extension: s" >> $MAILBOX.call
echo "Priority: 1" >> $MAILBOX.call
echo "Archive: yes" >> $MAILBOX.call
chown asterisk.asterisk $MAILBOX.call
mv -f $MAILBOX.call /var/spool/asterisk/outgoing/
Also I added this to my extensions.conf:
[custom-vmnotify] ; for mwi.sh script
exten => s,1,Wait(5)
exten => s,2,Hangup
Hope that helps anyone looking to do the same thing. I would also warn that Kumba's advice on the subject is right on the money (except for mixing Tylenol and high-proof - bad for the liver). The concept of an open source replacement for Amanda, Duovoice, or any other pc based voicemail is pretty compelling but Asterisk has a ways to go before this is anything close to "turnkey".