-
Notifications
You must be signed in to change notification settings - Fork 41
/
pistar-nxdnlink
executable file
·59 lines (52 loc) · 1.77 KB
/
pistar-nxdnlink
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
#
##############################################################################
# #
# Pi-Star NXDNGateway link Tool #
# #
# Version 1.0, Code, Design and Development by Andy Taylor (MW0MWZ). #
# #
# Make it simple to link reflectors from the CLI on Pi-Star. #
# #
##############################################################################
#
if [ "$(id -u)" != "0" ]; then
echo -e "You need to be root to run this command...\n"
exit 1
fi
# Make sure config is present
if [ "$(grep -o 'Remote Commands' /etc/nxdngateway | wc -l)" -eq "0" ]; then
echo -e "Remote Commands not enabled...\n"
exit 1
fi
# Setup some variables
cmd=/usr/local/bin/RemoteCommand
enable=$(grep -A1 'Remote Commands' /etc/nxdngateway | tail -n 1 | awk -F "=" '{print $2}')
port=$(grep -A2 'Remote Commands' /etc/nxdngateway | tail -n 1 | awk -F "=" '{print $2}')
# Make sure that remote commands are turned on
if [ "${enable}" -eq "0" ]; then
echo -e "Remote Commands not enabled...\n"
exit 1
fi
if [ -z "$1" ]
then
echo "To unlink from any connected TG, use: pistar-nxdnlink unlink"
echo "To link to TG31672, use: pistar-nxdnlink 31672"
echo ""
exit 0
fi
case ${1} in
unlink)
(cd /var/log/pi-star/; ${cmd} ${port} TalkGroup9999)
exit 0
;;
*)
if ! [[ "${1}" =~ ^[0-9]+$ ]]; then
echo -e "Invalid target ${1}"
exit 1
fi
(cd /var/log/pi-star/; ${cmd} ${port} TalkGroup${1^^})
exit 0
;;
esac
exit 0