Skip to content
This repository has been archived by the owner on Nov 25, 2022. It is now read-only.

Commit

Permalink
ICTSC5 edition
Browse files Browse the repository at this point in the history
  • Loading branch information
icchy committed Mar 2, 2016
0 parents commit b608b1c
Show file tree
Hide file tree
Showing 6 changed files with 446 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# config file generator for Cisco IP Phone (7960/7961)
## Usage
```
# just update tftp directory
python confgen.py ipphone.conf models.conf
# update sip.conf
sudo python confgen.py ipphone.conf models.conf
```

* `ipphone.conf` - MAC Address of IP Phone and Phone name etc.
* `models.conf` - map of model and firmware
98 changes: 98 additions & 0 deletions confgen.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import ConfigParser
import os
import sys

TFTP_DIR = "/tftpboot"
ASTERISK_DIR = "/etc/asterisk"

config = ConfigParser.ConfigParser()
modelconf = ConfigParser.ConfigParser()
config.read(sys.argv[1])
modelconf.read(sys.argv[2])

phones = config.sections()
tftp_files = {}

sip_template_base = """[general]
context=default
port=5060
bindaddr=0.0.0.0
progressinband=no
language=ja
"""

sip_template_team = """[{number}]
type=friend
defaultuser={username}
username={username}
secret={password}
host=dynamic
conreinvite=no
"""

tftp_sip_template = """image_version:{version};
line1_name:{username};
line1_authname:{username};
line1_password:{password};
line1_displayname:{username};
line1_shortname:{name};
proxy1_address:172.16.2.10;
proxy1_port:5060;
time_zone:JST;
"""

tftp_xml_sip_template = open('septemplate.xml').read()


# dialplan
extension_dial_base = """[default]
"""

sccp_template_base = """[general]
bindaddr=0.0.0.0
bindport=2000
dateformat=Y-M-D
keepalive=120
[devices]
"""

sccp_template_device = """[{username}]
device=SEP{mac};
version={version};
context=default;
line={username};
"""

sip_default = sip_template_base
# sccp_default = sccp_template_base

for phone in phones:
param = dict(config.items(phone))
model = dict(modelconf.items(param['model']))
param['version'] = model['version']
param['conftype'] = model['conftype']

os.system("rm -f "+TFTP_DIR+"/"+"SIP"+param['mac']+".cnf")
os.system("rm -f "+TFTP_DIR+"/"+"SEP"+param['mac']+".cnf.xml")
sip_default += sip_template_team.format(**param)

if param['conftype'].upper() == "SIP":
tftp_files["SIP"+param['mac']+".cnf"] = tftp_sip_template.format(**param)
elif param['conftype'].upper() == "SEP":
# sccp_default += sccp_template_device.format(**param)
tftp_files["SEP"+param['mac']+".cnf.xml"] = tftp_xml_sip_template.format(**param)

# sip_default += sip_template_team.format(**param)
# sccp_default += sccp_template_device.format(**param)
# tftp_files["SEP"+param['mac']+".cnf.xml"] = tftp_xml_sip_template.format(**param)
# tftp_files["SIP"+param['mac']+".cnf"] = tftp_sip_template.format(**param)

for fname, s in tftp_files.items():
open(os.path.join(TFTP_DIR, fname), "w").write(s)

open(os.path.join(ASTERISK_DIR, "sip.conf"), "w").write(sip_default)
# open(os.path.join(ASTERISK_DIR, "skinny.conf"), "w").write(sccp_default)
127 changes: 127 additions & 0 deletions ipphone.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
[team1]
model=7960
mac=0015FA34858D
name=MOTHER4
number=501
username=501
password=pass

[team2]
model=7960
mac=0015FA3488B4
name=WCDI
number=502
username=502
password=pass

[team3]
model=7960
mac=0015FA348581
name=RabbitHouse
number=503
username=503
password=pass

[team4]
model=7960
mac=0015FA34867E
name=FJB-teclub
number=504
username=504
password=pass

[team5]
model=7961
mac=00152B8F3705
name=WAN_PUNK_MAN's
number=505
username=505
password=pass

[team6]
model=7960
mac=0015FA348607
name=KanaiLab
number=506
username=506
password=pass

[team7]
model=7960
mac=0015FA3485D5
name=Aso_Info_Business_College_CN
number=507
username=507
password=pass

[team8]
model=7960
mac=0015FA34858F
name=mi_chan
number=508
username=508
password=pass

[team9]
model=7961
mac=001562106CC2
name=\U1F62A
number=509
username=509
password=pass

[team10]
model=7960
mac=0015FA3488A0
name=Yakisoba
number=510
username=510
password=pass

[team11]
model=7961
mac=001562107134
name=Kayahara pan
number=511
username=511
password=pass

[team12]
model=7961
mac=001562106ECB
name=Puchi KAIT
number=512
username=512
password=pass

[team13]
model=7960
mac=0009B7D0F46A
name=Nakagawa_Public
number=513
username=513
password=pass

[team14]
model=7961
mac=001AA21706D9
name=MWC
number=514
username=514
password=514

[team15]
model=7961
mac=001AA2460125
name=kstm
number=515
username=515
password=515

[team16]
model=7961
mac=0017E0A1B29D
name=DMM.com lab
number=516
username=516
password=516
7 changes: 7 additions & 0 deletions models.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[7960]
version=P0S3-8-12-00
conftype=SEP

