HOW TO install linbpq on a Raspberry Pi

Write jessie image to SD Card

Bootup RPi and connect to your WLAN and change the Raspberry Pi Configuration:
– expand file system
– rename host name
– enable I2C interface
– set keyboard to United States, English (US, with euro on 5)
– set timezone Europe Amsterdam
reboot the RPi

update system

sudo apt-get update
sudo apt-get upgrade

Reboot your Pi

sudo reboot now

Instructions can also be found on http://www.cantab.net/users/john.wiseman/Documents/InstallingLINBPQ.htm

sudo mkdir linbpq
cd linbpq
sudo wget http://www.cantab.net/users/john.wiseman/Downloads/Beta/pilinbpq
sudo mv pilinbpq linbpq
sudo chmod +x linbpq

If you want to use UDP or TCP ports below 1024, or the BPQEther Driver, you must also set some capabilites on the file
(or run as root, wihch is not advisable). You may need to install setcap if it isn’t already on your system – sudo apt-get install libcap2-bin
or the equivalent for your disatribution.

sudo setcap “CAP_NET_RAW=ep CAP_NET_BIND_SERVICE=ep” linbpq

You also need some web pages for the management interface. Create directory HTML (capitals) under your linbpq directory, and download and unzip
https://dl.dropbox.com/u/31910649/HTMLPages.zip into it.

sudo mkdir HTML
cd HTML
sudo wget https://dl.dropbox.com/u/31910649/HTMLPages.zip
sudo unzip HTMLPages.zip

 

The Web server is configured in a similar way to the UI-View web server, although there are minor differences. The “Base Directory” for pages and files is
folder BPQAPRS/HTML, under your BPQ32 Data Directory. The simplest way to get it working is to take a set of pages, and tailor them to your requirements. A
typical set may be downloaded from http://www.cantab.net/users/john.wiseman/Documents/Samples/APRSHTML.zip

cd ~/linbpq
sudo mkdir BPQAPRS
cd BPQAPRS
sudo wget http://www.cantab.net/users/john.wiseman/Documents/Samples/APRSHTML.zip
sudo unzip APRSHTML.zip

Change the rights for linbpq to pi:pi

cd ~
sudo chown -R pi:pi linbpq

Configuring linbpq

The linbpq software is configured by the file /home/pi/linbpq/bpq32.cfg. The configuration is well described in the documentation. See example for my bpq32.cfg file

sudo nano /home/pi/linbp/bpq32.cfg

Run linbpq for the first time

cd ~/linbpq
sudo -u pi ./linbpq

Create a script /home/pi/linbpq/runbpq containing:

cd /home/pi/linbpq
sudo -u pi mv linbpq.new linbpq
sudo -u pi ./linbpq >/dev/tty2

make it executable

sudo chmod +x /home/pi/linbpq/runbpq

Add user pi to group tty

sudo adduser pi tty

Create file /etc/systemd/system/linbpq.service containing:

[Unit]
After=network.target

[Service]
ExecStart=/bin/bash /home/pi/linbpq/runbpq
Restart=always

[Install]
WantedBy=multi-user.target

 

To start the service at bootrun command:
sudo systemctl enable linbpq.service

To stop the service at boot run command:
sudo systemctl disable linbpq.service

To restart the service at boot run command:
sudo systemctl restart linbpq.service

####################
You need to run setcap each time you download a new version of linbpq.

cd linbpq
sudo setcap “CAP_NET_ADMIN=ep CAP_NET_RAW=ep CAP_NET_BIND_SERVICE=ep” linbpq

 

(X)Net IP.NET

A small example of IP.NET from (X) Net

#
# Default route
ipr add default SLIP 192.168.1.201
#
iproute add 192.168.1.200/24 slip 192.168.1.201
#
### Set route naar Bbs en Convers
route local add 4 pi8lap-8 nd lapcon
route local add 3 pi8lap nd lapbbs
#
#### Start services
start tcpd
#### Start telnet server (zie file teluser.net)
start telnetd
#### Start httpd (index.htm)
start httpd
#### Start de ftp server (zie file ftpuser.net)
start ftpd
#### Start statd
start rstatd 192.168.1.112
start statd
start statd 60 		min.sta
start statd 3600 	hour.sta
start statd 86400 	day.sta

