Remot3_script_lib

We have a set of remote.it scripts working fine on Raspbian stretch, but want to move to Raspbian buster. When trying to install weavedconnectd on buster, I came across the following post: https://github.com/alanbjohnston/CubeSatSim/wiki/Remote-Management-of-Raspberry-P (found after not being able to install weavedconnectd)

Installing connectd works fine, I can connect our RPi to the remote.it server and run scripts. The problem is that our scripts attempt to import:

. /usr/bin/remot3_script_lib-1.1

which no longer exists. We use the following methods from it:

  • Translate
  • Status_*
  • Download_With_Retry
  • Task_Update
  • Task_Complete
  • Task_Failed

Is there a connectd equivalent wrapper to the underlying scripts? Or is there a way to update the wrapper to be agnostic to weaved vs connectd?

I notice the Send-File-Sample.sh example has some of these methods embedded within the script rather than as a separate ā€˜libraryā€™. Unfortunately I have no information about the history of the remot3_script_lib so I can only guess, but I think there are two possibilities:

  • An earlier version of the weavedconnectd installation provided the Remot3_script_lib, for device scripts to make use of
  • We generated a common library of functions called Remot3_script_lib and installed/placed it in /usr/bin so we didnā€™t have to replicate code between all our device scripts

Hi,

Sorry for the delay but I really had to think about this one. The remot3_script_lib wound up in our package originally to support an OEM customer. They had tested it, but we hadnā€™t, so we removed it from the connectd package. If it is working for you that is a good sign so you can continue to use it.

You can take that file (from one of your weaved devices) and send it to your connectd devices using the ā€œsend fileā€ script.

To write scripts so that they will work both with weavedconnectd and connectd, include the following lines near the top (but not at the top) of your scripts. Make sure that TOOL_DIR is defined prior to this, e.g.

# the following block is included to allow compatibility with both
# the deprecated weavedconnectd package as well as the current connectd package
TOOL_DIR=/usr/bin
if [ -e "$TOOL_DIR"/task_notify.sh ]; then
    NOTIFIERSCRIPT=task_notify.sh
elif [ -e "$TOOL_DIR"/connectd_task_notify ]; then
    NOTIFIERSCRIPT=connectd_task_notify
fi

If TOOL_DIR is already defined then you donā€™t need to redefine it, but make sure that definition is BEFORE the block of code above.

Then, in your code, youā€™ll need to replace any calls to /usr/bin/task_notify.sh to ${TOOL_DIR}/"$NOTIFIERSCRIPT", e.g.

Status()
{
	ret=$(${TOOL_DIR}/"$NOTIFIERSCRIPT" $1 $api $jobID "$2")	
}

# first, clear status cells a through e
Status a ""
Status b ""
Status c ""
Status d ""
Status e ""

Let me know if you have any issues getting this all to work.

1 Like

We took the methods from the example scripts on your website (specifically the file transfer example), diffed them with the methods in remote3_script_lib and found there were fairly minimal differences - including your suggestion for the $NOTIFIERSCRIPT var.

Unfortunately I donā€™t have enough rep to upload files, otherwise Iā€™d have attached our version of the script_lib for others to use.

Thanks for your help!

So, are you good to go now? Another thing you can do is simply to include all of the functions from the library file in your script itself, which removes the dependency on a specific external library.

Yep, weā€™re all good now, thanks for the help.

We didnā€™t really want to include the functions in the script as we have multiple separate scripts and copying code is always a bad sign!

Fair enough. You could also develop and install your own set of library functions into a file to be included when other scripts run, and use a simpler script to install them.