home    builders    Search

builders ➜ BPQ Extensions

BPQ Extensions

The G8BPQ node program can call applications on the Raspberry PI. The TARPN install has provided four different application calls extending the capabilities of the G8BPQ node program. The LINUX command, called from the node, let's a visitor to your node call the BASH scripts you provide, and those BASH scripts can run applications on your Raspberry PI. You have to generate and install those script files before they are accessible. More info below.

The four extentions are:


The linux command calls script files you provide. If you are used to creating BASH scripts, this will be easy and you'll be bored by some of this material. Please check the information, however, and email me at my QRZ email address if you have more information, or corrections.
BASH lets you use Linux commands in sequence and in loops.

Here are some examples of BASH scripts. Note these important commanalities in all of the script files called by the linux command. This script file, called linkquality.sh, sends the last 15 lines of the link quality data file.
tail -15 /usr/local/etc/tarpn_home_linkquality.dat
echo " "
sleep 2
exit 0

This script, guess.sh, pretends as if it is a guessing game of some sort, but it is basically an endless loop. Note: I'm a crappy BASH programmer. This example uses temp files in parsing. Somebody please tell me the right way to do this without the temp files?

echo "I'm thinking of a number. Guess what it is or hit b to exit."

while [ $ONE == $KEEPGOING ];
   read newvalue
   echo $newvalue > /home/pi/guess1.tmp
   tr '\r' "#" < /home/pi/guess1.tmp > /home/pi/guess2.tmp
   sed 's/#//g' /home/pi/guess2.tmp > /home/pi/guess3.tmp
   echo -n "you entered "
   echo $newvalue
   if [ $newvalue = $EXIT ];
     echo "wrong. guess again?"

echo "goodbye"
sleep 2
exit 0

About being executable
To declare a linux file to be executable, use chmod +x yourscript.sh.
You can use ls -l in the directory to show the "rights" for the file. It should look like this:

-rwxr-xr-x 1 pi   pi   208 Aug 19 14:51 yourscript.sh
Notice the 'x' in three places at the start of the line.
The first character, - is reserved for 'd' for directory, or - for normal file.
The next 3 characters describes the file permissions for the owner of the file. Each letter can be a '-' or a specific letter. 'r' means readable. 'w' means writable. 'x' means executable.
Characters 5, 6 and 7 represent the permissions for the group the file belongs to. In the Raspberry PI for TARPN case, the 'pi' group only has one member so this is sort of irrelavent.
Characters 8, 9, 10 represent the permissions for global users. Again this isn't very relevent here because the owner is 'pi' and the only other username in the system is 'root' which has access to all files.
What's really important is the presence of an 'x' in the owner space.

After the permissions is a set of fields which may be interesting.
The '1' indicates the number of hard links to this file, which is 1, i.e. none.
The first "pi" indicates the owner of the file is the user "pi".
The second "pi" indicates that the group of the file is "pi" which is a default group containing only the user "pi".
The number "208" is the number of bytes in the file.
That's different from how much space the file takes on the disk, which will be rounded up to the nearest sector size.
The "Aug 19 14:51" is the last modification date.
The ".sh" is part of the filename and, while it is arbitrary, is commonly used to tell the viewer what kind of file it is. In the case of our scripting, the .sh is used to tell the "linux" calling program that the file is one that should be listed to the visitor at the node.

Difficult stuff

Here are some loose notes.

You can have your bash script call an application.

The hard part of this process, especially with calling existing applicaitons, is that the G8BPQ packet node ends every line of text with CR-LF 0x0D 0x0A. This is common on the MSWindows world, but in Linux it's unheard of. You'll have to intercept every line and convert into just NewLine, i.e. Line Feed.

Right now all these functions are called from G8BPQ with root privileges. That means if you make your shell script call a shell, the operator would have the ability to launch attacks into your home network from the Raspberry PI. Don't do that.

© Tadd Torborg, 2020 -- all rights reserved