(X)Net Crontab

Here a small example of the crontab of (X) Net

# -------    ------------
# Minuten      0-59
# Uren         0-23
# Dagen        1-31 Dagen van de maand
# Maanden      1-12
# Weekdagen    0-6 (Zondag = 0, Maandag = 1, etc...)

# 30 4 1,15 * 5 msg all Goedemiddag allemaal
# Wordt om 4.30 uur op de 1e en de 15e van de maand en op elke vrijdag uitgevoerd.

# Minuten	uren	dagen	maanden	weekdagen	WAT	Text
# Gelukkig nieuwjaar wensen.
   0 		0 	1 	1 	* 		msg all Iedereen een gelukkig Nieuwjaar!
# Ronde van PI4Z begint zo
   55		11	*	*	0		msg all	Ronde van PI4Z begint over 5 minuten.
   55		11	*	*	0		fbeacon pi4z.txt 0 BEACON
   54		11	*	*	0		fbeacon pi4z.txt 1 BEACON
# Backup autoexec/autoboot 1 keer per dag
   0		0	*	*	0,1,2,3,4,5,6	cp autoexec.net /usr/local/xnet/backup/autoexec.res
   0		0	*	*	0,1,2,3,4,5,6	cp autoboot.net /usr/local/xnet/backup/autoboot.res
# Extra Beacon
   0,15,30,45 	* 	* 	* 	* 		fbeacon beacon.txt 0 BEACON
   1,16,31,46	*	*	*	*		fbeacon beacon.txt 1 BEACON
#

Ampr Gateway

Configuratie voorbeeld van een Ampr Gateway. Hier heb je het volgende programma(tje) voor nodig.
http://www.yo2loj.ro/hamprojects/ampr-ripd-1.15.tgz

Ik heb dit toegevoegd in het filetje /etc/rc.local zodat het bij het booten van het systeem automatische wordt geladen.

######################### tunnel ampr.org ################################
ifconfig tunl0 up 44.137.31.65/27 multicast
#ip tunnel change ttl 64 mode ipip tunl0
ip link set dev tunl0 up
################# default route naar gw-44-137.ampr.org ##################
ip route add default dev tunl0 via 213.222.29.194 onlink table 44
######################## route ampr.org #################################
ip rule add to 44.0.0.0/8 table 44 priority 44
ip rule add from 44.137.31.64/27 table 44 priority 45
route add -net 44.0.0.0 netmask 255.0.0.0 tunl0
ip route add 44.137.31.64/27 dev tunl0 table 44
## Start ampr-ripd to learn rest of mesh routes
/usr/sbin/ampr-ripd -r -s -i tunl0 -a (extern ip-adres) -t 44 -p (password)

Voor de rest heb ik nog wat regeltjes toegevoegd in de firewall. (de geleerde zullen er wel opmerkingen over hebben. Maar dit werkt voor mij)

-A INPUT -s 44.0.0.0/8 -j ACCEPT
# Block all non 44 incoming traffic
-A INPUT ! -s 44.0.0.0/8 -i tunl0 -j DROP
-A INPUT -i eth0 -p ipencap -j ACCEPT
-A INPUT -p udp --dport 520 -j ACCEPT
-A FORWARD -s 44.128.0.0/16 -j REJECT --reject-with icmp-port-unreachable
-A FORWARD -d 44.128.0.0/16 -j REJECT --reject-with icmp-port-unreachable
# Only allow ampr.org traffic ######
-A FORWARD -i tunl0 -o eth0 -s 44.0.0.0/8 -j ACCEPT
-A FORWARD -i eth0 -o tunl0 -d 44.0.0.0/8 -j ACCEPT
#####################################
-A FORWARD -d 44.0.0.0/8 -j ACCEPT
-A FORWARD -s 44.0.0.0/8 -j ACCEPT

