#!/bin/bash#OpenSBC Debian#/bin/sh#Install OpenSBC - CentOS edition#Copyright (C) 2010 Star2Billing S.L.#Author Jonathan Roper jonathan@star2billing.com#This program is free software; you can redistribute it and/or#modify it under the terms of the GNU General Public License#as published by the Free Software Foundation; either version 2#of the License, or (at your option) any later version.#This program is distributed in the hope that it will be useful,#but WITHOUT ANY WARRANTY; without even the implied warranty of#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the#GNU General Public License for more details.#You should have received a copy of the GNU General Public License#along with this program; if not, write to the Free Software#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.#==================================================================================================#This script will install OpenSBC on an existing asterisk server, and will be available on port 5061#It will provide upwards registration, and RTP proxy services.#No configuration in Asterisk is required.#Simply point your phone at <<IPADDR>>:5061#If this is installed behind NAT, forward UDP 5061 and 10,000 > 20,000#==================================================================================================apt-get updateapt-get install -y mc autoconf automake cvs flex expat libexpat1-dev libtool build-essential libxml2 libxml2-dev
libtiff4 libtiff4-dev libssl-dev libncurses5-dev bison libaudiofile-dev subversion libnewt-dev libcurl3-dev
libnet-ssleay-perl openssl ssl-cert libauthen-pam-perl libio-pty-perl libcrypt-passwdmd5-perl libdigest-md5-perl
libpg-perl libdbd-pg-perl openssl ssl-cert flex bison build-essential libxml2 libxml2-dev expat libexpat1-dev libspeex-dev speexcd /usr/srcecho "================================================================================"echo "When prompted for a CVS password, just press enter"echo "================================================================================"cvs -d:pserver:anonymous@opensipstack.cvs.sourceforge.net:/cvsroot/opensipstack logincvs -z3 -d:pserver:anonymous@opensipstack.cvs.sourceforge.net:/cvsroot/opensipstack co -P opensipstackcvs -z3 -d:pserver:anonymous@opensipstack.cvs.sourceforge.net:/cvsroot/opensipstack co -P opensbccd /usr/src/opensipstack/chmod +x ./configure./configure --enable-localspeex --enable-gpllibsmake bothnosharedcd ../opensbcchmod +x ./configure./configure --enable-gpllibsmake bothnosharedmake distribcp /usr/src/opensbc/distrib/* /usr/local/bin/echo "/usr/local/bin/opensbc -d -p /var/run/opensbc.pid -H 65536 -C 1024000" > /usr/local/bin/startup.shecho "/usr/local/bin/opensbc -u root -k -p /var/run/opensbc.pid" > /usr/local/bin/shutdown.shecho "/usr/local/bin/startup.sh" >> /etc/rc.localmkdir /root/OpenSIPStackmkdir /root/OpenSIPStack/OpenSBC_dataecho "[OpenSBC-General-Parameters]SIP-Log-Level=1PTRACE-Log-Level=1Log-File-Prefix=b2buaSBC-Application-Mode=B2BUpperReg ModeEnable-Trunk-Port=TrueEnable-Calea-Port=TrueRTP-Min-Port=10000RTP-Max-Port=20000NAT-Keep-Alive-Interval=15Send-OPTIONS-NAT-Keep-Alive=TrueSend-Responses-Using-New-Socket=FalseEnable-Local-Refer=FalseDisable-Refer-Optimization=TrueMax-Forwards=70Encryption-Mode=XOREncryption-Key=GSAlerting-Timeout=30000Seize-Timeout=60000SIP-Timer-B=DefaultSIP-Timer-H=DefaultSession-Keep-Alive=1800Session-Max-Life-Span=10800Max-Concurrent-Session=100Max-Call-Rate-Per-Second=10[SIP-Transports]Main-Interface-Address Array Size=1Main-Interface-Address 1=sip:*:5061Backdoor-Interface-Address=sip:*:5062Trunk-Interface-Address=sip:*:5064Media-Server-Interface-Address=sip:*:5066CALEA-Interface-Address=sip:*:5068Auxiliary-Interface-Address=sip:*:5070Interface-Route-List Array Size=0[RTP-Proxy]Proxy-On-Private-Contact=TrueProxy-On-via-received-vs-signaling-address=TrueProxy-On-Private-Via=TrueProxy-On-Different-RPORT=TrueProxy-All-Media=False[Trusted-Domains]Accept-All-Calls=TrueTrusted-Domain-List Array Size=0X-Remote-Info-List Array Size=0[Host-Access-List]Trust-All-Hosts=TrueTrusted-Host-List Array Size=0Enable-Selective-Banning=TrueBanned-Host-List Array Size=0[Upper-Registration]All-Reg-As-Upper-Reg=TrueEnable-Stateful-Reg=FalseRewrite-TO-Domain=TrueRewrite-FROM-Domain=TrueRoute-List Array Size=1Route-List 1=[sip:*] sip:127.0.0.1:5060[B2BUA-Routes]Route-List Array Size=1Route-List 1=[sip:*] sip:127.0.0.1:5060Insert-Route-Header=TrueRewrite-TO-URI=TruePrepend-ISUP-OLI=FalseRoute-By-Request-URI=FalseRoute-By-To-URI=FalseDrop-Routes-On-Ping-Timeout=FalseUse-External-XML=FalseExternal-XML-File=b2bua-route.xml" > /root/OpenSIPStack/OpenSBC_data/OpenSBC.iniecho "================================================================================"echo "The web interface for this is on <<ipaddress>:9999"echo "By default it has no password on it"echo "After reboot, please go to the website and configure a username and password"echo "================================================================================"echo "Please reboot"echo "================================================================================"echo "1. http://11.22.33.44:9999/Internal-DNS-MappingThis is where we create the DNS entries for the internal IP addresses, this not compulsory, but it does make admin easier.So assuming you have pbx.yourdomain.com on 192.168.1.101,Create a DNS entry on your DNS server for pbx.yourdomain.com = 11.22.33.44Now add the internal DNS mapping with [sip:pbx.yourdomain.com] sip:192.168.1.101:5060Click the update button.Repeat as necessary for all PBX systems.2. http://11.22.33.44:9999/Upper-RegistrationNext we need to deal with the registration aspect, so that when you create an extension on a PBX, OpenSBC checks to see that it is valid.Edit Route list, and add entries for each of your PBX systems.[sip:*@pbx.yourdomain.com:*] sip:pbx.yourdomain.com:5060or if you have not bothered with Step one - [sip:*@pbx.yourdomain.com:*] sip:192.168.1.101:5060Then click the update buttonSo registrations that are sent to pbx.yourdomain.com will be forwarded to the internal PBX,
and if the username and password is correct, OpenSBC will allow the endpoint to register.
Note that the endpoint must be configured with the hostname, e.g. pbx.yourdomain.com, NOT 11.22.33.44Repeat as necessary for all PBX systems.3. http://11.22.33.44:9999/B2BUA-RoutesThis is how the call is actually routed when someone picks up the phone and makes a call.The syntax here is the same as in step 2 for upper registration, e.g.Edit Route list, and add entries for each of your PBX systems.[sip:*@pbx.yourdomain.com:*] sip:pbx.yourdomain.com:5060or if you have not bothered with Step one - [sip:*@pbx.yourdomain.com:*] sip:192.168.1.101:5060Then click the update button.4. Register your endpointNow attempt to register a phone to your extension@pbx.yourdomain.com and make a call.5. DID forwardingTo forward DID to your systems from your DID provider or A2Billing system, simply forward the DID to sip/DID-Number@pbx.yourdomain.comPlease test and test again, particularly in respect of MWI lights, extension to extension calls and check that it does what you need it do." > /root/OpenSIPStack/README