Page 1 of 2

command line link/unlink

Posted: Sat May 19, 2018 5:58 pm
by w7efs
How does one link/unlink to a given reflector from the command line, please.

We have a need to cron this activity so that various regular nets can be heard.

Thank you.

Re: command line link/unlink

Posted: Sat May 19, 2018 7:01 pm
by MW0MWZ
Link to REF001 C

Code: Select all

sudo pistar-link ref001_c
Unlink

Code: Select all

sudo pistar-link unlink
Here is the full output from the command:

Code: Select all

pi-star@pi-star(ro):~$ sudo pistar-link
To unlink from any connected reflector, use: pistar-link unlink
To link to REF000 A for example, use: pistar-link ref000_a

If you need to make a reflector FIXED so that users cannot unlink,
for schedulling connections via CRON for example you can use the
the following: pistar-link ref000_a fixed
Should you wish to Un-Fix a reflector, relink to the same reflector
without the fixed flag, such as: pistar-link ref000_a
Hope that helps!

Re: command line link/unlink

Posted: Mon May 21, 2018 2:56 am
by w7efs
Perfect, Andy, thank you.

Re: command line link/unlink

Posted: Wed Jun 13, 2018 5:33 am
by n5amd
This is awesome! I had no idea. Thank you.

Re: command line link/unlink

Posted: Wed Oct 10, 2018 8:20 pm
by w7efs
Somehow the command seems to have gotten broken. While linked to a reflector:

# pistar-link unlink
remotecontrold: no address, port, or password is set

In /etc/ircddbgateway, remoteEnabled=1 with an assigned port and password. Permissions on the files look correct:

# ls -l $(which pistar-link remotecontrold)
-r-xr-xr-x 1 root bin 869036 Aug 2 2016 /usr/local/bin/remotecontrold
-rwxr-xr-x 1 root staff 1823 Mar 7 2018 /usr/local/sbin/pistar-link

... yet we're unable to unlink from the startup reflector or link to any other, using either the command line or the Admin web page. Any suggestions, please?

Re: command line link/unlink

Posted: Thu Oct 11, 2018 1:01 am
by AF6VN
That date stamp for pistar-link may be of concern...

Code: Select all

pi-star@pi-star-3b(ro):~$ ls -l $(which pistar-link remotecontrol remotecontrold)
-r-xr-xr-x 1 root bin   2354276 Aug  2  2016 /usr/local/bin/remotecontrol
-r-xr-xr-x 1 root bin    869036 Aug  2  2016 /usr/local/bin/remotecontrold
-rwxr-xr-x 1 root staff    1823 Jul 13 13:59 /usr/local/sbin/pistar-link
pi-star@pi-star-3b(ro):~$
... though the size looks the same...

Re: command line link/unlink

Posted: Thu Oct 11, 2018 1:47 am
by w7efs
AF6VN thank you much, yes, ours is outdated relative to yours, despite the daily cron update and a manual pistar-{update,upgrade} since your reply. Here's the text of our pistar-link, and does that agree with yours, please:

# #
# Make it simple to link reflectors from the CLI on Pi-Star. #
# Origional suggestion by Adrian (VK4TUX) #
# #
##############################################################################
#
if [ "$(id -u)" != "0" ]; then
echo -e "You need to be root to run this command...\n"
exit 1
fi

# Setup some variables
cmd=/usr/local/bin/remotecontrold
module=$(grep -m 1 'callsign=' /etc/dstarrepeater | awk -F "=" '/callsign/ {print $2}')

if [ -z "$1" ]
then
echo "To unlink from any connected reflector, use: pistar-link unlink"
echo "To link to REF000 A for example, use: pistar-link ref000_a"
echo ""
echo "If you need to make a reflector FIXED so that users cannot unlink,"
echo "for schedulling connections via CRON for example you can use the"
echo "the following: pistar-link ref000_a fixed"
echo "Should you wish to Un-Fix a reflector, relink to the same reflector"
echo "without the fixed flag, such as: pistar-link ref000_a"
echo ""
exit 0
fi

if [ -z "$2" ]
then
relink=never
else
relink=${2}
fi

case ${1} in
*unlink)
${cmd} "${module}" unlink
exit 0
;;
*)
${cmd} "${module}" link ${relink} $1
exit 0
;;
esac

exit 0

Re: command line link/unlink

Posted: Thu Oct 11, 2018 2:52 am
by AF6VN
Well, the actual shell script looks similar, but the opening comments are different... Or you failed to copy the entire script.

Code: Select all

cat /usr/local/sbin/pistar-link
#!/bin/bash
#
##############################################################################
#                                                                            #
#                     Pi-Star ircDDBGateway 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.         #
#                  Origional suggestion by Adrian (VK4TUX)                   #
#                                                                            #
##############################################################################
#
if [ "$(id -u)" != "0" ]; then
  echo -e "You need to be root to run this command...\n"
  exit 1
fi

# Setup some variables
cmd=/usr/local/bin/remotecontrold
module=$(grep -m 1 'callsign=' /etc/dstarrepeater | awk -F "=" '/callsign/ {print $2}')

if [ -z "$1" ]
then
      echo "To unlink from any connected reflector, use: pistar-link unlink"
      echo "To link to REF000 A for example, use: pistar-link ref000_a"
      echo ""
      echo "If you need to make a reflector FIXED so that users cannot unlink,"
      echo "for schedulling connections via CRON for example you can use the"
      echo "the following: pistar-link ref000_a fixed"
      echo "Should you wish to Un-Fix a reflector, relink to the same reflector"
      echo "without the fixed flag, such as: pistar-link ref000_a"
      echo ""
      exit 0
fi

if [ -z "$2" ]
then
      relink=never
else
      relink=${2}
fi

case ${1} in
*unlink)
  ${cmd} "${module}" unlink
  exit 0
;;
*)
  ${cmd} "${module}" link ${relink} $1
  exit 0
;;
esac

exit 0
pi-star@pi-star-3b(ro):~$

Re: command line link/unlink

Posted: Thu Oct 11, 2018 5:10 pm
by w7efs
AF6VN wrote: Thu Oct 11, 2018 2:52 am Well, the actual shell script looks similar, but the opening comments are different... Or you failed to copy the entire script.
Thanks for your assistance. I restored from a backup and all is well again.

Re: command line link/unlink

Posted: Fri Jul 19, 2019 3:52 pm
by W8DSB
HI, for the not so savvy Linux guy (me). How do a write a CRON to do the following:

Link to 24 C on startup (that was easy)
Monday at 19:59 unlink 24 C
Monday at 20:00 link 24 A
Monday at 20:59 unlink 24 A
Monday at 21:00 link 24 C

Examples would be welcome, thank you