[7961]
version=SIP41.8-4-1SR2S
conftype=SEP
137 changes: 137 additions & 0 deletions septemplate.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
<device>
<loadInformation>{version}</loadInformation>

<deviceProtocol>SIP</deviceProtocol>
<devicePool>
<dateTimeSetting>
<dateTemplate>Y-M-D</dateTemplate>
<timeZone>Tokyo Standard Time</timeZone>
<ntps>
<ntp>
<name>172.16.2.10</name>
<ntpMode>Unicast</ntpMode>
</ntp>
</ntps>
</dateTimeSetting>

<callManagerGroup>
<members>
<member priority="0">
<callManager>
<name>Asterisk</name>
<description>Asterisk version 13</description>
<ports>
<ethernetPhonePort>2000</ethernetPhonePort>
<sipPort>5060</sipPort>
<securedSipPort>5061</securedSipPort>
</ports>
<processNodeName>172.16.2.10</processNodeName>
</callManager>
</member>
</members>
</callManagerGroup>
</devicePool>

<sipProfile>
<sipProxies>
<backupProxy>172.16.2.10</backupProxy>
<backupProxyPort>5060</backupProxyPort>
<emergencyProxy></emergencyProxy>
<emergencyProxyPort></emergencyProxyPort>
<outboundProxy></outboundProxy>
<outboundProxyPort></outboundProxyPort>
<registerWithProxy>true</registerWithProxy>
</sipProxies>

<sipCallFeatures>
<cnfJoinEnabled>true</cnfJoinEnabled>
<callForwardURI>x-cisco-serviceuri-cfwdall</callForwardURI>
<callPickupURI>x-cisco-serviceuri-pickup</callPickupURI>
<callPickupListURI>x-cisco-serviceuri-opickup</callPickupListURI>
<callPickupGroupURI>x-cisco-serviceuri-gpickup</callPickupGroupURI>
<meetMeServiceURI>x-cisco-serviceuri-meetme</meetMeServiceURI>
<abbreviatedDialURI>x-cisco-serviceuri-abbrdial</abbreviatedDialURI>
<rfc2543Hold>false</rfc2543Hold>
<callHoldRingback>2</callHoldRingback>
<localCfwdEnable>true</localCfwdEnable>
<semiAttendedTransfer>true</semiAttendedTransfer>
<anonymousCallBlock>2</anonymousCallBlock>
<callerIdBlocking>2</callerIdBlocking>
<dndControl>0</dndControl>
<remoteCcEnable>true</remoteCcEnable>
</sipCallFeatures>

<sipStack>
<sipInviteRetx>6</sipInviteRetx>
<sipRetx>10</sipRetx>
<timerInviteExpires>180</timerInviteExpires>
<timerRegisterExpires>3600</timerRegisterExpires>
<timerRegisterDelta>5</timerRegisterDelta>
<timerKeepAliveExpires>120</timerKeepAliveExpires>
<timerSubscribeExpires>120</timerSubscribeExpires>
<timerSubscribeDelta>5</timerSubscribeDelta>
<timerT1>500</timerT1>
<timerT2>4000</timerT2>
<maxRedirects>70</maxRedirects>
<remotePartyID>false</remotePartyID>
<userInfo>None</userInfo>
</sipStack>

<autoAnswerTimer>1</autoAnswerTimer>
<autoAnswerAltBehavior>false</autoAnswerAltBehavior>
<autoAnswerOverride>true</autoAnswerOverride>
<transferOnhookEnabled>false</transferOnhookEnabled>
<enableVad>false</enableVad>

g711ulaw
<dtmfAvtPayload>101</dtmfAvtPayload>
<dtmfDbLevel>3</dtmfDbLevel>
<dtmfOutofBand>avt</dtmfOutofBand>
<alwaysUsePrimeLine>false</alwaysUsePrimeLine>
<alwaysUsePrimeLineVoiceMail>false</alwaysUsePrimeLineVoiceMail>
<kpml>3</kpml>

<phoneLabel>{name}</phoneLabel>
<stutterMsgWaiting>2</stutterMsgWaiting>
<callStats>false</callStats>
<silentPeriodBetweenCallWaitingBursts>10</silentPeriodBetweenCallWaitingBursts>
<disableLocalSpeedDialConfig>false</disableLocalSpeedDialConfig>
<startMediaPort>16384</startMediaPort>
<stopMediaPort>32766</stopMediaPort>

<sipLines>
<line button="1">
<featureID>9</featureID>
<featureLabel>{number}</featureLabel>
<proxy>172.16.2.10</proxy>
<port>5060</port>
<name>{username}</name>
<displayName>{name}</displayName>
<authName>{username}</authName>
<authPassword>{password}</authPassword>
<sharedLine>false</sharedLine>
</line>
</sipLines>

<voipControlPort>5060</voipControlPort>
<dscpForAudio>184</dscpForAudio>
<ringSettingBusyStationPolicy>0</ringSettingBusyStationPolicy>
</sipProfile>

<commonProfile>
<phonePassword>toracon</phonePassword>
</commonProfile>

<vendorConfig>
<settingsAccess>1</settingsAccess>
<garp>0</garp>
<voiceVlanAccess>0</voiceVlanAccess>
<videoCapability>0</videoCapability>
<autoSelectLineEnable>0</autoSelectLineEnable>
<webAccess>0</webAccess>
</vendorConfig>

<userLocale>
<langCode>ja</langCode>
</userLocale>
</device>
Loading

0 comments on commit b608b1c

Please sign in to comment.