#!/bin/bash # rpt_install # installs app_rpt as part of full system install # All Rights Reserved. Copyright (c)2008 Xelatec, LLC # http://www.xelatec.com # Author: Steven Henke, sph@xelatec.com # 20080911 0930 Steven Henke sph@xelatec.com # # $Date: 2008-05-14 16:44:53 -0400 (Wed, 14 May 2008) $ # $Revision: 514 $ # $Author: shenke $ # # cd /usr/local/bin # rm svn_2_app_rpt # wget -r http://www.xelatec.com/asterisk/svn_2_app_rpt # # # grep $target $conf > /dev/null 2>&1 # res=$? # if [ $res = 1 ] is true if not found # appsrcdir=/usr/src/EVB versAsterisk=1.4.21.2 versZaptel=1.14.12 APPINSTALLED=/etc/EVB/app_rpt_installed verbose=0 # yall=0 devel=0 testmode=0 evb1first=0 # haveusbadapter=0 havequadradio=0 havearib=0 uprit="" previnstall=0 wipeit=0 ufqdn="" unodenum="" uiaxport="" text="" usvnpath="" # # must do because of variable scope if [ -e /etc/EVB/app.conf ]; then echo "NOTICE: Found and loading configuration file /etc/EVB/app.conf." . /etc/EVB/app.conf else echo "ERROR: Unable to find configuration file /etc/EVB/app.conf." exit 1 fi # # # # ********************************************************************* # define functions # # # remove file if not a link # rmifnotlink() { linkfile=$linkdir/$sourcefile echo "rmifnotlink for $linkfile" if [ -e $linkfile ]; then if ! [ -L $linkfile ]; then if [ $testmode = 1 ]; then echo "rmifnot would rm : $linkfile" else # echo "rm -fR $linkfile" rm -fR $linkfile fi else unlink $linkfile fi fi # if ! [ -L $linkfile ]; then echo "ln -s $targetdir/$sourcefile $linkfile" ln -s $targetdir/$sourcefile $linkfile fi } # # copy with permissions # cpwp() { fullsource=$srcroot/$target fulldest=$destroot/$target # echo "cpwp $fullsource $fulldest" if ! [ -e $fullsource ]; then echo "ERROR: $fullsource does not exist" exit 1 fi if ! [ -d $destroot ]; then echo "ERROR: $destbase does not exist" exit 1 fi cp -p $fullsource $fulldest chown asterisk:asterisk $fulldest } # mod_app_config() { # sed -i "s/$AVAR=XXX/$AVAR=$AVAL/g" /etc/EVB/app.conf sed -i "s/^$AVAR.*$/$AVAR=$AVAL/g" /etc/EVB/app.conf } # # modify config files # modconfigs() { echo "" echo "Modifying asterisk .conf files..." echo "" # cd /etc/asterisk confignow=rpt.conf # if ! [ .$unodenum = "." ]; then sed -i "s/xxx_RPT_NODE_1/$unodenum/g" $confignow APP_NODE=$unodenum AVAR=APP_NODE AVAL=$APP_NODE mod_app_config fi # if ! [ .$unodepasswd = "." ]; then if [ $APP_XIPPR = 1 ]; then sed -i "s/stats\.allstarlink\.org/xippr-stats\.xelatec\.com/g" $confignow else sed -i "s/;statpost_/statpost_/g" $confignow fi APP_NODE_PASSWORD=$unodepasswd AVAR=APP_NODE_PASSWORD AVAL=$APP_NODE_PASSWORD mod_app_config fi # if ! [ .$ufqdn = "." ]; then sed -i "s/xxx_RPT_NODE_FQDN/$ufqdn/g" $confignow APP_FQDN=$ufqdn AVAR=APP_FQDN AVAL=$APP_FQDN mod_app_config fi if ! [ .$callsign = "." ]; then sed -i "s/xxx_RPT_NODE_CALLSIGN_1/$callsign/g" $confignow APP_CALLSIGN=$callsign AVAR=APP_CALLSIGN AVAL=$APP_CALLSIGN mod_app_config fi # confignow=iax_rpt_custom.conf if ! [ .$iaxrptpasswd = "." ]; then sed -i "s/xxx_RPT_NODE_IAXRPT_PASSWD/$iaxrptpasswd/g" $confignow APP_IAX_PASSWORD=$iaxrptpasswd AVAR=APP_IAX_PASSWORD AVAL=$APP_IAX_PASSWORD mod_app_config fi # confignow=extensions_rpt_custom.conf if ! [ .$unodenum = "." ]; then sed -i "s/xxx_RPT_NODE_1/$unodenum/g" $confignow fi # ta="0" tb="0" if ! [ .$priduplex = "." ]; then if [ .$priduplex = "y" ]; then ta="2" tb="1" fi fi APP_RDUPLEX=$tb AVAR=APP_RDUPLEX AVAL=$APP_RDUPLEX mod_app_config confignow=rpt.conf sed -i "s/xxx_RPT_NODE_DUPLEX_1/$ta/g" $confignow confignow=usbradio.conf sed -i "s/xxx_RPT_NODE_USB_DUPLEX_1/$tb/g" $confignow # ta=4569 if ! [ .$uiaxport = "." ]; then ta=4569 confignow=rpt.conf sed -i "s/xxx_RPT_NODE_IAXPORT/$uiaxport/g" $confignow confignow=iax_general_custom.conf # sed -i "s/4569/$uiaxport/" $confignow echo "bindport=$uiaxport" >> $confignow fi APP_RIAXPORT=$ta AVAR=APP_RIAXPORT AVAL=$APP_RIAXPORT mod_app_config # if ! [ .$uprit = "." ]; then confignow=rpt.conf if [ $uprit = "u" ]; then sed -i "s/xxx_RPT_NODE_CHANDEV_1/radio\/usb/g" $confignow elif [ $uprit = "p" ]; then sed -i "s/xxx_RPT_NODE_CHANDEV_1/radio\/zap1/g" $confignow fi APP_RINTERFACE=$uprit AVAR=APP_RINTERFACE AVAL=$APP_RINTERFACE mod_app_config fi # conf=/etc/asterisk/extensions_custom.conf target=extensions_rpt_custom.conf grep "$target" $conf > /dev/null 2>&1 res=$? if [ $res = 1 ]; then echo ";" >> $conf echo "#include $target" >> $conf fi # # so that g726aal2 works on radio links # conf=/etc/asterisk/iax_general_custom.conf target="bandwidth=high" if ! [ -e $conf ]; then touch $conf chown asterisk:asterisk $conf fi grep "$target" $conf > /dev/null 2>&1 res=$? if [ $res = 1 ]; then echo ";" >> $conf echo $target >> $conf fi # conf=/etc/asterisk/iax_custom.conf target='#include iax_rpt_custom.conf' if ! [ -e $conf ]; then touch $conf chown asterisk:asterisk $conf fi grep $target $conf > /dev/null 2>&1 res=$? if [ $res = 1 ]; then echo ";" >> $conf echo $target >> $conf fi # grep "pseudo" /etc/asterisk/zapata.conf > /dev/null 2>&1 res=$? if [ $res = 1 ]; then echo "" >> /etc/asterisk/zapata.conf echo "group=9" >> /etc/asterisk/zapata.conf echo "channel=pseudo" >> /etc/asterisk/zapata.conf fi # # Add Radio Over IP Network Register statement to iax_general_custom.conf # conf=/etc/asterisk/iax_registrations_custom.conf if [ $APP_XIPPR = 1 ]; then echo ";register=X$unodenum:$unodepasswd@xippr-reg.xelatec.com" >> $conf else echo "register=A$unodenum:$unodepasswd@register.allstarlink.org" >> $conf fi } # # cp configs # cpconfigs() { echo "" echo "Copying app_rpt .conf files to /etc/asterisk..." echo "" # srcroot=/usr/src/EVB/scripts/rpt/configs destroot=/etc/asterisk # target=rpt.conf cpwp # target=globals_rpt_custom.conf cpwp # target=usbradio.conf cpwp # target=iax_rpt_custom.conf cpwp # target=extensions_rpt_custom.conf cpwp # target=echolink.conf cpwp } # # get additional sounds # rpt_getsounds() { echo "rpt_getsounds()" # this is now being done elsewhere # could also install node names recordings but not yet # # tar xzf $SVNWORK/rpt-sounds/nodenames.tar.gz -C /var/lib/asterisk/sounds/ # # get better quality ulaw sounds # cd /tmp wget -N http://downloads.digium.com/pub/telephony/sounds/asterisk-core-sounds-en-ulaw-current.tar.gz wget -N http://downloads.digium.com/pub/telephony/sounds/asterisk-extra-sounds-en-ulaw-current.tar.gz cd /var/lib/asterisk/sounds tar /tmp/xzf asterisk-core-sounds-en-ulaw-current.tar.gz tar xzf /tmp/asterisk-extra-sounds-en-ulaw-current.tar.gz chown -R asterisk:asterisk * } # # put scripts into /usr/local/bin # rpt_putscripts() { echo "rpt_putscripts()" # cd $appsrcdir/scripts/rpt # cp -p ./rc.updatenodelist /usr/local/bin/. chown root:root /usr/local/bin/rc.updatenodelist chmod 700 /usr/local/bin/rc.updatenodelist # cp ./rpt_helper.sh /usr/local/bin/rpt_helper.sh chown root:root /usr/local/bin/rpt_helper.sh chmod 700 /usr/local/bin/rpt_helper.sh # cp ./permiblast /usr/local/bin/permiblast chown root:root /usr/local/bin/permiblast chmod 700 /usr/local/bin/permiblast # cp ./rpt_update /usr/local/bin/rpt_update chown root:root /usr/local/bin/rpt_update chmod 700 /usr/local/bin/rpt_update # cp ./rpt_update_a /usr/local/bin/rpt_update_a chown root:root /usr/local/bin/rpt_update_a chmod 700 /usr/local/bin/rpt_update_a # cp ./rpt_info_dump.sh /usr/local/bin/rpt_info_dump.sh chown root:root /usr/local/bin/rpt_info_dump.sh chmod 700 /usr/local/bin/rpt_info_dump.sh # cp ./96-xuri.rules /etc/udev/rules.d/96-xuri.rules chown root:root /etc/udev/rules.d/96-xuri.rules chmod 644 /etc/udev/rules.d/96-xuri.rules # cp ./xuri-udev-handler /usr/local/bin/xuri-udev-handler chown root:root /usr/local/bin/xuri-udev-handler chmod 755 /usr/local/bin/xuri-udev-handler # cp ./xurifind /usr/local/bin/xurifind chown root:root /usr/local/bin/xurifind chmod 755 /usr/local/bin/xurifind # } rpt_form() { echo "" echo "" echo "" echo "" echo "" echo "" echo "" echo "" echo "" echo "Initial PTT Radio Configuration Query. " echo "" echo "Your answers to the following questions are used in the initial" echo "configuration files. This information can be manually entered " echo "or changed later in the configuration files." echo "" if [ $APP_XIPPR = 1 ]; then echo "The primary radio interface type is USB." uprit="u" else echo -n "Select Primary Radio Interface Type p)ci, u)sb, c)ustom: " read uprit fi echo -n "Is the primary radio a full duplex repeater? (n/y): " read priduplex echo -n "Enter the station's callsign or press Enter for none: " read callsign echo "If it is defined, enter this machine's Fully Qualified Domain Name (FQDN)" echo -n "here or press Enter: " read ufqdn echo -n "If it is defined, enter this machine's primary radio node number: " read unodenum echo -n "If it is defined, enter this machine's primary radio node password: " read unodepasswd echo -n "If this server uses a non-standard IAX2 port number, enter it: " read uiaxport echo -n "Enter the password for iaxRpt client access: " read iaxrptpasswd # echo " " if ! [ .$uprit = "." ]; then echo -n "Using a primary radio interface of type " if [ $uprit = "a" ]; then echo "ARIB." elif [ $uprit = "u" ]; then echo "USB." elif [ $uprit = "p" ]; then echo "PCI." else echo "Custom." fi fi # if ! [ .$priduplex = "." ]; then echo -n "Primary Node Duplex: " if [ $priduplex = "y" ]; then echo "yes." else echo "no." fi fi # if ! [ .$ufqdn = "." ]; then echo -n "FQDN: " echo "$ufqdn" fi # if [ .$uiaxport = "." ]; then uiaxport="4569" fi # if ! [ .$uiaxport = "." ]; then echo -n "IAX2 port: " echo "$uiaxport" fi # if ! [ .$iaxrptpasswd = "." ]; then echo -n "iaxRpt Password: " echo "$iaxrptpasswd" fi # if ! [ .$unodenum = "." ]; then echo -n "Primary node number: " echo "$unodenum" fi # if ! [ .$unodepasswd = "." ]; then echo -n "Primary node registration password: " echo "$unodepasswd" fi # if ! [ .$callsign = "." ]; then echo -n "Primary Node Callsign: " echo "$callsign" fi # if [ $testmode = 1 ]; then echo "Running in test mode." fi # if [ $devel = 1 ]; then echo "Developement Option Enabled." fi # echo -n "Type e)dit or u)se, then press Enter:" read resp } # # install_uemacs() { # # check for MicroEMACS # if ! [ -e /usr/bin/emacs ]; then echo "You do not have micoEMACS. Installing..." cd /usr/src wget -N http://xelatec.com/asterisk/microemacs-5.03.tgz tar xvzf microemacs-5.03.tgz cd /usr/src/microemacs-5.03 sed -i 's/#define FRENCH\t1/#define FRENCH\t0/' ./estruct.h sed -i 's/#define ENGLISH 0/#define ENGLISH 1/' ./estruct.h make install -m 755 microemacs /usr/bin/emacs else echo "You have micoEMACS." fi } ######################################################################## # main process # echo "" echo "" echo "Start Xelatec Radio Installation. " echo "" # yall=0 install_uemacs resp="e" while [ "$resp" != u ] do rpt_form done # if [ .$resp = ."d" ]; then uprit="" ufqdn="" unodenum="" uiaxport="" usvnpath="" fi # if [ -e $APPINSTALLED ]; then previnstall=1 echo "Previous app_rpt installation found." else previnstall=0 # echo "No previous app_rpt installation found." fi # cpconfigs modconfigs # echo "" echo "app_rpt installation continues..." echo "" # # # check for libusb # if ! [ -e /usr/include/usb.h ]; then echo "You do not have libusb-devel. Installing..." # yum -y install libusb yum -y install libusb-devel fi # if ! [ -e /usr/include/usb.h ]; then echo "ERROR: Unable to source libusb." exit 0 fi # # modify freepbx_engine for permiblast # sed -i 's/\[ -e \/dev\/dsp ] && chown -R asterisk:asterisk \/dev\/dsp/\/usr\/local\/bin\/permiblast/' /var/lib/asterisk/bin/freepbx_engine # rpt_putscripts # # fix conflict between usb and onboard sound devices echo "blacklist snd-usb-audio" >> /etc/modprobe.d/blacklist sed -i '/^\/etc\/EVB\/apploader.sh/imodprobe snd-usb-audio; sleep 2' /etc/rc.local # if ! [ -e $APPINSTALLED ]; then # # mark that app_rpt has been installed # touch $APPINSTALLED # fi # echo "" #echo -n "Press Enter to continue install." #read text # # end of file #