#!/bin/sh
echo ""
echo "--------------------------------------------------------------"
echo "Creating a default config file for Grandstream GXP2000 phones"
echo "--------------------------------------------------------------"

yum -y install jre nmap gapslite GXP2000
if [ -x /usr/java/jre1.5.0_07/bin/java ]
then
  if [ ! -x /usr/local/bin/java ]
  then
    ln -s /usr/java/jre1.5.0_07/bin/java /usr/local/bin/java
  fi
else
  if [[ `which java` != *java ]]
  then
    say "WARNING: java executable may not be in the PATH"
  fi
fi

################################################################################################
##GXP2000#######################################################################################
################################################################################################
################################################################################################

echo ""
echo "Creating /tftpboot/Grandstream_GXP2000_Default.txt..."
echo ""

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

cat > /tftpboot/Grandstream_GXP2000_Default.txt <<EOF

# default settings

# SIP Server
P47 = $IPADDR

# Outbound Proxy
P48 = $IPADDR

################################################################################################
## Configuration template for GXP-2000 firmware version 1.1.0.16
################################################################################################

##############################################################################
##  Advanced/System-wide Options
##############################################################################

# Password for configuration file authentication
P1 = 

# Admin password for web interface
P2 = admin

# Silence Suppression. 0 - no, 1 - yes
P50 = 0

# Voice Frames per TX (up to 10/20/32/64 frames for G711/G726/G723/other codecs respectively)
P37 = 2

# Layer 3 QoS (IP Diff-Serv or Precedence value for RTP)
P38 = 48

# Layer 2 QoS. 802.1Q/VLAN Tag (VLAN classification for RTP)
P51 = 0

# Layer 2 QoS. 802.1p priority value (0 - 7)
P87 = 0

# No Key Entry Timeout. Default - 4 seconds.
P85 = 4

# Use # as Dial Key (if set to Yes, "#" will function as the "(Re-)Dial" key). 0 - no, 1 - yes
P72 = 1

# Local RTP port (1024-65535, default 5004)
P39 = 5004 

# Use Random Port. 0 - no, 1 - yes
P78 = 0

# Keep-alive interval (in seconds. default 20 seconds)
P84 = 20

# Use NAT IP.  This will enable our SIP client to use this IP in the SIP message. Example 64.3.153.50.
P101 =

# STUN server
P76 =

#-------------------------------------------------------------
# Firmware Upgrade 
#-------------------------------------------------------------

# Firmware Upgrade. 0 - TFTP Upgrade,  1 - HTTP Upgrade.
P212 = 0

# Firmware Server Path
P192 = $IPADDR

# Config Server Path
P237 = $IPADDR

# Firmware File Prefix
P232 =

# Firmware File Postfix
P233 =

# Config File Prefix
P234 =

# Config File Postfix
P235 =

# Allow DHCP Option 66 to override server. 0 - No, 1 - Yes. Default is No.
# When set to Yes(1), it will override the configured provision path and method.
P145 = 0

# Automatic Upgrade. 0 - No, 1 - Yes (checking every defined days). Default is No.
P194 = 1

# Check for new firmware every () minutes, unit is in minute, default is 7 days.
P193 = 1440

# Use firmware pre/postfix to determine if f/w is required
# 0 = Always Check for New Firmware 
# 1 = Check New Firmware only when F/W pre/suffix changes 
P238 = 0

# Authenticate Conf File
P240 = 0

# DTMF Payload Type
P79 = 101

# Syslog Server (name of the server, max length is 64 charactors)
P207 = 

# Syslog Level (Default setting is NONE)
# 0 - NONE, 1 - DEBUG, 2 - INFO, 3 - WARNING, 4 - ERROR
P208 = 0

# NTP Server
P30 = time.nist.gov

# Allow DHCP Option 42 to override NTP server. 0 - No, 1 - Yes. Default is No.
# When set to Yes(1), it will override the configured NTP server.
P144 = 0

# Distinctive Ring Tone
# Use custom ring tone 1 if incoming caller ID is the following:
P105 =

# Use custom ring tone 2 if incoming caller ID is the following:
P106 =

# Use custom ring tone 3 if incoming caller ID is the following:
P107 =

# Disable Call Waiting. 0 - no, 1 - yes
P91 = 0

Use Quick IP-call mode. 0 - no, 1 - yes
P184 = 0

# Lock Keypad Update. 0 - no, 1 - yes
P88 = 0

####################################################################
# Primary Account (Account 1) Settings
####################################################################

# Account Active (In Use). 0 - no, 1 - yes
P271 = 1

# Outbound Proxy
P48 = $IPADDR

# Authenticate ID
P36 =

# Use DNS SRV. 0 - No, 1 - Yes.
P103 = 0

# SIP User ID is phone number. 0 - no, 1 - yes
P63 = 0

# SIP Registration. 0 - no, 1 - yes
P31 = 1

# Unregister On Reboot. 0 - no, 1 - yes
P81 = 0

# Register Expiration (in minutes. default 1 hour, max 45 days)
P32 = 60

# Local SIP port (default 5060)
P40 = 5060

# SIP T1 Timeout. RFC 3261 T1 value (RTT estimate)
# 50 - 0.5 sec, 100 - 1 sec, 200 - 2 sec. Default 100.
P209 = 100

# SIP T2 Interval. RFC 3261 T2 value. The maximum retransmit interval for non-INVITE requests and INVITE responses.
# 200 - 2 sec, 400 - 4 sec, 800 - 8 sec. Default 400.
P250 = 400

# NAT Traversal. 0 - yes, 1 - no, 2 - No, but send keep-alive
P52 = 1

# SUBSCRIBE for MWI. (Whether or not send SUBSCRIBE for Message Waiting Indication) 0 - No, 1 - Yes.
P99 = 0

# Proxy-Require (A SIP extension to enable firewall penetration)
P197 =

# Voice Mail UserID (User ID/extension for 3rd party voice mail system)
P33 = *97

# Send DTMF. 0 - in audio, 1 - via RTP, 2 - via SIP INFO
P73 = 1

# Early Dial (use "Yes" only if proxy supports 484 response). 0 - no, 1 - yes
P29 = 0

# Dial Plan Prefix (dial plan prefix string).
P66 =

# Enable Call Features.  0 - no, 1 - yes
P191 = 1

# Disable Missed-Call (Missed calls will not be logged if set to Yes). 0 - no, 1 - yes
P182 = 0

# Session Expiration (in seconds. default 180 seconds. Allowed value: 90-65535)
P260 = 180

# Minimum SE (in seconds. default 90 seconds, must be lower than or equal to P260)
P261 = 90

# Caller Request Timer (Request for timer when calling) 0 - no, 1 - yes
P262 = 0

# Callee Request Timer (Request for timer when called. i.e. if remote party supports timer but did not request for one) 0 - no, 1 - yes
P263 = 0

# Force Timer (Still use timer when remote party does not support timer) 0 - no, 1 - yes
P264 = 0

# Force INVITE (Always refresh with INVITE instead of UPDATE even when remote party supports UPDATE) 0 - no, 1 - yes
P265 = 0

# UAC Specify Refresher. 0 - omit, 1 - UAC, 2 - UAS
P266 = 0

# UAS Specify Refresher. 1 - UAC, 2 - UAS
P267 = 1

# Enable 100rel. 0 - no, 1 - yes
P272 = 0

# Account Ring Tone. 0 - system ring tone, 1 - custom ring tone 1, 2 - custom ring tone 2
# 3 - custom ring tone 3.
P104 = 0

# Send Anonymous (caller ID will be blocked if set to Yes). 0 - no, 1 - yes
P65 = 0

# Auto Answer. 0 - no, 1 - yes
P90 = 0

# Allow Auto Answer by Call-Info. 0 - no, 1 - yes
P298 = 1

# Turn off speaker on remote disconnect. 0 - no, 1 - yes
P299 = 1

# Special Feature.    100 - Standard, 101 - Nortel MCS, 102- Broadsoft, 108 - CBCOM, 109 - RNK.
P198 = 100

#-----------------------------------------------------------------------------
# Codec/Voice Quality settings
#-----------------------------------------------------------------------------

# First codec.   0 - PCMU, 3 - GSM, 4 - G.723.1, 8 - PCMA, 18 - G.729A/B
P57 = 0

# Second codec.  0 - PCMU, 3 - GSM, 4 - G.723.1, 8 - PCMA, 18 - G.729A/B
P58 = 3

# Third codec.   0 - PCMU, 3 - GSM, 4 - G.723.1, 8 - PCMA, 18 - G.729A/B
P59 = 4

# Forth codec.   0 - PCMU, 3 - GSM, 4 - G.723.1, 8 - PCMA, 18 - G.729A/B
P60 = 8

# Fifth codec.   0 - PCMU, 3 - GSM, 4 - G.723.1, 8 - PCMA, 18 - G.729A/B
P61 = 18

# Sixth codec.   0 - PCMU, 3 - GSM, 4 - G.723.1, 8 - PCMA, 18 - G.729A/B
P62 = 0

# Seventh codec. 0 - PCMU, 3 - GSM, 4 - G.723.1, 8 - PCMA, 18 - G.729A/B
P46 = 0

# Eighth codec.  0 - PCMU, 3 - GSM, 4 - G.723.1, 8 - PCMA, 18 - G.729A/B
P98 = 0

########################################################################
# SIP Account 2 Settings
########################################################################

# Account Active (In Use). 0 - no, 1 - yes
P401 = 0

#Account Name
P417 = 

# SIP Server
P402 =

# Outbound Proxy Server
P403 =

# Account 2 SIP User ID
P404 =

# Authenticate ID
P405 =

# Authenticate Password
P406 =

# Display Name (John Doe)
P407 =

# Use DNS SRV. 0 - No, 1 - Yes.
P408 = 0

# User ID is phone number; "user=phone". 0 - no, 1 - yes
P409 = 0

# SIP Registration. 0 - no, 1 - yes
P410 = 1

# Unregister on Reboot. 0 - no, 1 - yes
P411 = 0

# Register Expiration (in minutes. default 1 hour, max 45 days)
P412 = 60

# SIP Local port (default 5062)
P413 = 5062

# SIP T1 Timeout. RFC 3261 T1 value (RTT estimate)
# 50 - 0.5 sec, 100 - 1 sec, 200 - 2 sec. Default 100.
P440 = 100

# SIP T2 Interval. RFC 3261 T2 value. The maximum retransmit interval for non-INVITE requests and INVITE responses.
# 200 - 2 sec, 400 - 4 sec, 800 - 8 sec. Default 400.
P441 = 400

# NAT Traversal. 0 - yes, 1 - no, 2 - No, but send keep-alive
P414 = 1

# Subscribe MWI. (Whether or not send SUBSCRIBE for Message Waiting Indication) 0 - No, 1 - Yes.
P415 = 0

# Proxy Require
P418 =

# Voice Mail UserID (User ID/extension for 3rd party voice mail system)
P426 =
 
# Send DTMF method. 0 - in audio, 1 - via RTP, 2 - via SIP INFO
P416 = 0
 
# Early Dial. 0 - no, 1 - yes
P422 = 0

# Dial Plan Prefix
P419 =

# Enable Call Features. 0 - no, 1 - yes.
P420 = 1

# Disable Missed-Call (Missed calls will not be logged if set to Yes). 0 - no, 1 - yes
P442 = 0

# Default Session Expires (in seconds. default 180 seconds. Allowed value: 90-65535)
P434 = 180

# Minimum SE (in seconds. default 90 seconds, must be lower than or equal to P260)
P427 = 90

# Caller Request Timer (Request for timer when calling) 0 - no, 1 - yes
P428 = 0

# Callee Request Timer (Request for timer when called. i.e. if remote party supports timer but did not request for one) 0 - no, 1 - yes
P429 = 0

# Force Timer (Still use timer when remote party does not support timer) 0 - no, 1 - yes
P430 = 0

# Force INVITE (Always refresh with INVITE instead of UPDATE even when remote party supports UPDATE) 0 - no, 1 - yes
P431 = 0

# UAC Specify Refresher. 0 - omit, 1 - UAC, 2 - UAS
P432 = 0

# UAS Specify Refresher. 1 - UAC, 2 - UAS
P433 = 1

# Enable 100rel. 0 - no, 1 - yes
P435 = 0

# Account Ring Tone. 0 - system ring tone, 1 - custom ring tone 1, 2 - custom ring tone 2
# 3 - custom ring tone 3.
P423 = 0

# Send Anonymous. 0 - no, 1 - yes
P421 = 0

# Auto Answer. 0 - no, 1 - yes.
P425 = 0

# Allow Auto Answer by Call-Info. 0 - no, 1 - yes
P438 = 1

# Turn off speaker on remote disconnect. 0 - no, 1 - yes
P439 = 1

# Special Feature.    100 - Standard, 101 - Nortel MCS, 102- Broadsoft, 108 - CBCOM, 109 - RNK.
P424 = 100

#-----------------------------------------------------------------------------
# Codec/Voice Quality settings
#-----------------------------------------------------------------------------

# First codec.   0 - PCMU, 3 - GSM, 4 - G.723.1, 8 - PCMA, 18 - G.729A/B
P451 = 0

# Second codec.  0 - PCMU, 3 - GSM, 4 - G.723.1, 8 - PCMA, 18 - G.729A/B
P452 = 3

# Third codec.   0 - PCMU, 3 - GSM, 4 - G.723.1, 8 - PCMA, 18 - G.729A/B
P453 = 4

# Forth codec.   0 - PCMU, 3 - GSM, 4 - G.723.1, 8 - PCMA, 18 - G.729A/B
P454 = 8

# Fifth codec.   0 - PCMU, 3 - GSM, 4 - G.723.1, 8 - PCMA, 18 - G.729A/B
P455 = 18

# Sixth codec.   0 - PCMU, 3 - GSM, 4 - G.723.1, 8 - PCMA, 18 - G.729A/B
P456 = 0

# Seventh codec. 0 - PCMU, 3 - GSM, 4 - G.723.1, 8 - PCMA, 18 - G.729A/B
P457 = 0

# Eighth codec.  0 - PCMU, 3 - GSM, 4 - G.723.1, 8 - PCMA, 18 - G.729A/B
P458 = 0

########################################################################
# SIP Account 3 Settings
########################################################################

# Account Active (In Use). 0 - no, 1 - yes
P501 = 0

# Account Name
P517 =

# SIP Server
P502 =

# Outbound Proxy Server
P503 =

# SIP User ID
P504 =

# Authenticate ID
P505 =

# Authenticate Password
P506 =

# Display Name (John Doe)
P507 =

# Use DNS SRV. 0 - No, 1 - Yes.
P508 = 0

# User ID is phone. "user=phone". 0 - no, 1 - yes
P509 = 0

# SIP Registration. 0 - no, 1 - yes
P510 = 1

# Unregister on Reboot. 0 - no, 1 - yes
P511= 0

# Register Expiration (in minutes. default 1 hour, max 45 days)
P512 = 60

# SIP Local port (default 5064)
P513 = 5064

# SIP T1 Timeout. RFC 3261 T1 value (RTT estimate)
# 50 - 0.5 sec, 100 - 1 sec, 200 - 2 sec. Default 100.
P540 = 100

