#!/bin/bash
#
# Copyright (c) 2020 by Thomas A. Early N7TAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
trap ControlC INT
ControlC () {
echo "caught SIGINT"
}
UninstallReflector () {
if [ -e $xlxserv ] || [ -e $xrfserv ]; then
cd src
sudo make uninstall
cd ..
fi
if [ -e $ambserv ]; then
cd ambed
sudo make uninstall
cd ..
fi
}
InstallReflector () {
if [ "$tcaddress" != none ]; then
cd ambed
sudo make install || read -p " to continue: " ans
cd ..
fi
cd src
if [[ "$callsign" == XLX* ]]; then
if [ ! -e xlxd.whitelist ]; then
cp ../config/xlxd.whitelist .
fi
if [ ! -e xlxd.blacklist ]; then
cp ../config/xlxd.blacklist .
fi
if [ ! -e xlxd.interlink ]; then
cp ../config/xlxd.whitelist .
fi
if [[ "$g3support" == true ]] && [ ! -e xlxd.terminal ]; then
cp ../config/xlxd.terminal .
fi
else
if [ ! -e xrfd.whitelist ]; then
cp ../config/xlxd.whitelist xrfd.whitelist
fi
if [ ! -e xrfd.blacklist ]; then
cp ../config/xlxd.blacklist xrfd.blacklist
fi
if [ ! -e xrfd.interlink ]; then
cp ../config/xlxd.whitelist xrfd.interlink
fi
if [[ "$g3support" == true ]] && [ ! -e xrfd.terminal ]; then
cp ../config/xlxd.terminal xrfd.terminal
fi
fi
sudo make install || read -p " to continue: " ans
cd ..
}
Clean () {
cd src
make clean
cd ../ambed
make clean
cd ..
}
Compile () {
local np
np=`getconf _NPROCESSORS_ONLN`
cd src
make -j$np || read -p " - omit value to toggle a true/false : " key value garbage
if [[ "$key" == ls* ]]; then
cat reflector.cfg;
echo
read -p " to return to main menu: " ans
elif [[ "$key" == us* ]]; then UninstallReflector
elif [[ "$key" == is* ]]; then InstallReflector
elif [[ "$key" == gp* ]]; then git pull
elif [[ "$key" == rr* ]]; then
if [[ "$callsign" == XLX* ]]
then sudo systemctl restart xlxd
else sudo systemctl restart xrfd
fi
elif [[ "$key" == rt* ]]; then sudo systemctl restart ambed
elif [[ "$key" == cl* ]]; then Clean
elif [[ "$key" == co* ]]; then Compile
elif [[ "$key" == tl* ]]; then sudo journalctl -u ambed -f
elif [[ "$key" == rl* ]]; then
if [ -e $xlxserv ]; then
sudo journalctl -u xlxd -f
elif [ -e $xrfserv ]; then
sudo journalctl -u xrfd -f
fi
fi
done
exit 0