Inital Commit

This commit is contained in:
Aaron Johnson 2022-01-28 20:24:57 -06:00
parent c98e7e2327
commit 20861c1a02
2 changed files with 224 additions and 0 deletions

104
MyGMRS_Configure.sh Executable file
View File

@ -0,0 +1,104 @@
#!/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
echo -e "This script is for use with Aaron's MyGMRS OVA virtual machine image only, no other use is supported"
echo -e " use ctrl-c to exit\n"
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
DIFF=$((999999-100000+1))
RANDOM=$$
R=$(($(($RANDOM%$DIFF))+100000))
echo "RepeaterFinder Configuration Script"
echo "Node: $NODE"
cd /etc/asterisk
DATE=`date +%Y%m%d%H%M%S`
for FILE in rpt.conf extensions.conf iax.conf savenode.conf simpleusb.conf usbradio.conf
if [ -e ${FILE}.org-$0 ]
then
if [ -e ${FILE} ]
then
if [ -e ${FILE}_bak-$DATE ]
then
echo "Error: Backup file ${FILE}_bak-$DATE already exists, not handled by this script"
exit -1
fi
# Backup existing configuration file before overwritting it
mv ${FILE} ${FILE}_bak-$DATE
fi
# restore orginal config to template version
/bin/cp -f ${FILE}.org-$0 ${FILE}
else
# Org file before running this script not found, create one
/bin/cp -f ${FILE} ${FILE}.org-$0
fi
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 "Reloading asterisk configuration..."
service asterisk restart
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 "Configuration complete! Restarting..."
reboot
exit 0

120
MyGMRS_Setup.sh Executable file
View File

@ -0,0 +1,120 @@
#!/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