Start (X)Net/kissattach/slip at boot

I have written the startup script below so that all services are started. Now of course it is nice if this also happens when booting the server. First the start script.

#!/bin/sh
#
tmpfile="/tmp/$$.startax0.pts"
#
kissnetd -p 2 > "$tmpfile" &
#
sleep 2
#
attachthem () {
        read PTS1 PTS2
        echo "Starting PTS gekloot voor poort AX0 :)"
        kissattach -l $PTS1 ax0 192.168.1.113
	ifconfig ax0 netmask 255.255.255.0
        sleep 1
        sed -i "s,attach sdev3 kiss 3 1 115200 /dev/.*$,attach sdev3 kiss 3 1 115200 $PTS2," /usr/local/xnet/AUTOBOOT.NET
}

tail -n 1 $tmpfile | attachthem
rm $tmpfile
#
tmpfile="/tmp/$$.startax1.pts"
#
kissnetd -p 2 > "$tmpfile" &
#
sleep 2

attachthem () {
	read PTS1 PTS2
	echo "Starting PTS gekloot voor poort AX1 :)"
        kissattach -l $PTS1 ax1 192.168.1.113
        ifconfig ax1 netmask 255.255.255.0
        sleep 1
        sed -i "s,attach sdev4 kiss 4 1 115200 /dev/.*$,attach sdev4 kiss 4 1 115200 $PTS2," /usr/local/xnet/AUTOBOOT.NET
}

tail -n 1 $tmpfile | attachthem
rm $tmpfile
################## Klote slip link ###################################
XNET_DIR=/usr/local/xnet
LINIP=192.168.1.200     # LINUX-IP   address
XNET=192.168.1.201  # XNET  address
#
cd /usr/local/xnet
./dev &
#
sleep 2
#
attachthem () {
        read PTS1 PTS2
        echo "Starting PTS gekloot voor de slip link :)"
        slattach -s 38400 -p slip $PTS1 &
        sleep 1
        ifconfig sl0 $LINIP netmask 255.255.255.255 pointopoint $XNET mtu 236 up
        sleep 1
        sed -i "s,attach sdev6 slip 38400 /dev/.*$,attach sdev6 slip 38400 $PTS2," /usr/local/xnet/AUTOBOOT.NET
}

tail -n 1 /tmp/slip | attachthem
rm /tmp/slip

cd /usr/local/sbin
./ppconversd &
sleep 3
#
cd /usr/local/xnet
./rstatrxd /var/www/cgi-bin/postat/ &
sleep 2
#
  /sbin/modprobe netrom
  /usr/local/sbin/nrattach -i 192.168.1.113 -m 512 netrom
  /usr/local/sbin/nrattach -i 192.168.1.113 -m 512 netcon
  /usr/local/sbin/nrattach -i 192.168.1.113 -m 512 netbbs
# Init Netrom
   /usr/local/sbin/netromd -i -l -t 30
# Enable External Logons
  /usr/local/sbin/ax25d &
  /bin/sleep 2
# Start Mheard daemon
 /usr/local/sbin/mheardd
# start fbb
 /usr/local/sbin/fbb &
# Nu dan eindelijk Xnet
./linuxnet < /dev/tty2 > /dev/tty2 2>&1 &

Now I have created the following file in /etc/init.d with the name xnet.

#!/bin/sh
### BEGIN INIT INFO
# Provides:          xnet
# Required-Start: $remote_fs $syslog $network
# Required-Stop: $remote_fs $syslog $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Run /usr/local/xnet/xnet if it exist
### END INIT INFO

PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin

. /lib/init/vars.sh
. /lib/lsb/init-functions

do_start() {
        if [ -x /usr/local/xnet/xnet ]; then
                [ "$VERBOSE" != no ] && log_begin_msg "Running pi1lap)"
                /usr/local/xnet/xnet
                ES=$?
                [ "$VERBOSE" != no ] && log_end_msg $ES
                return $ES
        fi
}