# SIP T2 Interval. RFC 3261 T2 value. The maximum retransmit interval for non-INVITE requests and INVITE responses.
# 200 - 2 sec, 400 - 4 sec, 800 - 8 sec. Default 400.
P541 = 400

# NAT Traversal. 0 - yes, 1 - no, 2 - No, but send keep-alive
P514 = 1

# Subscribe MWI. (Whether or not send SUBSCRIBE for Message Waiting Indication) 0 - no, 1 - yes
P515 = 0

# Proxy Require
P518 =

# Voice Mail UserID (User ID/extension for 3rd party voice mail system)
P526 =
 
# Send DTMF method. 0 - in audio, 1 - via RTP, 2 - via SIP INFO
P516 = 0

# Early Dial. 0 - no, 1 - yes
P522 = 0

# Dial Plan Prefix
P519 =

# Enable Call Features. 0 - no, 1 - yes.
P520 = 1

# Disable Missed-Call (Missed calls will not be logged if set to Yes). 0 - no, 1 - yes
P542 = 0

# Default Session Expires (in seconds. default 180 seconds. Allowed value: 90-65535)
P534 = 180

# Minimum SE (in seconds. default 90 seconds, must be lower than or equal to P260)
P527 = 90

# Caller Request Timer (Request for timer when calling) 0 - no, 1 - yes
P528 =

# Callee Request Timer (Request for timer when called. i.e. if remote party supports timer but did not request for one) 0 - no, 1 - yes
P529 =

# Force Timer (Still use timer when remote party does not support timer) 0 - no, 1 - yes
P530 =

# Force INVITE (Always refresh with INVITE instead of UPDATE even when remote party supports UPDATE) 0 - no, 1 - yes
P531 =

# UAC Specify Refresher. 0 - omit, 1 - UAC, 2 - UAS
P532 = 0

# UAS Specify Refresher. 1 - UAC, 2 - UAS
P533 = 1

# Enable 100rel. 0 - no, 1 - yes
P535 = 0

# Account Ring Tone. 0 - system ring tone, 1 - custom ring tone 1, 2 - custom ring tone 2
# 3 - custom ring tone 3.
P523 = 0

# Send Anonymous
P521 =

# Auto Answer. 0 - no, 1 - yes.
P525 = 0
 
# Allow Auto Answer by Call-Info. 0 - no, 1 - yes
P538 = 1

# Turn off speaker on remote disconnect. 0 - no, 1 - yes
P539 = 1

# Special Feature.    100 - Standard, 101 - Nortel MCS, 102- Broadsoft, 108 - CBCOM, 109 - RNK.
P524 = 100

#-----------------------------------------------------------------------------
# Codec/Voice Quality settings
#-----------------------------------------------------------------------------

# First codec.   0 - PCMU, 3 - GSM, 4 - G.723.1, 8 - PCMA, 18 - G.729A/B
P551 = 0

# Second codec.  0 - PCMU, 3 - GSM, 4 - G.723.1, 8 - PCMA, 18 - G.729A/B
P552 = 3

# Third codec.   0 - PCMU, 3 - GSM, 4 - G.723.1, 8 - PCMA, 18 - G.729A/B
P553 = 4

# Forth codec.   0 - PCMU, 3 - GSM, 4 - G.723.1, 8 - PCMA, 18 - G.729A/B
P554 = 8

# Fifth codec.   0 - PCMU, 3 - GSM, 4 - G.723.1, 8 - PCMA, 18 - G.729A/B
P555 = 18

# Sixth codec.   0 - PCMU, 3 - GSM, 4 - G.723.1, 8 - PCMA, 18 - G.729A/B
P556 = 0

# Seventh codec. 0 - PCMU, 3 - GSM, 4 - G.723.1, 8 - PCMA, 18 - G.729A/B
P557 = 0

# Eighth codec.  0 - PCMU, 3 - GSM, 4 - G.723.1, 8 - PCMA, 18 - G.729A/B
P558 = 0

########################################################################
# SIP Account 4 Settings
########################################################################

# Account Active (In Use). 0 - no, 1 - yes
P601 = 0

#Account Name
P617 = 

# SIP Server
P602 =

# Outbound Proxy Server
P603 =

# SIP User ID
P604 =

# Authenticate ID
P605 =

# Authenticate Password
P606 =

# Display Name (John Doe)
P607 =

# Use DNS SRV. 0 - no, 1 - yes.
P608 = 0

# User ID is phone number. "user=phone". 0 - no, 1 - yes
P609 = 0

# SIP Registration. 0 - no, 1 - yes
P610 = 1

# Unregister on Reboot. 0 - no, 1 - yes
P611 = 0

# Register Expiration (in minutes. default 1 hour, max 45 days)
P612 = 60

# SIP Local port (default 5066)
P613 = 5066

# SIP T1 Timeout. RFC 3261 T1 value (RTT estimate)
# 50 - 0.5 sec, 100 - 1 sec, 200 - 2 sec. Default 100.
P640 = 100

# SIP T2 Interval. RFC 3261 T2 value. The maximum retransmit interval for non-INVITE requests and INVITE responses.
# 200 - 2 sec, 400 - 4 sec, 800 - 8 sec. Default 400.
P641 = 400

# NAT Traversal. 0 - yes, 1 - no, 2 - No, but send keep-alive
P614 = 1

# Subscribe MWI. Whether or not send SUBSCRIBE for Message Waiting Indication.  0 - no, 1 - yes
P615 = 0

# Proxy Require
P618 =

# Voice Mail UserID (User ID/extension for 3rd party voice mail system)
P626 =
 
# Send DTMF method. 0 - in audio, 1 - via RTP, 2 - via SIP INFO
P616 = 0

# Early Dial. 0 - no, 1 - yes
P622 = 0

# Dial Plan Prefix
P619 =

# Enable Call Features. 0 - no, 1 - yes.
P620 = 1

# Disable Missed-Call (Missed calls will not be logged if set to Yes). 0 - no, 1 - yes
P642 = 0

# Default Session Expires (in seconds. default 180 seconds. Allowed value: 90-65535)
P634 =

# Minimum SE (in seconds. default 90 seconds, must be lower than or equal to P260)
P627 =

# Caller Request Timer (Request for timer when calling) 0 - no, 1 - yes
P628 =

# Callee Request Timer (Request for timer when called. i.e. if remote party supports timer but did not request for one) 0 - no, 1 - yes
P629 =

# Force Timer (Still use timer when remote party does not support timer) 0 - no, 1 - yes
P630 =

# Force INVITE (Always refresh with INVITE instead of UPDATE even when remote party supports UPDATE) 0 - no, 1 - yes
P631 =

# UAC Specify Refresher. 0 - omit, 1 - UAC, 2 - UAS
P632 = 0

# UAS Specify Refresher. 1 - UAC, 2 - UAS
P633 = 1

# Enable 100rel. 0 - no, 1 - yes
P635 = 0

# Account Ring Tone. 0 - system ring tone, 1 - custom ring tone 1, 2 - custom ring tone 2
# 3 - custom ring tone 3.
P623 = 0

# Send Anonymous. 0 - no, 1 - yes
P621 = 0

# Auto Answer. 0 - no, 1 - yes.
P625 = 0

# Allow Auto Answer by Call-Info. 0 - no, 1 - yes
P638 = 1

# Turn off speaker on remote disconnect. 0 - no, 1 - yes
P639 = 1

# Special Feature.  100 - Standard, 101 - Nortel MCS, 102- Broadsoft, 108 - CBCOM, 109 - RNK.
P624 = 100
 
#-----------------------------------------------------------------------------
# Codec/Voice Quality settings
#-----------------------------------------------------------------------------

# First codec.   0 - PCMU, 3 - GSM, 4 - G.723.1, 8 - PCMA, 18 - G.729A/B
P651 = 0

