#!/bin/bash
asteridex="/var/www/html/asteridex4" # Set the location of your AsteriDex4 application here!
echo "Installing FONmail for Asterisk. Please wait..."
echo " "
if [ -d "$asteridex" ]
then
echo "$asteridex found. AsteriDex4 appears to be installed. Proceeding..."
echo " "
else
echo "ERROR: $asteridex directory not found."
echo "You must first install AsteriDex4 on your system."
echo "If you have moved the default location, please modify the location in this script."
echo "Then rerun the script to continue."
exit
fi
echo "Decompressing FONmail archive..."
FONmail="/root/FONmail"
cd /root
if [ -d "$FONmail" ]
then
echo "Existing FONmail installation folder found. Proceeding..."
else
echo "Creating FONmail installation folder: /root/FONmail. Proceeding..."
mkdir FONmail
fi
cd FONmail
echo "Downloading FONmail tarball..."
wget http://bestof.nerdvittles.com/applications/FONmail/FONmail.tgz
tar zxvf FONmail.tgz
echo "Done. "
echo " "
echo "Modifying AsteriDex database table to support email addresses..."
mysql -uroot -ppassw0rd asteridex <> /etc/asterisk/extensions_custom.conf
sed -i '
/\[from-internal-custom\]/ {
a\
exten => 412,1,Answer\
exten => 412,2,Wait(1)\
exten => 412,3,Set(TIMEOUT(digit)=7)\
exten => 412,4,Set(TIMEOUT(response)=10)\
exten => 412,5,GotoIf($[${STAT(e,\/usr\/bin\/swift)}]?8)\
exten => 412,6,Flite(\"At the beep enter the first three letters of the name of the person you wish to contact.\")\
exten => 412,7,Goto(s,9)\
exten => 412,8,Swift(\"At the beep enter the first three letters of the name of the person you wish to contact.\")\
exten => 412,9,Read(DIALCODE,beep,3)\
exten => 412,10,NoOp(Name lookup: ${DIALCODE})\
exten => 412,11,AGI(nv-callwho.php,${DIALCODE})\
exten => 412,12,NoOp(Number to call: ${NUM2CALL})\
exten => 412,13,GotoIf($[\"foo${NUM2CALL}\" = \"foo0\"]?15)\
exten => 412,14,Goto(outbound-allroutes,${NUM2CALL},1)\
exten => 412,15,Wait(1)\
exten => 412,16,Hangup\
}' /etc/asterisk/extensions_custom.conf
echo "Done."
echo " "
echo "Reloading Asterisk dialplan..."
asterisk -rx "dialplan reload"
echo "Done."
echo " "
echo "Using your web browser, you need to access FreePBX now."
echo "NOTE: With version 2.3 of FreePBX, the Custom Destination step is not required."
echo "Choose Tools, Custom Destinations and Add Custom Destination."
echo "Custom Destination: custom-mailit,s,1"
echo "Description: FONmail"
echo " "
echo "Click Submit Changes and then Apply Configuration Changes and Continue With Reload."
echo " "
echo "Next choose Admin, Misc Applications and Add a new Misc. Application."
echo "Description: FONmail"
echo "Feature Code: 6245 (which spells M-A-I-L)"
echo "Feature Status: Enabled"
echo "Destination:"
echo "Custom Destination(FreePBX 2.4) or Custom App(FreePBX 2.3): custom-mailit,s,1"
echo " "
echo "Click Submit Changes and then Apply Configuration Changes and Continue With Reload."
echo " "
echo " "
echo "For complete documentation, visit http://nerdvittles.com/index.php?p=229"