case "$1" in
    start)
        do_start
        ;;
    restart|reload|force-reload)
        echo "Error: argument '$1' not supported" >&2
        exit 3
        ;;
    stop)
        ;;
    *)
        echo "Usage: $0 start|stop" >&2
        exit 3
        ;;
esac

Now it has to be added.
update-rc.d xnet defaults
update-rc.d xnet enable

Well, reboot and see if everything is alright.

(X)Net slip link linux

Well here I have been working on it for a while. Because (new) Linux works with master /dev/pmtx and slave /dev/pts/? it is not always easy to find out which slave you will be assigned. Custom programs such as kissattach that give the slave with stdout. Now slattach does not suffer from it unfortunately. Oh well in Debian than.

I use the following program to create a master and slave.

/*compile with : gcc -Wall -O2 -D_GNU_SOURCE tty0tty.c -o tty0tty */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>


int
ptym_open(char *pts_name, char *pts_name_s , int pts_namesz)
{
char *ptr;
int fdm;

strncpy(pts_name, "/dev/ptmx", pts_namesz);
pts_name[pts_namesz - 1] = '\0';

fdm = posix_openpt(O_RDWR | O_NONBLOCK);
if (fdm < 0)
return(-1);
if (grantpt(fdm) < 0) 
{
close(fdm);
return(-2);
}
if (unlockpt(fdm) < 0) 
{
close(fdm);
return(-3);
}
if ((ptr = ptsname(fdm)) == NULL) 
{
close(fdm);
return(-4);
}

strncpy(pts_name_s, ptr, pts_namesz);
pts_name[pts_namesz - 1] = '\0';

return(fdm); 
}


int main(void)
{
char master1[1024];
char slave1[1024];
char master2[1024];
char slave2[1024];

int fd1;
int fd2;

char c1,c2;

fd1=ptym_open(master1,slave1,1024);

fd2=ptym_open(master2,slave2,1024);

{
  FILE *fp;

  printf("%s <-> %s\n",slave1,slave2);

  if((fp=freopen("/tmp/slip", "w" ,stdout))==NULL) {
    printf("Cannot open file.\n");
    exit(1);
}

  printf("%s %s\n",slave1,slave2);

  fclose(fp);

}
while(1)
{
if(read (fd1,&c1,1) == 1) write(fd2,&c1,1);
usleep(20);
if(read (fd2,&c2,1) == 1) write(fd1,&c2,1);
usleep(20);
};

close(fd1);
close(fd2);

return EXIT_SUCCESS;
}

I have added the code below. Because I would like the pts to be written down in a file.

{
  FILE *fp;

  printf("%s <-> %s\n",slave1,slave2);

  if((fp=freopen("/tmp/slip", "w" ,stdout))==NULL) {
    printf("Cannot open file.\n");
    exit(1);
}

  printf("%s %s\n",slave1,slave2);

  fclose(fp);

}
As you can see above, the pts are displayed with printf and they are written in /tmp/slip. Well here I wanted to go. Now I can read the file. Here I use the following in my start script of (X) Net.
#!/bin/sh
XNET_DIR=/usr/local/xnet
LINIP=192.168.1.200 # LINUX-IP address
XNET=192.168.1.201 # XNET address
#
cd /usr/local/xnet
./pts & # Hier worden de ptssen gemaakt ?
#
sleep 2
#
attachthem () {
read PTS1 PTS2
echo “Starting PTS gekloot voor de slip link :)”
slattach -s 38400 -p slip $PTS1 &
sleep 1
ifconfig sl0 $LINIP netmask 255.255.255.255 pointopoint $XNET mtu 236 up
sleep 1
sed -i “s,attach sdev6 slip 38400 /dev/.*$,attach sdev6 slip 38400 $PTS2,” /usr/local/xnet/AUTOBOOT.NET
}

tail -n 1 /tmp/slip | attachthem
#rm /tmp/slip <> Niet weg gooien sukkel, die hebben we nog nodig

With the command “sed” the PTS is adjusted in AUTOBOOT.NET. Now I do not have to worry about what pts I get assigned.