# Second codec.  0 - PCMU, 3 - GSM, 4 - G.723.1, 8 - PCMA, 18 - G.729A/B
P652 = 3

# Third codec.   0 - PCMU, 3 - GSM, 4 - G.723.1, 8 - PCMA, 18 - G.729A/B
P653 = 4

# Forth codec.   0 - PCMU, 3 - GSM, 4 - G.723.1, 8 - PCMA, 18 - G.729A/B
P654 = 8

# Fifth codec.   0 - PCMU, 3 - GSM, 4 - G.723.1, 8 - PCMA, 18 - G.729A/B
P655 = 18

# Sixth codec.   0 - PCMU, 3 - GSM, 4 - G.723.1, 8 - PCMA, 18 - G.729A/B
P656 = 0

# Seventh codec. 0 - PCMU, 3 - GSM, 4 - G.723.1, 8 - PCMA, 18 - G.729A/B
P657 = 0

# Eighth codec.  0 - PCMU, 3 - GSM, 4 - G.723.1, 8 - PCMA, 18 - G.729A/B
P658 = 0

################################################################################
# End User Settings. Please do not edit this section.
################################################################################

# End User Password
#P196 = 123

# DHCP support. 0 - yes, 1 - no
#P8 = 0

# PPPoE support. PPPoE user ID
#P82 =

# PPPoE password
#P83 =

# Host name, DHCP option 12. Max length allowed is 32 bytes.
P146 =

# Domain name, DHCP option 15. Max length allowed is 32 bytes.
P147 =

# Vendor Class ID, DHCP option 60. Max length allowed is 32 bytes.
P148 = 

# IP Address. Ignore if DHCP or PPPoE is used
#P9 = 192
#P10 = 168
#P11 = 0
#P12 = 1

# Subnet mask. Ignore if DHCP or PPPoE is used
#P13 = 255
#P14 = 255
#P15 = 255
#P16 = 0

# Router. Ignore if DHCP or PPPoE is used
#P17 = 192
#P18 = 168
#P19 = 1
#P20 = 1

# Use this DNS server.  (if specified).
#P92 = 192
#P93 = 168
#P94 = 0
#P95 = 2

# DNS 1. Ignore if DHCP or PPPoE is used
#P21 = 192
#P22 = 168
#P23 = 0
#P24 = 1

# DNS 2. Ignore if DHCP or PPPoE is used
#P25 = 0
#P26 = 0
#P27 = 0
#P28 = 0

#--------------------------------------------------------------------------
# End User Multi Purpose Keys
#-------------------------------------------------------------------------- 

# Multi Purpose Key 1 
# ------------------------------------------

# Account. 0 - Account 1, 1 - Account 2, 2 - Account 3, 3 - Account 4
P301 = 0

# Multi Purpose Key 2
# ------------------------------------------

# Account. 0 - Account 1, 1 - Account 2, 2 - Account 3, 3 - Account 4
P304 = 0

# Multi Purpose Key 3
# ------------------------------------------

# Account. 0 - Account 1, 1 - Account 2, 2 - Account 3, 3 - Account 4
P307 = 0

# Multi Purpose Key 4
# ------------------------------------------

# Account. 0 - Account 1, 1 - Account 2, 2 - Account 3, 3 - Account 4  
P310 = 0

# Multi Purpose Key 5
# ------------------------------------------

# Account. 0 - Account 1, 1 - Account 2, 2 - Account 3, 3 - Account 4
P313 = 0

# Multi Purpose Key 6
# ------------------------------------------

# Account. 0 - Account 1, 1 - Account 2, 2 - Account 3, 3 - Account 4 
P316 = 0

# Multi Purpose Key 7
# ------------------------------------------

# Account. 0 - Account 1, 1 - Account 2, 2 - Account 3, 3 - Account 4 
P319 = 0

#-----------------------------------------------------------------------------
# End User Time settings
#-----------------------------------------------------------------------------

# Time Zone. Offset in minutes to GMT
P64 = 420

# Allow DHCP Option 2 to override Time Zone setting. 0 - No, 1 - Yes.
# When set to Yes(1), it will override the configured Time Zone setting if available. 
P143 = 0

# Daylight Savings Time. 0 - no, 1 - yes
P75 = 1

# Optional Rule. Daylight Saving rule.
P246 = 4,1,7,2,0;10,-1,7,2,0;60

# LCD Backlight Always On. 0 - no, 1 - yes
P322 = 1

# Time Display Format. 0 - 12 Hour, 1 - 24 Hour
P122 = 0

# Date Display Format. 0 - Year-Month-Day, 1 - Month-Day-Year, 2 - Day-Month-Year
P102 = 2

# Display Clock instead of Date. 0 - no, 1 - yes
P123 = 0

# Device Mode. 0 - Switch, 1 - NAT/Router. Default is 0.
P231 = 0

# WAN side http access.  0 - Disable(default), 1 - Yes.
P190 = 0

# Reply to ICMP on WAN port. 0 - No, 1 - Yes. Unit will not respond to PING from WAN side if set to No.
P189 = 0

#Cloned WAN MAC Address.
#P115 =
#P116 =
#P117 =
#P118 =
#P119 =
#P120 =

#LAN Subnet Mask.  Default is 255.255.255.0.
#P110 = 

#LAN Base/Gateway/Router IP for the LAN port, default is 192.168.2.1.
#P111 = 

#DHCP IP Lease Time, in units of hours, default is 120 hours or 5 days.
#P112 = 120

#DMZ IP.
#P113 =

#-----------------------------------------------------------
# Port Forwarding Settings.
#-----------------------------------------------------------

#############  Choice 1 ####################################
# WAN Port
P150 =
# LAN IP
P158 =
# LAN Port
P166 =
# Protocol.  0 - UDP Only, 1 - TCP Only, 2 - TCP and UDP.
P174 =
#############  Choice 2 ####################################
# WAN Port
P151 =
# LAN IP
P159 =
# LAN Port
P167 =
# Protocol.  0 - UDP Only, 1 - TCP Only, 2 - TCP and UDP.
P175 =
#############  Choice 3 ####################################
# WAN Port
P152 =
# LAN IP
P160 =
# LAN Port
P168 =
# Protocol.  0 - UDP Only, 1 - TCP Only, 2 - TCP and UDP.
P176 =
#############  Choice 4 ####################################
# WAN Port
P153 =
# LAN IP
P161 =
# LAN Port
P169 =
# Protocol.  0 - UDP Only, 1 - TCP Only, 2 - TCP and UDP.
P177 =
#############  Choice 5 ####################################
# WAN Port
P154 =
# LAN IP
P162 =
# LAN Port
P170 =
# Protocol.  0 - UDP Only, 1 - TCP Only, 2 - TCP and UDP.
P178 =
#############  Choice 6 ####################################
# WAN Port
P155 =
# LAN IP
P163 =
# LAN Port
P171 =
# Protocol.  0 - UDP Only, 1 - TCP Only, 2 - TCP and UDP.
P179 =
#############  Choice 7 ####################################
# WAN Port
P156 =
# LAN IP
P164 =
# LAN Port
P172 =
# Protocol.  0 - UDP Only, 1 - TCP Only, 2 - TCP and UDP.
P180 =
#############  Choice 8 ####################################
# WAN Port
P157 = 
# LAN IP
P165 = 
# LAN Port
P173 = 
# Protocol.  0 - UDP Only, 1 - TCP Only, 2 - TCP and UDP.
P181 = 
EOF


################################################################################################
##HT386#########################################################################################
################################################################################################
################################################################################################

echo ""
echo "Creating /tftpboot/Grandstream_HT386_Default.txt..."
echo ""

cat > /tftpboot/Grandstream_HT386_Default.txt <<EOF

# default settings

