command line link/unlink

Help with D-Star related issues
User avatar
w7efs
Posts: 335
Joined: Sun Apr 22, 2018 4:26 pm

command line link/unlink

Post 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.
User avatar
MW0MWZ
Site Admin
Posts: 1506
Joined: Wed Apr 04, 2018 9:15 pm
Location: Wales, UK
Contact:

Re: command line link/unlink

Post 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!
Andy

73 de MW0MWZ
http://pistar.uk
User avatar
w7efs
Posts: 335
Joined: Sun Apr 22, 2018 4:26 pm

Re: command line link/unlink

Post by w7efs »

Perfect, Andy, thank you.
n5amd
Posts: 37
Joined: Wed Apr 11, 2018 9:05 pm
Location: San Antonio Texas
Contact:

Re: command line link/unlink

Post by n5amd »

This is awesome! I had no idea. Thank you.
Ben
N5AMD
www.n5amd.com
User avatar
w7efs
Posts: 335
Joined: Sun Apr 22, 2018 4:26 pm

Re: command line link/unlink

Post 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?
AF6VN
Posts: 821
Joined: Fri Jul 20, 2018 1:15 am

Re: command line link/unlink

Post 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...

--
AF6VN
Dennis L Bieber
User avatar
w7efs
Posts: 335
Joined: Sun Apr 22, 2018 4:26 pm

Re: command line link/unlink

Post 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
AF6VN
Posts: 821
Joined: Fri Jul 20, 2018 1:15 am

Re: command line link/unlink

Post 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):~$

--
AF6VN
Dennis L Bieber
User avatar
w7efs
Posts: 335
Joined: Sun Apr 22, 2018 4:26 pm

Re: command line link/unlink

Post 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.
W8DSB
Posts: 31
Joined: Thu Jun 14, 2018 5:54 pm

Re: command line link/unlink

Post 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
Post Reply