Having just helped a new amateur radio friend out (2E0IJC) with adding a custom application to linbpq/bpq32 on his Raspberry Pi, I thought I would share the steps taken.
Open a console (Terminal window)
Before we start, you may need to install inetd. In Debian-based versions of linux we can use
sudo apt install inetutils-inetd
We only ever have to do this once.
Step 1: Create a hello world script
I keep all my scripts in a central location for ease of use.
mkdir -p ~/BBS/{apps,games} # create the scripts locations /home/username/BBS/apps and /home/username/BBS/games echo -e '#!/bin/bash read -t 1 player echo "Hello $player, somewhere in the world (in this case literally!)"' > ~/BBS/apps/helloworld.sh # create the hello world script chmod a+x ~/BBS/apps/helloworld.sh # allow the scrtipt to be executable by anyone ~/BBS/apps/helloworld.sh # execute the script # we should now see "Hello world (in this case literally!)" appear in the console.
Step 2: Add the CMDPORT information to bpq32.cfg
I installed bpq32/linbpq to ~/linbpq. Adjust the paths to suit your own location.
You need to decide which port you wish to use to run the script, and it must be unique.
Online guides tend to start at port 63000 so we shall do likewise.
Edit the bpq32.cfg file using your preferred editor. I use nano.
Search for a line starting
CMDPORT
If it is present, we need to add our port to the end of that line.
CMDPORT 1234 3232 63000
Keep track of the number of ports on that line, in our case there is only one. For a line such as
CMDPORT 1234 1235 1236
there are three ports (1234, 1235 and 1236). Each port has a position on the line starting at 0 for port 1234, 1 for 1235, 2 for 1236 and so on. Note that the numbering starts at 0 not 1.
If the CMDPORT line is not present in the file, we need to add it into the file, inside the section with
"ID=Telnet Server"
. While you are there, check what the
PORTNUM
is for that section. In mine the line reads
PORTNUM=2
. Remember this number as we will need it in the
APPLICATION
line shortly.
CMDPORT 63000
We now need to add an APPLICATION line for that port
If there are any applications defined such as BBS, CHAT, it goes under those lines.
APPLICATION 10,HELLO,C 2 HOST 0 K S,,CALHEL,,
Parts of the line will be changed for your own needs:
10 HELLO 2 0 CALHEL
10 is the application number, if you have other
APPLICATION
lines, add one to the highest number you have, the maximum is 32.
HELLO
is the command you will use to run the script (just like BBS, CHAT, TALK or any other inbuilt command)
2
is the
PORTNUM
number from earlier.
0
is the position in the
CMDPORT
line, starting at 0.
CALHEL
is optional and can be removed. This is a way to directly run the command when you connect.
If we assume your callsign is M0XYZ, take the last 3 letters (XYZ) and add extra letters to the end, in this case we will use “HEL” for a short version of “HELLO”, giving us “XYZHEL”.
If the node has an NoV and its own callsign, use that one (GB7ODZ in my case), use the last 3 letters and “HEL” to give us “ODZHEL”.
The maximum length for this is 6 letters. If you have a callsign with only 2 letters then use the 2 letters and then “HEL”
To reiterate, this is completely optional and can be left blank so you have 4 commas “,,,,” at the end of the line.
Save the file.
Step 3: Add the port to the /etc/services file
This is a system file, and must be edited as an administrator using sudo.
sudo nano /etc/services
Scroll to the end of the file and add a new line:
hamhello 63000/tcp # bpq hello world
hamhello
is just our internal service name and must be unique in the file.
63000
is the port number from the CMDPORT line earlier
Save the file and exit
Step 4: Add the script that gets called whenever we connect to the CMDPORT to /etc/inetd.conf
Again, as with /etc/services, this is a system file.
sudo nano /etc/inetd.conf
Scroll to the end of the file and add the line
hamhello stream tcp nowait username /home/username/BBS/apps/helloworld.sh
Change
hamhello
,
username
and the path to the script to match your settings.
Save the file and exit
Step 5: Restart the services
We now need to restart the inetd and bpq services to activate the changes.
Restarting services is an administrative task so again we need to use sudo.
sudo service inetutils-inetd restart
sudo service bpq restart
Hi Greg – great instructions and really appreciate your time this evening helping me setup my own node.
Great work – many thanks.
Andy