################################################################################################
## Configuration template for firmware version 1.0.3.44 (HT488, HT496, HT386)
################################################################################################

##############################################################################
##  Advanced Settings.
##############################################################################

# Admin password for web interface
P2 = admin

# Home NPA
P259 =

# Layer 3 QoS (IP Diff-Serv or Precedence value for RTP)
P38 = 48

# Layer 2 QoS. 802.1Q/VLAN Tag (VLAN classification for RTP)
P51 = 0

# Layer 2 QoS. 802.1p priority value (0 - 7)
P87 = 0

# STUN server
P76 = 

# Keep-alive interval (in seconds. default 20 seconds)
P84 = 20

# Use NAT IP.  This will enable our SIP client to use this IP in the SIP message. 
# Example 64.3.153.50.
P101 =

#-------------------------------------------------------------------------------
# Firmware Upgrade
#-------------------------------------------------------------------------------

# Firmware Upgrade and Privisioning. 0 - TFTP Upgrade,  1 - HTTP Upgrade.
P212 = 0

# Firmware Server Path
P192 = $IPADDR

# Config Server Path
P237 = $IPADDR

# Firmware File Prefix
P232 =

# Firmware File Postfix
P233 =

# Config File Prefix
P234 =

# Config File Postfix
P235 =

# Automatic Upgrade. 0 - No, 1 - Yes (checking every defined days). Default is No.
P194 = 0

# Check for new firmware every () minutes, unit is in minute, default is 7 days.
P193 = 10080

# Use firmware pre/postfix to determine if f/w is required
# 0 = Always Check for New Firmware 
# 1 = Check New Firmware only when F/W pre/suffix changes 
P238 = 0

# Firmwae Key (AES 128, in Hexadecimal Representation) 
P242 =

# For HT488, the following 5 fields are in the FXS Port Settings page
#
# Onhook Threshold. Default 800ms.
# <value=0>Hookflash OFF
# <value=6>600 ms
# <value=8>800 ms
# <value=10>1000 ms
# <value=12>1200 ms
P245 = 8

# FXS Impedence
#
# <value="0" > Default setting is "600 Ohm (North America)"
# <value=0>600 Ohm (North America)
# <value=1>900 Ohm
# <value=2>600 Ohm + 2.16uF
# <value=3>900 Ohm + 2.16uF
# <value=4>CTR21 (270 Ohm + 750 Ohm||150nF)
# <value=5>Australia/New Zealand #1 (220 Ohm + 820 Ohm||120nF)
# <value=6>Slovakia/Slovenia/South Africa (220 Ohm + 820 Ohm||115nF)
# <value=7>UK/New Zealand #2 (370 Ohm + 620 Ohm||310nF)
P86 = 0

# Caller ID Scheme
#
# <value="0">current setting is "Bellcore"
# <value=0>Bellcore (North America)
# <value=1>ETSI-FSK (France, Germany, Norway, Taiwan, UK-CCA)
# <value=2>ETSI-DTMF (Finland, Sweden)
# <value=3>DTMF-Denmark
# <value=4>CID-Canada
# <value=5>DTMF-Brazil
P200 = 0

# Onhook Voltage
#
# <value="3">current setting is "48V"
# <value=1>18V
# <value=5>24V
# <value=2>36V
# <value=3>48V
# <value=4>51V
P206 = 3

# Polarity Reversal. 0 - No, 1 - Yes.
P205 = 0

# NTP Server
P30 = time.nist.gov

# Reply to ICMP on WAN port (Unit will not respond to PING from WAN side if set to No)
# 0 - No, 1 - Yes.
P189 = 0

# WAN side http access.  0 - Disable(default), 1 - Yes.
# For HT488/496 only
P190 = 0

# Syslog feature for HT496/386 only
# Syslog Server (name of the server, max length is 64 charactors)
P207 = 

# Syslog Level (Default setting is NONE)
# 0 - NONE, 1 - DEBUG, 2 - INFO, 3 - WARNING, 4 - ERROR
P208 = 0

##############################################################################
# HandyTone 488/496/386 Port 1 (FXS) Account Settings.
##############################################################################

# SIP Server
P47 = $IPADDR

# Outbound Proxy
P48 = $IPADDR

# Use DNS SRV. 0 - No, 1 - Yes.
P103 = 

# User ID is phone number. 0 - no, 1 - yes
P63 = 0

# SIP Registration. 0 - no, 1 - yes
P31 = 1

# Unregister On Reboot. 0 - no, 1 - yes
P81 = 0

# Register Expiration (in minutes. default 1 hour, max 45 days)
P32 = 60

# Local SIP port (default 5060)
P40 = 5060

# Local RTP port (1024-65535, default 5004)
P39 = 5004 

# Use Random Port. 0 - no, 1 - yes
P78 = 0

# DTMF Payload Type
P79 = 101

# Send DTMF. 8 - in audio, 1 - via RTP, 2 - via SIP INFO, 11 - In Audio & RTP & SIP INFO
# 9 - In Audio & RTP, 10 - IN Audio & SIP INFO, 3 - RTP & SIP INFO
P73 = 1

# Send Flash Event (Flash will be sent as a DTMF event if set to Yes). 0 - no, 1 - yes
P74 = 0

# Enable Call Features,  0 - No, 1 - Yes.
P191 = 1

# Use Bell-style 3-way Conference. 0 - No, 1 - Yes.
P108 = 0

# Offhook Auto-Dial (User ID/extension to dial automatically when offhook)
P71 =

# Proxy-Require (A SIP extension to enable firewall penetration)
P197 =

# Disable Call-Waiting. 0 - No, 1 - Yes.
P91 = 0

# NAT Traversal (STUN). 0 - Yes, 1 - No
P52 = 1

# No Key Entry Timeout. Default - 4 seconds.
P85 = 4

#-------------------------------------------------------------------------------
# Codec/Voice Quality settings
#-------------------------------------------------------------------------------

# First codec. 0 - PCMU, 2 - G.726-32, 4 - G.723.1, 8 - PCMA, 18 - G.729A/B, 98 - iLBC
P57 = 0

# Second codec. 0 - PCMU, 2 - G.726-32, 4 - G.723.1, 8 - PCMA, 18 - G.729A/B, 98 - iLBC
P58 = 2

# Third codec. 0 - PCMU, 2 - G.726-32, 4 - G.723.1, 8 - PCMA, 18 - G.729A/B, 98 - iLBC
P59 = 4

# Forth codec. 0 - PCMU, 2 - G.726-32, 4 - G.723.1, 8 - PCMA, 18 - G.729A/B, 98 - iLBC
P60 = 8

# Fifthth codec. 0 - PCMU, 2 - G.726-32, 4 - G.723.1, 8 - PCMA, 18 - G.729A/B, 98 - iLBC
P61 = 18

# Sixth codec. 0 - PCMU, 2 - G.726-32, 4 - G.723.1, 8 - PCMA, 18 - G.729A/B, 98 - iLBC
P62 = 98

# Voice Frames per TX (up to 10/20/32/64 frames for G711/G726/G723/other codecs respectively)
P37 = 2

# G723 rate. 0 - 6.3kbps encoding rate, 1 - 5.3kbps encoding rate
P49 = 0

# iLBC Frame Size. 0 - 20ms(default), 1 - 30ms.
P97 = 0

# iLBC payload type. Between 96 and 127, default is 97.
P96 = 97

# Silence Suppression. 0 - no, 1 - yes
P50 = 0

# FAX Mode. 0 - T.38 (Auto Detect), 1 - Pass Through
P228 = 0

# Early Dial (use "Yes" only if proxy supports 484 response). 0 - no, 1 - yes
P29 = 0

# Dial Plan Prefix (dial plan prefix string)
P66 =

