diff --git a/repeaterfinder.anonymous.sh b/repeaterfinder.anonymous.sh new file mode 100644 index 0000000..2dc818b --- /dev/null +++ b/repeaterfinder.anonymous.sh @@ -0,0 +1,126 @@ +#!/bin/bash + +NODE= +PASSWORD= +REG_SERVER=register.mygmrs.com +NODE_VERSION=12.18.3 + +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..." +wget https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-armv7l.tar.xz + +echo "Unpacking Node.js..." +tar -xvf node-v$NODE_VERSION-linux-armv7l.tar.xz + +echo "Installing node and npm binaries..." +ln -s /root/node-v$NODE_VERSION-linux-armv7l/bin/node /usr/bin/node +ln -s /root/node-v$NODE_VERSION-linux-armv7l/bin/npm /usr/bin/npm + +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 +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 - + +echo "Configuration complete! Restarting..." + +reboot + +exit 0