forked from AndyTaylorTweet/Pi-Star_Binaries_sbin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
pistar-ysflink
executable file
·60 lines (53 loc) · 1.85 KB
/
pistar-ysflink
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
60
#!/bin/bash
#
##############################################################################
# #
# Pi-Star YSFGateway 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/ysfgateway | wc -l)" -eq "0" ]; then
echo -e "Remote Commands not enabled...\n"
exit 1
fi
# Setup some variables
cmd=/usr/local/bin/RemoteCommand
enable=$(sed -n '/^\[Remote Commands\]/,/^\[/p' /etc/ysfgateway | grep "^Enable" | awk -F '=' '{print $2}')
port=$(sed -n '/^\[Remote Commands\]/,/^\[/p' /etc/ysfgateway | grep "^Port" | 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 reflector, use: pistar-ysflink unlink"
echo "To link to YSF31672, use: pistar-ysflink ysf31672"
echo "To link to FCS002-90, use: pistar-ysflink fcs00290"
echo ""
exit 0
fi
case ${1} in
unlink)
(cd /var/log/pi-star/; ${cmd} ${port} UnLink)
exit 0
;;
*)
if [ ${#1} -ne 8 ]; then
echo -e "Invalid target ${1}"
exit 1
fi
(cd /var/log/pi-star/; ${cmd} ${port} Link${1^^})
exit 0
;;
esac
exit 0