#!/bin/sh
echo ""
echo "--------------------------------------------------------------"
echo "Creating a default config file for Aastra phones"
echo "--------------------------------------------------------------"
echo ""
echo "Creating /tftpboot/aastra.cfg..."
echo ""

IFCONFIG=`which ifconfig 2>/dev/null||echo /sbin/ifconfig`
IPADDR=`$IFCONFIG eth0|gawk '/inet addr/{print $2}'|gawk -F: '{print $2}'`

cat > /tftpboot/aastra.cfg <<EOF
#aastra default config file
time server disabled: 0
time server1: $IPADDR

sip proxy ip: $IPADDR
sip proxy port: 5060
sip registrar ip: $IPADDR
sip registrar port: 5060

sip digit timeout: 6

xml application post list: $IPADDR

softkey1 type: speeddial
softkey1 label: "Voice Mail"
softkey1 value: *97

softkey2 type: speeddial
softkey2 label: "DND On"
softkey2 value: *78

softkey3 type: speeddial
softkey3 label: "DND Off"
softkey3 value: *79
EOF

chmod 666 /tftpboot/aastra.cfg

echo "Created /tftpboot/aastra.cfg using $IPADDR for the proxy. If the"
echo "IP address of your Asterisk system changes run this script again and reboot."
echo "Reboot your Aastra phones by disconnectiong the power to the phone."
echo ""
