#!/bin/bash # Copyright 2022 Aaron Johnson ke0opk@ajserver.com based on works by Rich at MyGMRS.com (pending license information) # # Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. # #THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # End COPYRIGHT 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 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 "Enable SimpleUSB driver module..." sed -i "s/noload => chan_simpleusb.so/load => chan_simpleusb.so/" modules.conf 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 "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 "Disabling als-menu" chmod -x /usr/local/sbin/asl-menu echo "Configuration complete! Restarting..." reboot exit 0