# Use # as Dial Key (if set to Yes, "#" will function as the "(Re-)Dial" key). 0 - no, 1 - yes
P72 = 1

# SUBSCRIBE for MWI. Whether or not send SUBSCRIBE for Message Waiting Indication.  0 - No, 1 - Yes.
P99 = 0

# Send Anonymous (caller ID will be blocked if set to Yes). 0 - no, 1 - yes
P65 = 0

# Lock Keypad Update. (configuration update via keypad is disabled if set to Yes)
# 0 - No, 1 - Yes.
P88 = 0

# Special Feature. 100 - Standard, 105 - Lucent FS5000 Simple Endpoint, 108 - CBCOM, 109 - RNK.
P198 = 100

##### Call Progress Tones #####
#
### Dial Tone ###
# Frequency 1 (Hz)
P1820 = 350
# Frequency 2 (Hz)
P1840 = 440
# ON (x 10ms)
P1860 = 0
# OFF (x 10ms)
P1880 = 0

### Recall Dial Tone ###
# Frequency 1 (Hz)
P1821 = 350
# Frequency 2 (Hz)
P1841 = 440
# ON (x 10ms)
P1861 = 10
# OFF (x 10ms)
P1881 = 10

### Message Waiting Tone ###
# Frequency 1 (Hz)
P1822 = 350
# Frequency 2 (Hz)
P1842 = 440
# ON (x 10ms)
P1862 = 10
# OFF (x 10ms)
P1882 = 10

### Confirmation Tone ###
# Frequency 1 (Hz)
P1823 = 350
# Frequency 2 (Hz)
P1843 = 440
# ON (x 10ms)
P1863 = 10
# OFF (x 10ms)
P1883 = 10

### Audiable Ringing ###
# Frequency 1 (Hz)
P1824 = 440
# Frequency 2 (Hz)
P1844 = 480
# ON (x 10ms)
P1864 = 200
# OFF (x 10ms)
P1884 = 400

### Busy Tone ###
# Frequency 1 (Hz)
P1825 = 480
# Frequency 2 (Hz)
P1845 = 620
# ON (x 10ms)
P1865 = 50
# OFF (x 10ms)
P1885 = 50

### Reorder Tone ###
# Frequency 1 (Hz)
P1826 = 480
# Frequency 2 (Hz)
P1846 = 620
# ON (x 10ms)
P1866 = 25
# OFF (x 10ms)
P1886 = 25

### Receiver offhook ###
# Frequency 1 (Hz)
P1827 = 1400
# Frequency 2 (Hz)
P1847 = 2600
# ON (x 10ms)
P1867 = 10
# OFF (x 10ms)
P1887 = 10

##### Distinct Ring Tones #####
#
# For HT496 only
#
### Ring1 ###
# Frequency 1 (Hz)
P1828 = 440
# Frequency 2 (Hz)
P1848 = 440
# ON (x 10ms)
P1868 = 100
# OFF (x 10ms)
P1888 = 100

### Ring2 ###
# Frequency 1 (Hz)
P1829 = 440
# Frequency 2 (Hz)
P1849 = 440
# ON (x 10ms)
P1869 = 100
# OFF (x 10ms)
P1889 = 100
 
### Ring3 ###
# Frequency 1 (Hz)
P1830 = 440
# Frequency 2 (Hz)
P1850 = 440
# ON (x 10ms)
P1870 = 100
# OFF (x 10ms)
P1890 = 100

### Ring4 ###
# Frequency 1 (Hz)
P1831 = 440
# Frequency 2 (Hz)
P1851 = 440
# ON (x 10ms)
P1871 = 100
# OFF (x 10ms)
P1891 = 100

### Ring5 ###
# Frequency 1 (Hz)
P1832 = 440
# Frequency 2 (Hz)
P1852 = 440
# ON (x 10ms)
P1872 = 100
# OFF (x 10ms)
P1892 = 100

### Ring6 ###
# Frequency 1 (Hz)
P1833 = 440
# Frequency 2 (Hz)
P1853 = 440
# ON (x 10ms)
P1873 = 100
# OFF (x 10ms)
P1893 = 100

### Ring7 ###
# Frequency 1 (Hz)
P1834 = 20
# Frequency 2 (Hz)
P1854 = 20
# ON (x 10ms)
P1874 = 80
# OFF (x 10ms)
P1894 = 40

### Ring8 ###
# Frequency 1 (Hz)
P1835 = 20
# Frequency 2 (Hz)
P1855 = 20
# ON (x 10ms)
P1875 = 40
# OFF (x 10ms)
P1895 = 20

### Ring9 ###
# Frequency 1 (Hz)
P1836 = 20
# Frequency 2 (Hz)
P1856 = 20
# ON (x 10ms)
P1876 = 30
# OFF (x 10ms)
P1896 = 20

### Ring10 ###
# Frequency 1 (Hz)
P1837 = 20
# Frequency 2 (Hz)
P1857 = 20
# ON (x 10ms)
P1877 = 50
# OFF (x 10ms)
P1897 = 800

### Ring11 ###
# Frequency 1 (Hz)
P1838 = 20
# Frequency 2 (Hz)
P1858 = 20
# ON (x 10ms)
P1878 = 200
# OFF (x 10ms)
P1898 = 400

### Ring12 ###
# Frequency 1 (Hz)
P1839 = 20
# Frequency 2 (Hz)
P1859 = 20
# ON (x 10ms)
P1879 = 200
# OFF (x 10ms)
P1899 = 400

# Volume Amplification
# TX 
# <value=1> +6dB
# <value=2> +4dB
# <value=3> +2dB
# <value=0> 0dB
# <value=4> -2dB
# <value=5> -4dB
# <value=6> -6dB
P247 = 0 

# RX 
# <value=1> +6dB
# <value=2> +4dB
# <value=3> +2dB
# <value=0> 0dB
# <value=4> -2dB
# <value=5> -4dB
# <value=6> -6dB
P249 = 0

##############################################################################
# HandyTone 488/496/386 Port 2 (FXO/FXS) Account Settings.
##############################################################################

# SIP Server
P747 = $IPADDR

# Outbound Proxy
P748 = $IPADDR

# Use DNS SRV. 0 - No, 1 - Yes.
P702 = 0

# User ID is phone number. 0 - no, 1 - yes
P763 = 0

# SIP Registration. 0 - no, 1 - yes
P731 = 1

# Unregister On Reboot. 0 - no, 1 - yes
P752 = 0

# Register Expiration (in minutes. default 1 hour, max 45 days)
P732 = 60

# Local SIP port (default 5062)
P740 = 5062

# Local RTP port (1024-65535, default 5008)
P739 = 5008

# Use Random Port. 0 - no, 1 - yes
P778 = 0

# DTMF Payload Type
P779 = 101
  
# Send DTMF. 8 - in audio, 1 - via RTP, 2 - via SIP INFO, - In Audio & RTP & SIP INFO
# In Audio & RTP - IN Audio & SIP INFO - RTP & SIP INFO
P773 = 1

# Send Flash Event (Flash will be sent as a DTMF event if set to Yes). 0 - no, 1 - yes
P774 = 0

# Enable call features. 0 - No, 1 - Yes. 
# For HT496/386 only
P751 = 1

# Use Bell-style 3-way Conference. 0 - No, 1 - Yes.
P711 = 0

# Offhook Auto-Dial (User ID/extension to dial automatically when offhook)
# For HT496/386 only
P771 =

# Proxy-Require (A SIP extension to enable firewall penetration)
P792 =

# Disable Call-Waiting. 0 - No, 1 - Yes.
# For HT496/386 only
P791 = 0

# NAT Traversal (STUN). 0 - Yes, 1 - No
P730 = 1

# No Key Entry Timeout. Default - 4 seconds.
P292 = 4

