Skip to content

Instantly share code, notes, and snippets.

@dandrzejewski
Last active April 14, 2020 14:55
Show Gist options
  • Save dandrzejewski/f54b4e9c909f9be9aaef77c1d7138930 to your computer and use it in GitHub Desktop.
Save dandrzejewski/f54b4e9c909f9be9aaef77c1d7138930 to your computer and use it in GitHub Desktop.
A shell script to update radio and peer IDs in a cBridge, using radioid.net's CSV files.
#!/bin/bash
#
#Written by NF9K on 5/23/2019
#
#Work in progress
#
# Modified by AD8G to strip newlines at the end of the radioid.net csv files.
#
# To use, create a file called "vars" in the same directory as this script.
# Place two variables in it - USERNAME and PASSWORD - these are the credentials
# the script will use to log into your cBridge.
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
if [ ! -f $SCRIPTDIR/vars ]; then
echo "Please create $SCRIPTDIR/vars with the following format:"
echo ""
echo "USERNAME=cbridgeusername"
echo "PASSWORD=cbridgepassword"
echo ""
exit 1
fi
. $SCRIPTDIR/vars
mkdir -p /root/ids
PEERFILE=/root/ids/cBridgePeers.csv
RADIOFILE=/root/ids/cBridgeRadios.csv
rm -f $PEERFILE
rm -f $RADIOFILE
rm -f $PEERFILE.load
rm -f $RADIOFILE.load
wget -O $PEERFILE https://www.radioid.net/static/cbridge_rptr.csv
wget -O $RADIOFILE https://www.radioid.net/static/cbridge_user.csv
sed -e :a -e '/^\n*$/{$d;N;};/\n$/ba' $PEERFILE > $PEERFILE.load
sed -e :a -e '/^\n*$/{$d;N;};/\n$/ba' $RADIOFILE > $RADIOFILE.load
python /usr/local/ravennet/upload_ids.py -c $PEERFILE.load -p -u $USERNAME -d $PASSWORD localhost
python /usr/local/ravennet/upload_ids.py -c $RADIOFILE.load -r -u $USERNAME -d $PASSWORD localhost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment