2024-10-06 08:14:59 -07:00
|
|
|
#!/bin/bash
|
|
|
|
|
#
|
|
|
|
|
# Author : Gaston Gonzalez
|
|
|
|
|
# Date : 6 October 2024
|
2024-10-10 04:37:22 -07:00
|
|
|
# Updated : 10 October 2024
|
2024-10-06 08:14:59 -07:00
|
|
|
# Purpose : Utility script for dumping system information
|
|
|
|
|
|
|
|
|
|
function usage() {
|
|
|
|
|
echo "Usage: $(basename $0) <command>"
|
2024-10-10 04:37:22 -07:00
|
|
|
echo " active-radio - Display model of active radio"
|
|
|
|
|
echo " et-cat - Is CAT control connected"
|
|
|
|
|
echo " et-gps - Is the GPS connected"
|
|
|
|
|
echo " ip - System IP address"
|
|
|
|
|
echo " release - EmComm Tools Release"
|
2024-10-06 08:14:59 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if [ $# -ne 1 ]; then
|
|
|
|
|
usage
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
case $1 in
|
2024-10-10 04:37:22 -07:00
|
|
|
active-radio)
|
|
|
|
|
if [ -L "${ET_HOME}/conf/radios.d/active-radio.json" ]; then
|
2024-10-10 05:48:41 -07:00
|
|
|
cat "${ET_HOME}/conf/radios.d/active-radio.json" | jq -r .model
|
2024-10-10 04:37:22 -07:00
|
|
|
else
|
2024-10-10 05:48:41 -07:00
|
|
|
echo "No radio selected"
|
2024-10-10 04:37:22 -07:00
|
|
|
fi
|
|
|
|
|
;;
|
2024-10-06 08:14:59 -07:00
|
|
|
et-cat)
|
2024-10-10 05:24:56 -07:00
|
|
|
|
2024-10-10 05:48:41 -07:00
|
|
|
if [ ! -L "${ET_HOME}/conf/radios.d/active-radio.json" ]; then
|
|
|
|
|
echo "N/A"
|
|
|
|
|
exit 0
|
|
|
|
|
fi
|
|
|
|
|
|
2024-10-10 05:24:56 -07:00
|
|
|
# 1. Check if the symlink was created by the udev rules
|
|
|
|
|
if [ -e /dev/et-cat ]; then
|
|
|
|
|
|
|
|
|
|
# 2. Check if the rigctl systemd unit is running properly
|
|
|
|
|
systemctl status rigctld --no-pager > /dev/null
|
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
|
|
|
|
|
|
# 3. Grab and format frequency
|
|
|
|
|
FREQ=$(timeout 1 rigctl -m 2 f)
|
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
|
printf "%'d MHz\n" "$FREQ" | sed 's|,|.|g'
|
|
|
|
|
else
|
|
|
|
|
echo "Connected. Can't access VFO";
|
|
|
|
|
fi
|
|
|
|
|
else
|
2024-10-10 05:48:41 -07:00
|
|
|
echo "Connected. rigctld not running"
|
2024-10-10 05:24:56 -07:00
|
|
|
fi
|
|
|
|
|
else
|
|
|
|
|
echo "Not connected";
|
|
|
|
|
fi
|
|
|
|
|
|
2024-10-06 08:14:59 -07:00
|
|
|
;;
|
|
|
|
|
et-gps)
|
|
|
|
|
if [ -e /dev/et-gps ]; then echo "Yes"; else echo "No"; fi
|
|
|
|
|
;;
|
|
|
|
|
ip)
|
|
|
|
|
hostname -I
|
|
|
|
|
;;
|
|
|
|
|
release)
|
|
|
|
|
grep DISTRIB_DESCRIPTION /etc/lsb-release | sed 's|"||g' | awk '{print $1}' | cut -d"=" -f2
|
|
|
|
|
;;
|
|
|
|
|
*)
|
|
|
|
|
echo "Command not supported."
|
|
|
|
|
usage
|
|
|
|
|
exit 1
|
|
|
|
|
;;
|
|
|
|
|
esac
|