#-------------------------------------------------------------------------------
# Codec/Voice Quality settings
#-------------------------------------------------------------------------------

# First codec. 0 - PCMU, 2 - G.726-32, 4 - G.723.1, 8 - PCMA, 18 - G.729A/B, 98 - iLBC
P757 = 0

# Second codec. 0 - PCMU, 2 - G.726-32, 4 - G.723.1, 8 - PCMA, 18 - G.729A/B, 98 - iLBC
P758 = 2

# Third codec. 0 - PCMU, 2 - G.726-32, 4 - G.723.1, 8 - PCMA, 18 - G.729A/B, 98 - iLBC
P759 = 4

# Forth codec. 0 - PCMU, 2 - G.726-32, 4 - G.723.1, 8 - PCMA, 18 - G.729A/B, 98 - iLBC
P760 = 8

# Fifth codec. 0 - PCMU, 2 - G.726-32, 4 - G.723.1, 8 - PCMA, 18 - G.729A/B, 98 - iLBC
P761 = 18

# Sixth codec. 0 - PCMU, 2 - G.726-32, 4 - G.723.1, 8 - PCMA, 18 - G.729A/B, 98 - iLBC
P762 = 98

# Voice Frames per TX (up to 10/20/32/64 frames for G711/G726/G723/other codecs respectively)
P737 = 2

# G723 rate. 0 - 6.3kbps encoding rate, 1 - 5.3kbps encoding rate
P749 = 0

# iLBC payload type. Between 96 and 127, default is 97.
P704 = 97

# iLBC Frame Size. 0 - 20ms(default), 1 - 30ms.
P705 = 0

# Silence Suppression. 0 - no, 1 - yes
P750 = 0

# FAX Mode. 0 - T.38 (Auto Detect), 1 - Pass Through
# For HT496/386 only
P710 = 0

# Early Dial (use "Yes" only if proxy supports 484 response). 0 - no, 1 - yes
P729 = 0

# Dial Plan Prefix (dial plan prefix string)
P766 =

# Use # as Dial Key (if set to Yes, "#" will function as the "(Re-)Dial" key). 0 - no, 1 - yes
P772 = 1

# SUBSCRIBE for MWI. Whether or not send SUBSCRIBE for Message Waiting Indication.  0 - No, 1 - Yes.
# For HT496/386 only
P709 = 0

# Send Anonymous (caller ID will be blocked if set to Yes). 0 - no, 1 - yes
P765 = 0

# Special Feature. 100 - Standard, 105 - Lucent FS5000 Simple Endpoint, 108 - CBCOM, 109 - RNK.
P767 = 100

##### Call Progress Tones #####
#
### Dial Tone ###
# Frequency 1 (Hz)
P2820 = 350
# Frequency 2 (Hz)
P2840 = 440
# ON (x 10ms)
P2860 = 0
# OFF (x 10ms)
P2880 = 0

### Recall Dial Tone ###
# Frequency 1 (Hz)
P2821 = 350
# Frequency 2 (Hz)
P2841 = 440
# ON (x 10ms)
P2861 = 10
# OFF (x 10ms)
P2881 = 10

### Message Waiting Tone ###
# Frequency 1 (Hz)
P2822 = 350
# Frequency 2 (Hz)
P2842 = 440
# ON (x 10ms)
P2862 = 10
# OFF (x 10ms)
P2882 = 10

### Confirmation Tone ###
# Frequency 1 (Hz)
P2823 = 350
# Frequency 2 (Hz)
P2843 = 440
# ON (x 10ms)
P2863 = 10
# OFF (x 10ms)
P2883 = 10

### Audiable Ringing ###
# Frequency 1 (Hz)
P2824 = 440
# Frequency 2 (Hz)
P2844 = 480
# ON (x 10ms)
P2864 = 200
# OFF (x 10ms)
P2884 = 400

### Busy Tone ###
# Frequency 1 (Hz)
P2825 = 480
# Frequency 2 (Hz)
P2845 = 620
# ON (x 10ms)
P2865 = 50
# OFF (x 10ms)
P2885 = 50

### Reorder Tone ###
# Frequency 1 (Hz)
P2826 = 480
# Frequency 2 (Hz)
P2846 = 620
# ON (x 10ms)
P2866 = 25
# OFF (x 10ms)
P2886 = 25

### Receiver offhook ###
# Frequency 1 (Hz)
P2827 = 1400
# Frequency 2 (Hz)
P2847 = 2600
# ON (x 10ms)
P2867 = 10
# OFF (x 10ms)
P2887 = 10

##### Distinct Ring Tones #####
#
# For HT496 only
#
### Ring1 ###
# Frequency 1 (Hz)
P2828 = 440
# Frequency 2 (Hz)
P2848 = 440
# ON (x 10ms)
P2868 = 100
# OFF (x 10ms)
P2888 = 100

### Ring2 ###
# Frequency 1 (Hz)
P2829 = 440
# Frequency 2 (Hz)
P2849 = 440
# ON (x 10ms)
P2869 = 100
# OFF (x 10ms)
P2889 = 100
 
### Ring3 ###
# Frequency 1 (Hz)
P2830 = 440
# Frequency 2 (Hz)
P2850 = 440
# ON (x 10ms)
P2870 = 100
# OFF (x 10ms)
P2890 = 100

### Ring4 ###
# Frequency 1 (Hz)
P2831 = 440
# Frequency 2 (Hz)
P2851 = 440
# ON (x 10ms)
P2871 = 100
# OFF (x 10ms)
P2891 = 100

### Ring5 ###
# Frequency 1 (Hz)
P2832 = 440
# Frequency 2 (Hz)
P2852 = 440
# ON (x 10ms)
P2872 = 100
# OFF (x 10ms)
P2892 = 100

### Ring6 ###
# Frequency 1 (Hz)
P2833 = 440
# Frequency 2 (Hz)
P2853 = 440
# ON (x 10ms)
P2873 = 100
# OFF (x 10ms)
P2893 = 100

### Ring7 ###
# Frequency 1 (Hz)
P2834 = 20
# Frequency 2 (Hz)
P2854 = 20
# ON (x 10ms)
P2874 = 80
# OFF (x 10ms)
P2894 = 40

### Ring8 ###
# Frequency 1 (Hz)
P2835 = 20
# Frequency 2 (Hz)
P2855 = 20
# ON (x 10ms)
P2875 = 40
# OFF (x 10ms)
P2895 = 20

### Ring9 ###
# Frequency 1 (Hz)
P2836 = 20
# Frequency 2 (Hz)
P2856 = 20
# ON (x 10ms)
P2876 = 30
# OFF (x 10ms)
P2896 = 20

### Ring10 ###
# Frequency 1 (Hz)
P2837 = 20
# Frequency 2 (Hz)
P2857 = 20
# ON (x 10ms)
P2877 = 50
# OFF (x 10ms)
P2897 = 800

### Ring11 ###
# Frequency 1 (Hz)
P2838 = 20
# Frequency 2 (Hz)
P2858 = 20
# ON (x 10ms)
P2878 = 200
# OFF (x 10ms)
P2898 = 400

### Ring12 ###
# Frequency 1 (Hz)
P2839 = 20
# Frequency 2 (Hz)
P2859 = 20
# ON (x 10ms)
P2879 = 200
# OFF (x 10ms)
P2899 = 400

# Volume Amplification
# TX 
# <value=1> +6dB
# <value=2> +4dB
# <value=3> +2dB
# <value=0> 0dB
# <value=4> -2dB
# <value=5> -4dB
# <value=6> -6dB
P248 = 0 

# RX 
# <value=1> +6dB
# <value=2> +4dB
# <value=3> +2dB
# <value=0> 0dB
# <value=4> -2dB
# <value=5> -4dB
# <value=6> -6dB
P250 = 0

