#!/bin/bash read -p "What is your node number? " NODE read -sp "What is your password? " PASSWORD REG_SERVER=register.mygmrs.com NODE_VERSION=12.18.3 x86=false i386=false amd64=false arm=false arm64=false case $(dpkg --print-architecture) in i386 ) x86=true i386=true echo "WARNING - this tool not testing on i386 (32-bit)" echo -e "\tIf you want to continue modify this script to remove the exit line" exit -1 ;; amd64 ) x86=true amd64=true ;; arm64 ) arm=true arm64=true ;; *) echo "ERROR: architecture $(dpkg --print-architecture) not supported, contact author" exit -2 ;; esac DIFF=$((999999-100000+1)) RANDOM=$$ R=$(($(($RANDOM%$DIFF))+100000)) echo "RepeaterFinder Configuration Script" echo "Node: $NODE" echo "Installing Git..." apt-get update apt-get install -y git echo "Configuring Asterisk..." cd /etc/asterisk echo "Setting link to GMRS external nodes list..." sed -i "/; rxchannel = USRP\/127.0.0.1:34001:32001; GNU Radio interface USRP/aextnodefile = /var/lib/asterisk/rpt_extnodes_gmrs" rpt.conf echo "Set SimpleUSB as the channel driver..." sed -i "s/rxchannel = dahdi\/pseudo/; rxchannel = dahdi\/pseudo/" rpt.conf sed -i "s/; rxchannel = SimpleUSB\/usb_1999/rxchannel = SimpleUSB\/usb_1999/" rpt.conf echo "Set statistics server URL..." sed -i "s/;statpost_program/statpost_program/" rpt.conf sed -i "s/--output-document=\/dev\/null/--output-document=\/dev\/null,--no-check-certificate/" rpt.conf sed -i "s/;statpost_url = http:\/\/stats.allstarlink.org\/uhandler.php/statpost_url = https:\/\/link.mygmrs.com\/stats\/update/" rpt.conf echo "Setting node number in rpt.conf..." sed -i "s/1999/$NODE/g" rpt.conf echo "Setting node number in extensions.conf..." sed -i "s/1999/$NODE/" extensions.conf echo "Setting node number in iax.conf..." sed -i "s/; register = 1999:123456@register.allstarlink.org/register = $NODE:$PASSWORD@$REG_SERVER/" iax.conf echo "Setting random password for iaxrpt and iaxclient accounts in iax.conf..." sed -i "s/Your_Secret_Pasword_Here/$R/" iax.conf sed -i "s/Your_Secret_Password_Here/$R/" iax.conf echo "Setting node number in savenode.conf..." sed -i "s/1999/$NODE/" savenode.conf echo "Setting node number in simpleusb.conf..." sed -i "s/1999/$NODE/" simpleusb.conf echo "Setting node number in usbradio.conf..." sed -i "s/1999/$NODE/" usbradio.conf echo "Renaming simpleusb_tune_usb_1999.conf..." [ -f simpleusb_tune_usb_1999.conf ] && mv simpleusb_tune_usb_1999.conf simpleusb_tune_usb_$NODE.conf echo "Renaming usbradio_tune_usb_1999.conf..." [ -f usbradio_tune_usb_1999.conf ] && mv usbradio_tune_usb_1999.conf usbradio_tune_usb_$NODE.conf echo "Enable SimpleUSB driver module..." sed -i "s/noload => chan_simpleusb.so/load => chan_simpleusb.so/" modules.conf echo "Reloading asterisk configuration..." service asterisk restart echo "Modifying rc.updatenodelist..." sed -i "/verbose=0/a\$WGET -q -O /var/lib/asterisk/rpt_extnodes_gmrs https://link.mygmrs.com/nodes" /usr/local/bin/rc.updatenodelist cd /root echo "Downloading Node.js..." ${arm64} && wget https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-armv7l.tar.xz ${amd64} && curl -sL https://deb.nodesource.com/setup_current.x | sudo -E bash - ${i386} && curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash - ${arm64} && echo "Unpacking Node.js..." ${arm64} && tar -xvf node-v$NODE_VERSION-linux-armv7l.tar.xz echo "Installing node and npm binaries..." ${arm64} && ln -s /root/node-v$NODE_VERSION-linux-armv7l/bin/node /usr/bin/node ${arm64} && ln -s /root/node-v$NODE_VERSION-linux-armv7l/bin/npm /usr/bin/npm ${x86} && apt-get install -y nodejs echo "Downloading rpt-cmd..." git clone https://github.com/richdunajewski/rpt-cmd.git echo "Installing rpt-cmd node dependencies..." cd rpt-cmd npm install cd .. echo "Installing PM2..." npm install -g pm2 ${arm64} && ln -s /root/node-v$NODE_VERSION-linux-armv7l/lib/node_modules/pm2/bin/pm2 /usr/bin/pm2 echo "Running rpt-cmd..." pm2 start /root/rpt-cmd/app.js --name "rpt-cmd-"$NODE"" -- --host nodemgr.mygmrs.com --port 443 --ssl --node $NODE echo "Setting rpt-cmd to run at boot..." pm2 save pm2 startup echo "Setting hostname..." hostname node-$NODE echo "node-"$NODE"" > /etc/hostname echo "Updating hosts file..." echo "127.0.1.1 node-"$NODE"" >> /etc/hosts echo "Installing update-node-list client..." cd /root git clone https://github.com/richdunajewski/update-node-list.git cd update-node-list npm install echo "Adding update-node-list to crontab..." (crontab -l 2>/dev/null; echo "*/10 * * * * /usr/bin/node /root/update-node-list/app.js") | crontab - ${x86} && echo "Fixing dahdi..." ${x86} && dpkg-reconfigure asl-dahdi-linux-dkms echo "Configuration complete! Restarting..." reboot exit 0