#!/bin/bash # # DStar Monitor installation script # Written by Brian Roode, NJ6N # # ****** CHANGE HISTORY ****** # Date | Who | Description of Change # -----------|-------|----------------------------------------------------------------- # 2007-10-13 | nj6n | Script creation (v1.0) # 2007-10-14 | nj6n | Added javAPRS configuation commands and decho installation (v1.1) # 2007-10-16 | nj6n | Added check for gateway conf files. Validated Range parameter; # nothing entered = 0 range, Removed numRptrs (not needed), added # update to CtrlrIP= parameter - set to ZR_ADDR parameter value. # Added query and setting for controller port number per Pete AE5PL. # 2007-11-22 | nj6n | Install dplus instead of decho now. # 2008-03-29 | nj6n | Updated for the G2 gateway system. # 2008-04-19 | nj6n | Added dsm init script installation commands... (2.1) # 2008-04-28 | nj6n | Updated for DSM verson 2.4 (installer v2.2) # 2008-04-29 | nj6n | Fixed bugs related to new installations (v2.3) # 2008-08-04 | nj6n | Updated DSM host name (v2.4) # # Fixed variable section # VERSION="2.4 August 4, 2008 nj6n" # SVR=0 CURL="/usr/bin/curl --connect-timeout 60" RUN_DIR="/opt" DSYNC="http://dsyncg2.dstarusers.org" DSM_PROP="/opt/dstarmon/dstarmonitor.properties" DSETUP="dsetup.dstarusers.org" LIB="compat-libstdc++-296" APRS="/opt/dstarmon/javaprssrvr" DSIPSVD="/opt/products/dstar/dstar_gw/dsipsvd/dsipsvd.conf" DSGWD="/opt/products/dstar/dstar_gw/dsgwd/dsgwd.conf" DSM_LOC=`$CURL $DSYNC/dstarmon_url 2>/dev/null` DSM_TAR=`echo $DSM_LOC | awk -F\/ '{print $4}'` DSM_DIR=/opt/dstarmon echo echo -e "\t\tWelcome to the D-STAR Monitor G2 installer" echo -e "\t\t Version $VERSION\n" if [ $UID != 0 ]; then echo "ERROR: You must have root privileges to execute this script." echo -e "\n\t#### Nothing done ####\n" exit; fi # Re-installation is the same as a first-time installation # Upgrade is the same except dstarmonitor.properites is copied to new dstarmon directory # Exit exits if [ -d $DSM_DIR ]; then echo echo -e "\tIt appears that you already have DStarMonitor installed.\n" echo -n "Options: (R)e-install or (U)pgrade or (E)xit: " INST='' while [ "X$INST" == "X" ]; do read INST INST=`echo $INST | tr [a-z] [A-Z]` if [ "X$INST" == "X" ]; then echo -n "Please select either R, U, or E: " fi done else echo echo -e "No previous installation found, installing..." INST='R' fi if [ "$INST" == "E" ]; then echo echo -e "\n\t#### Nothing done ####\n" exit fi # # Gateway must have already been configured before running # this installation script. Check for ICOM Gateway configuration # files. # if [ -f $DSIPSVD ] && [ -f $DSGWD ]; then GW_CALL=`egrep -e '^ZR_CALLSIGN' $DSIPSVD | sed -e 's/ //g' | awk -F"=" '{print $2}' |sed -e 's/\r//'` ZR_ADDR=`egrep -e '^ZR_ADDR' $DSGWD | sed -e 's/ //g' | awk -F"=" '{print $2}' |sed -e 's/\r//'` echo -e "\tGateway: $GW_CALL\n"; else echo echo "ERROR: $DSIPSVD and $DSGWD must both exist!" echo "Please configure your gateway and then re-run this script." echo exit fi if [ -d $DSM_DIR ]; then /sbin/service dsm stop sleep 2 fi # # check for necessary library # echo "Verifying library $LIB is installed." RC=`rpm -verify $LIB > /dev/null 2>&1` if [ $? != 0 ]; then echo "### Library is not installed." echo "Installing Library \"$LIB\" using /usr/bin/yum." `/usr/bin/yum -y install $LIB > /tmp/$LIB.log 2>&1` if [ $? != 0 ]; then echo echo "Installing necessary library, $LIB FAILED" echo "Check /tmp/$LIB.log for error report. You will" echo "need to fix this before DStarMonitor will run properly." else echo echo "Successfully installed: $LIB" echo "Check /tmp/$LIB.log for more information on installation." fi else echo "*** $LIB is already installed." fi # # if DSM directory exists, move it to a backup location. # if [ -d $DSM_DIR ]; then DSM_BAK=/opt/dstarmon-`date +%Y%m%d-%H%M%S` echo -e -n "\nMoving $DSM_DIR to $DSM_BAK ... " mv -f $DSM_DIR $DSM_BAK echo "[Done]"; fi # # Download the DStarMonitor Tar archive # echo -n "Downloading DStarMonitor... " cd /tmp $CURL -O $DSM_LOC 2>/dev/null if [ $? != 0 ]; then echo "[FAILED]" exit else echo "[Done]" fi # # Change to root directory before extracting files # cd / echo echo -n "Installing DStarMonitor applications... " gzip -dc /tmp/$DSM_TAR | tar -xf - if [ $? != 0 ]; then echo "[FAILED]" exit else echo "[Done]" fi cd # # D-STAR Monitor configuration secdtion. Obtain system particulars from gateway # administrator. Update necessary configuration files. # # NOTE: If this is an upgrade, copy the old dstarmonitor.properties file over, otherwise # re-ask the configuration questions for a re-installation. # if [ "$INST" != "U" ]; then echo echo " **** DStarMonitor Configuration ****" echo if [ ! -f $DSM_PROP ]; then echo "Can't find: $DSM_PROP!" exit fi LAT="" while [ "X$LAT" == "X" ]; do echo echo "Please enter repeater LATITUDE in DECIMAL degrees." echo "Enter a negative value for the Southern Hemisphere" echo -n "For example, enter 32.9628 or -32.9500: " read LAT if [ "X$LAT" == "X" ]; then echo echo " Latitude value must be specified!" fi done LONG="" while [ "X$LONG" == "X" ]; do echo echo "Please enter repeater LONGITUDE in DECIMAL degrees." echo "Enter a negative value for the Western Hemisphere" echo -n "For example, enter 96.4427 or -96.4427: " read LONG if [ "X$LONG" == "X" ]; then echo echo "Longitude value must be specified!" fi done # # Obtain VOICE Module "A" information, usually on controller port 1 # echo echo "Repeater 'A' Voice Frequency and offset, to skip (no repeater) 'A' " echo -n "For example: '1295.1295 -20 MHz': " read DESC_A if [ -n "$DESC_A" ]; then SVR=`expr $SVR + 1` echo echo "Enter your repeater coverage area, estimated in Miles" echo -n "For example, 40: " RANGE=0 while [ "X$RANGE" == "X" ] || \ [ $RANGE -lt 1 ]; do read RANGE if [ "X$RANGE" == "X" ] || \ [ $RANGE -lt 1 ]; then echo "Please enter a valid range, greater than 0 miles." fi done sed -i -e "s/repeaterIDA=.*/repeaterIDA=$LAT;$LONG;$RANGE;1.2 Voice $DESC_A/" $DSM_PROP else sed -i -e "s/repeaterIDA=/# repeaterIDA=/" $DSM_PROP fi # # Obtain DATA Module "A" information, usually onc ontroller port 2 # echo echo "Repeater 'A' Data Frequency, for NO Data Repeater 'A' " echo -n "For example: '1299.900 MHz': " read DESC_AD if [ -n "$DESC_AD" ]; then echo echo "Enter your repeater coverage area, estimated in Miles" echo -n "For example, 40: " RANGE=0 while [ "X$RANGE" == "X" ] || \ [ $RANGE -lt 1 ]; do read RANGE if [ "X$RANGE" == "X" ] || \ [ $RANGE -lt 1 ]; then echo "Please enter a valid range, greater than 0 miles." fi done sed -i -e "s/repeaterIDAD=.*/repeaterIDAD=$LAT;$LONG;$RANGE;1.2 Data $DESC_AD/" $DSM_PROP else sed -i -e "s/repeaterIDAD=/# repeaterIDAD=/" $DSM_PROP fi # # Obtain VOICE Module "B" information, usually on controller port 3 # echo echo "Repeater 'B' Voice Frequency and offset, to skip (no repeater) 'B' " echo -n "For example: 445.660 +5.00 MHz': " read DESC_B if [ -n "$DESC_B" ]; then SVR=`expr $SVR + 1` echo echo "Enter your repeater coverage area, estimated in Miles" echo -n "For example, 40: " RANGE=0 while [ "X$RANGE" == "X" ] || \ [ $RANGE -lt 1 ]; do read RANGE if [ "X$RANGE" == "X" ] || \ [ $RANGE -lt 1 ]; then echo "Please enter a valid range, greater than 0 miles." fi done sed -i -e "s/repeaterIDB=.*/repeaterIDB=$LAT;$LONG;$RANGE;440 Voice $DESC_B/" $DSM_PROP else sed -i -e "s/repeaterIDB=/# repeaterIDB=/" $DSM_PROP fi # # Obtain VOICE Module "C" information, usually on controller port 4 # echo echo "Repeater 'C' Voice Frequency and offset, to skip (no repeater) 'C' " echo -n "For example: '146.115 +0.600 MHz': " read DESC_C if [ -n "$DESC_C" ]; then SVR=`expr $SVR + 1` echo echo "Enter your repeater coverage area, estimated in Miles" echo -n "For example, 40: " RANGE=0 while [ "X$RANGE" == "X" ] || \ [ $RANGE -lt 1 ]; do read RANGE if [ "X$RANGE" == "X" ] || \ [ $RANGE -lt 1 ]; then echo "Please enter a valid range, greater than 0 miles." fi done sed -i -e "s/repeaterIDC=.*/repeaterIDC=$LAT;$LONG;$RANGE;2m Voice $DESC_C/" $DSM_PROP else sed -i -e "s/repeaterIDC=/# repeaterIDC=/" $DSM_PROP fi else echo -e -n "\nUsing existing configuration files ... " mv -f $DSM_DIR/dstarmonitor.properties $DSM_DIR/dstarmonitor.properties.original cp -f $DSM_BAK/dstarmonitor.properties $DSM_DIR/dstarmonitor.properties cp -f $DSM_BAK/javaprssrvr?.cfg $DSM_DIR/. echo "[Done]" fi echo echo "Setting CtrlrIP Address to: $ZR_ADDR" sed -i -e "s/CtrlrIP=.*/CtrlrIP=$ZR_ADDR/" $DSM_PROP echo echo -n "Updating DSM Properites for $GW_CALL ... " sed -i -e "s/callsign=.*/callsign=$GW_CALL/" $DSM_PROP sed -i -e "s/d-starusers.org/dsm.dstarusers.org/i" $DSM_PROP echo "[Done]" # # create the log file touch /var/log/dstarmon.log # # Copy capture library into java runtime directory # cp /opt/dstarmon/jpcap-0.01.16/libjpcap.so /opt/products/dstar/j2se/jre/lib/i386/. cd /etc/init.d echo -n "Downloading dsm init script... " /usr/bin/curl -O dsyncg2.dstarusers.org/dsm > /dev/null 2>&1 if [ $? == 0 ]; then echo "[Done]" else echo "[FAILED]" exit fi echo -n "Installing init script... " /bin/chmod 755 dsm /sbin/chkconfig --add dsm echo "[Done]" /sbin/service dsm start sleep 5 /sbin/service dsm status echo echo "Here is the DStarMonitor Log file, no errors should be shown here:" echo echo "tail /var/log/dstarmon.log" echo "-----------------------------------------------------------------------" tail /var/log/dstarmon.log echo echo "IMPORTANT NOTE: Complete documentation can be found in the directory: $DSM_DIR/docs" echo /bin/ls $DSM_DIR/docs echo echo -e "\t\tInstallation is complete." echo