#--------------------------------------------------------------------
# The following 4 fields are for HT488 FXO Port only
#--------------------------------------------------------------------
# PSTN AC Termination Impedance
#
#  <value=0 selected >600 Ohm (North America)
#  <value=1          >900 Ohm</option>
#  <value=2          >270 Ohm + (750 Ohm || 150 nF) and 275 Ohm + (780 Ohm || 150 nF)
#  <value=3          >220 Ohm + (820 Ohm || 120 nF) and 220 Ohm + (820 Ohm || 115 nF)
#  <value=4          >370 Ohm + (620 Ohm || 310 nF)
#  <value=5          >320 Ohm + (1050 Ohm || 230 nF))
#  <value=6          >370 Ohm + (820 Ohm || 110 nF)
#  <value=7          >275 Ohm + (780 Ohm || 150 nF)
#  <value=8          >120 Ohm + (820 Ohm || 110 nF)
#  <value=9          >350 Ohm + (1000 Ohm || 210 nF)
#  <value=10         >0  Ohm + (900 Ohm || 30 nF)
#  <value=11         >600 Ohm + 2.16 uF
#  <value=12         >900 Ohm + 1 uF
#  <value=13         >900 Ohm + 2.16 uF
#  <value=14         >600 Ohm + 1 uF
#  <value=15         >Global complex impedance
P800 = 0

# PSTN Disconnect Tone. 0 - inactive, default is 480Hz and 620Hz.
# Frequency f1
P801 = 480
# Frequency f2
P802 = 620

# PSTN Disconnect Tone Cadence. 0 - Disabled. Default is 0.
# Choice 1, On
P804 = 0
# Choice 1, Off
P805 = 0
# Choice 2, On
P806 = 0
# Choice 2, Off
P807 = 0
# Choice 3, On
P808 = 0
# Choice 3, Off
P809 = 0

# PSTN Silence Timeout. In seconds, terminate call after long silence detected.
# default is 60 sec, max 65536.
P810 = 60

#################################################################################
## End User Settings. Please do not edit this section.
#################################################################################

# End User Password
#P196 = 123

# Web Port. Device internal HTTP server port number. Default is 80.
P901 = 80

# DHCP support. 0 - yes, 1 - no
#P8 = 0

# Host name, DHCP option 12. Max length allowed is 32 bytes.
P146 =

# Domain name, DHCP option 15. Max length allowed is 32 bytes.
P147 =

# Vendor Class ID, DHCP option 60. Max length allowed is 32 bytes.
P148 = 

# PPPoE support. PPPoE user ID
#P82 =

# PPPoE password
#P83 =

# PPPoE Service Name
#P269 =

# IP Address. Ignore if DHCP or PPPoE is used
#P9 = 
#P10 = 
#P11 = 
#P12 = 

# Subnet mask. Ignore if DHCP or PPPoE is used
#P13 = 255
#P14 = 255
#P15 = 255
#P16 = 0

# Router. Ignore if DHCP or PPPoE is used
#P17 = 
#P18 = 
#P19 = 
#P20 = 

# Preferred DNS server.  (if specified).
#P92 = 
#P93 = 
#P94 = 
#P95 = 

# DNS 1. Ignore if DHCP or PPPoE is used
#P21 = 
#P22 = 
#P23 = 
#P24 = 

# DNS 2. Ignore if DHCP or PPPoE is used
#P25 = 0
#P26 = 0
#P27 = 0
#P28 = 0

# Time Zone. Offset in minutes to GMT
#P64 = 420

# Daylight Savings Time. 0 - no, 1 - yes
#P75 = 0

# Optional Rule. Daylight Saving rule.
P246 = 4,1,7,2,0;10,-1,7,2,0;60

# PSTN Access Code.   Default = *00
# HT488/386 only
#P195 = 

#------------------------------------------------------------------------
# HandyTone 488/496 End User Specific NAT Settings.
#------------------------------------------------------------------------

# Device Mode. 0 - NAT Router, 1 - Bridge. Default is 0.
# HT496 only
#P231 = 0

#Cloned WAN MAC Address.
#P115 =
#P116 =
#P117 =
#P118 =
#P119 =
#P120 =

#LAN Subnet Mask.  Example: 255.255.255.224
#P110 = 

#LAN Base/Gateway/Router IP for the LAN port, default is 192.168.2.1.
#P111 = 

#DHCP IP Lease Time, in units of hours, default is 120 hours or 5 days.
#P112 = 120

#DMZ IP.
#P113 =

#-----------------------------------------------------------
# Port Forwarding Settings.
#-----------------------------------------------------------

#############  Choice 1 ####################################
# WAN Port
P150 =
# LAN IP
P158 =
# LAN Port
P166 =
# Protocol.  0 - UDP Only, 1 - TCP Only, 2 - TCP and UDP.
P174 =
#############  Choice 2 ####################################
# WAN Port
P151 =
# LAN IP
P159 =
# LAN Port
P167 =
# Protocol.  0 - UDP Only, 1 - TCP Only, 2 - TCP and UDP.
P175 =
#############  Choice 3 ####################################
# WAN Port
P152 =
# LAN IP
P160 =
# LAN Port
P168 =
# Protocol.  0 - UDP Only, 1 - TCP Only, 2 - TCP and UDP.
P176 =
#############  Choice 4 ####################################
# WAN Port
P153 =
# LAN IP
P161 =
# LAN Port
P169 =
# Protocol.  0 - UDP Only, 1 - TCP Only, 2 - TCP and UDP.
P177 =
#############  Choice 5 ####################################
# WAN Port
P154 =
# LAN IP
P162 =
# LAN Port
P170 =
# Protocol.  0 - UDP Only, 1 - TCP Only, 2 - TCP and UDP.
P178 =
#############  Choice 6 ####################################
# WAN Port
P155 =
# LAN IP
P163 =
# LAN Port
P171 =
# Protocol.  0 - UDP Only, 1 - TCP Only, 2 - TCP and UDP.
P179 =
#############  Choice 7 ####################################
# WAN Port
P156 =
# LAN IP
P164 =
# LAN Port
P172 =
# Protocol.  0 - UDP Only, 1 - TCP Only, 2 - TCP and UDP.
P180 =
#############  Choice 8 ####################################
# WAN Port
P157 = 
# LAN IP
P165 = 
# LAN Port
P173 = 
# Protocol.  0 - UDP Only, 1 - TCP Only, 2 - TCP and UDP.
P181 = 

#-------------------------------------------------------------------------------
# HandyTone 488 Specific End User Settings. 
#-------------------------------------------------------------------------------

# Number of Rings (Number of FXS phone rings for FXO incoming PSTN calls before bridgeing to VoIP)
# Default is 4.
#P798 = 4

# PIN for PSTN Calls
#P794 = 

# PIN for VoIP Calls
#P795 =

# Route Call to PSTN (outbound calls will be routed to PSTN port when dialed digits match one of the following)
#P780 =
#P781 =
#P782 =
#P783 =
#P784 =
#P785 =
#P786 =
#P787 =
#P788 =
#P789 =

# Forward to PSTN (VoIP calls will be forwarded to the specified PSTN number) 
#P796 =

# Forward to VoIP (PSTN calls will be forwarded to the specified VoIP number)
#P797 =
EOF


chmod 666 /tftpboot/Grandstream_GXP2000_Default.txt
chmod 666 /tftpboot/Grandstream_HT386_Default.txt

echo "Created /tftpboot/Grandstream_GXP2000_Default.txt and"
echo "/tftpboot/Grandstream_HT386_Default.txt using $IPADDR for the"
echo "proxy. If the IP address of your Asterisk system changes run this script"
echo "again and reboot."
echo "Reboot your Grandstream phones by selecting reboot from the menu."
echo ""
