#!/bin/bash
# Start AX25/Netrom networking daemons.
# Script written and modified by Niels pd9q
# Date of last modification: 11-14-2018
### BEGIN INIT INFO
# Provides: ax25
# Required-Start: $network $remote_fs $syslog
# Required-Stop: $network $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: AX25 server
### END INIT INFO
# Add some color
green='\e[0;32m'
red='\e[0;31m'
reset='\e[0m'
set +e # Don't exit on error status
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/xnet:/usr/local/etc/ax25:/home/pd2lt/jnos
DESC="AX25 server"
ENABLED=1
base=${0##*/}
link=${base#*[SK][0-9][0-9]}
test $link = $base && AX_START=yes
test "$AX_START" = yes || exit 0
test -x /usr/local/etc/ax25/ax-start || exit 0
return="Done"
case "$1" in
start)
modprobe mkiss
modprobe ax25
modprobe netrom
modprobe rose
# Dual port TNC KPC-9612
#mkiss -s 9600 -x 2 /dev/ttyUSB0 > /tmp/unix98
#export PTS0=`more /tmp/unix98 | grep -w /dev | cut -b -11`
#export PTS1=`more /tmp/unix98 | grep -w /dev | cut -b 12-`
#sleep 1
# Port 1k2 144.850Mhz
echo "Starting ax0 "
if grep ax0 /etc/ax25/axports ; then
kissattach /dev/ttyUSB0 ax0 || return=$rc_failed
ifconfig ax0 44.137.31.73 netmask 255.255.255.224
sleep 2
else
echo "Error ax0 not found in the file axports"
return="Failed"
fi
echo "$1 $return"
# Port 9k6 430.950Mhz
echo "Starting ax1 "
if grep ax1 /etc/ax25/axports ; then
kissattach /dev/ttyUSB1 ax1 || return=$rc_failed
ifconfig ax1 44.137.31.73 netmask 255.255.255.224
sleep 2
else
echo "Error ax1 not found in the file axports"
return="Failed"
fi
echo "$1 $return"
# link local pi8lap (xnet)
echo "Starting ax2 "
if grep ax2 /etc/ax25/axports ; then
tmpfile="/tmp/$$.startax2.pts"
kissnetd -p 2 > "$tmpfile" &
sleep 2
attachthem () {
read PTS1 PTS2
kissattach -l $PTS1 ax2 44.137.31.73 || return=$rc_failed
ifconfig ax2 44.137.31.73 netmask 255.255.255.224 up
sleep 1
sed -i "s,attach sdev3 kiss 3 1 19200 /dev/.*$,attach sdev3 kiss 3 1 19200 $PTS2," /usr/local/xnet/AUTOBOOT.NET
}
tail -n 1 $tmpfile | attachthem
rm $tmpfile
sleep 3
else
echo "Error ax2 not found in the file axports"
return="Failed"
fi
echo "$1 $return"
# Link local pi1lap-4 (xnet)
echo "Starting ax3 "
if grep ax3 /etc/ax25/axports ; then
tmpfile="/tmp/$$.startax3.pts"
kissnetd -p 2 > "$tmpfile" &
sleep 2
attachthem () {
read PTS1 PTS2
kissattach -l $PTS1 ax3 44.137.31.73 || return=$rc_failed
ifconfig ax3 44.137.31.73 netmask 255.255.255.224 up
sleep 1
sed -i "s,attach sdev4 kiss 4 1 19200 /dev/.*$,attach sdev4 kiss 4 1 19200 $PTS2," /usr/local/xnet/AUTOBOOT.NET
}
tail -n 1 $tmpfile | attachthem
rm $tmpfile
sleep 3
else
echo "Error ax3 not found in the file axports"
return="Failed"
fi
echo "$1 $return"
# create slip link Linux <-> Xnet
socat -d -d -ly PTY,link=/dev/ttyq1 PTY,link=/dev/ptyq1 &
sleep 2
slattach -s 38400 -p slip /dev/ptyq1 &
sleep 1
ifconfig sl0 44.137.31.69 netmask 255.255.255.255 pointopoint 44.137.31.70 mtu 236 up
sleep 1
# create axudp device
socat -d -d -ly PTY,link=/dev/ttyq2 PTY,link=/dev/ptyq2 &
sleep 2
echo "Starting ax4 "
if grep ax4 /etc/ax25/axports ; then
kissattach -m 256 /dev/ptyq2 ax4 44.137.31.73 || return=$rc_failed
ax25udp -c /etc/ax25/ax25ipd-10093.conf > /tmp/axudp
ifconfig ax4 44.137.31.73 netmask 255.255.255.224 up
sleep 1
else
echo "Error ax4 not found in the file axports"
return="Failed"
fi
echo "$1 $return"
# create axip device
socat -d -d -ly PTY,link=/dev/ttyq3 PTY,link=/dev/ptyq3 &
sleep 2
echo "Starting ax5 "
if grep ax5 /etc/ax25/axports ; then
kissattach -m 256 /dev/ptyq3 ax5 44.137.31.73 || return=$rc_failed
ax25ipd -c /etc/ax25/ax25ipd-axip.conf > /tmp/axip
ifconfig ax5 44.137.31.73 netmask 255.255.255.224 up
sleep 1
else
echo "Error ax5 not found in the file axports"
return="Failed"
fi
echo "$1 $return"
# create socat device (jnos-uro)
socat -d -d -ly PTY,link=/dev/ttyq4 PTY,link=/dev/ptyq4 &
sleep 2
echo "Starting ax6 "
if grep ax6 /etc/ax25/axports ; then
kissattach -m 256 /dev/ptyq4 ax6 44.137.31.73 || return=$rc_failed
ifconfig ax6 44.137.31.73 netmask 255.255.255.224 up
sleep 1
else
echo "Error ax6 not found in the file axports"
return="Failed"
fi
echo "$1 $return"
# attach rose port
echo "Starting rose0 "
if grep rose0 /etc/ax25/rsports ; then
rsattach rose0 || return=$rc_failed
ifconfig rose0 44.137.31.73 netmask 255.255.255.224
rsparms -call PI1LAP-10
else
echo "Error rose0 not found in the file rsports"
return="Failed"
fi
echo "$1 $return"
# MFnos running in DOSEmu
# Set the comport in de file /etc/dosemu/dosemu.comf $_com1 = "dev/ttyq5"
#socat -d -d -ly PTY,link=/dev/ttyq5 PTY,link=/dev/ptyq5 &
# slattach -n -q -p slip -s 38400 /dev/ptyq5 &
#sleep 2
# KISS inteface for MFnos / slip
# kissattach /dev/ptyq5 ax6 44.137.31.73
# kissparms -p ax6 -c 1 -f y -t 10 -s 100 -r 255
# axparms -setcall ax6 pi1lap-10
#
# ifconfig ax3 44.88.0.9 netmask 255.255.255.224 up
#sleep 2
# create nr0 device (lapuro/pi1lap-5) uronode
echo "Starting nr0 "
if grep nr0 /etc/ax25/nrports ; then
ifconfig nr0 down
nrattach -i 44.137.31.73 -m 512 nr0 || return=$rc_failed
ifconfig nr0 44.137.31.73 netmask 255.255.255.224 hw netrom PI1LAP-5 up
else
echo "Error nr0 not found in the file nrports"
return="Failed"
fi
echo "$1 $return"
# create nr1 device (lapbbs/pi8lap) f6fbb
echo "Starting nr1 "
if grep nr1 /etc/ax25/nrports ; then
ifconfig nr1 down
nrattach -i 44.137.31.73 -m 512 nr1 || return=$rc_failed
ifconfig nr1 44.137.31.73 netmask 255.255.255.224 hw netrom PI8LAP up
else
echo "Error nr1 not found in the file nrports"
return="Failed"
fi
echo "$1 $return"
# create nr2 device (lapdx/pi1lap-4) dxspider
echo "Starting nr2 "
if grep nr2 /etc/ax25/nrports ; then
ifconfig nr2 down
nrattach -i 44.137.31.73 -m 512 nr2 || return=$rc_failed
ifconfig nr2 44.137.31.73 netmask 255.255.255.224 hw netrom PI1LAP-4 up
else
echo "Error nr2 not found in the file nrports"
return="Failed"
fi
echo "$1 $return"
# create nr3 device (lappac/pi1lap-7) fpac
echo "Starting nr3 "
if grep nr3 /etc/ax25/nrports ; then
ifconfig nr3 down
nrattach -i 44.137.31.73 -m 512 nr3 || return=$rc_failed
ifconfig nr3 44.137.31.73 netmask 255.255.255.224 hw netrom PI1LAP-7 up
else
echo "Error nr3 not found in the file nrports"
return="Failed"
fi
echo "$1 $return"
# start xnet
cd /usr/local/xnet
rm *.CFG &> /dev/null
sleep 2
./linuxnet < /dev/tty2 > /dev/tty2 2>&1 &
./rstatrxd /var/www/cgi-bin/postat/ &> /dev/null &
sleep 2
# start jnos
cd /home/pd9q/jnos
./startnos </dev/tty3>/dev/tty3 2>&1 &
sleep 3
# route
# Xnet route
ip route add 44.137.31.70 dev sl0 table 44 src 44.137.31.69
# Mfnos route to 192.168.1.110
#route add 44.137.31.75 gw 192.168.1.112
# beacons
beacon -c PI1LAP-15 -t 10 -d ID ax0 "Network node PI1LAP-15 Zeeland, JO11VN" &
beacon -c PI1LAP-15 -t 10 -d ID ax1 "Network node PI1LAP-15 Zeeland, JO11VN" &
beacon -c PI1LAP-15 -t 10 -d ID ax2 "Network node PI1LAP-15 Zeeland, JO11VN" &
beacon -c PI1LAP-15 -t 10 -d ID ax3 "Network node PI1LAP-15 Zeeland, JO11VN" &
# start ax25 deamons
echo "Starting ax25d daemon "
if [ -f /usr/local/etc/ax25/ax25d.conf ] ; then
/usr/local/sbin/ax25d || return=$rc_failed
else
echo "/usr/local/etc/ax25/ax25d.conf file not found"
return="Failed"
fi
echo "$1 $return"
echo "Starting mheardd daemon "
/usr/local/sbin/mheardd
echo "$1 $return"
echo "Starting ax25rtd daemon "
if [ -f /usr/local/etc/ax25/ax25rtd.conf ] ; then
/usr/local/sbin/ax25rtd || return=$rc_failed
else
echo "/usr/local/etc/ax25/ax25rtd.conf file not found"
return="Failed"
fi
echo "$1 $return"
echo "Starting flexd daemon "
if [ -f /usr/local/etc/ax25/flexd.conf ] ; then
/usr/local/sbin/flexd || return=$rc_failed
else
echo "/usr/local/etc/ax25/flexd.conf file not found"
return="Failed"
fi
echo "$1 $return"
echo "Starting netromd daemon "
if [ -f /usr/local/etc/ax25/nrports ] ; then
/usr/local/sbin/netromd -c -i -p 1 -t 15 || return=$rc_failed
else
echo "/usr/local/etc/ax25/nrports file not found"
return="Failed"
fi
echo "$1 $return"
echo "Starting FBB daemon "
if [ -f /usr/local/etc/ax25/fbb/fbb.conf ] ; then
/usr/local/sbin/fbb -s -a -l /etc/ax25/fbb.log || return=$rc_failed
else
echo "/usr/local/etc/ax25/fbb/fbb.conf file not found"
return="Failed"
fi
echo "$1 $return"
;;
stop)
kill $(ps aux | grep '[l]inuxnet' | awk '{print $2}')
echo "Shutting down jnos bbs"
killall -KILL jnos || return="Failed"
echo "Shutting down FBB script"
killall -KILL fbb || return="Failed"
echo "Shutting down FBB daemon"
killall -KILL xfbbd || return="Failed"
echo "Shutting down mheardd daemon"
killall -KILL mheardd || return="Failed"
echo "Shutting down netromd daemon"
killall -KILL netromd || return="Failed"
echo "Shutting down ax25d daemon"
killall -KILL ax25d || return="Failed"
echo "Shutting down ax25ipd daemon"
killall -KILL ax25ipd || return="Failed"
echo "Shutting down ax25upd daemon"
killall -KILL ax25udp || return="Failed"
echo "Shutting down rstatrxd daemon"
killall -KILL rstatrxd || return="Failed"
echo "Shutting down ax25rtd daemon"
killall -KILL ax25rtd || return="Failed"
echo "Shutting down mkiss daemon"
killall -KILL mkiss || return="Failed"
echo "Shutting down kissattach daemon"
killall -KILL kissattach || return="Failed"
echo "Shutting down kissnetd daemon"
killall -KILL kissnetd || return="Failed"
echo "Shutting down slattach daemon"
killall -KILL slattach || return="Failed"
echo "Shutting down socat daemon"
killall -KILL socat || return="Failed"
echo "Shutting down beacon daemon"
killall -KILL beacon || return="Failed"
echo "Shutting down flexd daemon"
killall -KILL flexd || return="Failed"
echo "Shutting down netrom ports"
ifconfig nr0 down || return="Failed"
ifconfig nr1 down || return="Failed"
ifconfig nr2 down || return="Failed"
ifconfig nr3 down || return="Failed"
echo "Shutting down ax ports"
ifconfig ax0 down || return="Failed"
ifconfig ax1 down || return="Failed"
ifconfig ax2 down || return="Failed"
ifconfig ax3 down || return="Failed"
ifconfig ax4 down || return="Failed"
ifconfig ax5 down || return="Failed"
echo "Shutting down rose ports"
ifconfig rose0 down || return="Failed"
ifconfig rose1 down || return="Failed"
sleep 4
echo "$1 $return"
;;
restart|reload)
$0 stop && $0 start
;;
status)
echo -n "Checking for fbb daemon: "
PID=`/bin/pidof -x xfbbd`
if [ -n "$PID" ]; then
echo -e "${green}Yes, fbb is up :)${reset}"
else
echo -e "${red}No, fbb is down :(${reset}"
fi
echo -n "Checking for ax25d daemon: "
PID=`/bin/pidof -x ax25d`
if [ -n "$PID" ]; then
echo -e "${green}Yes, ax25d is up :)${reset}"
else
echo -e "${red}No, ax25d is down :(${reset}"
fi
echo -n "Checking for netromd daemon: "
PID=`/bin/pidof -x netromd`
if [ -n "$PID" ]; then
echo -e "${green}Yes, netromd is up :)${reset}"
else
echo -e "${red}No, netromd is down :(${reset}"
fi
echo -n "Checking for ax25rtd daemon: "
PID=`/bin/pidof -x ax25rtd`
if [ -n "$PID" ]; then
echo -e "${green}Yes, ax25rtd is up :)${reset}"
else
echo -e "${red}No, ax25rtd is down :(${reset}"
fi
echo -n "Checking for flexd daemon: "
PID=`/bin/pidof -x flexd`
if [ -n "$PID" ]; then
echo -e "${green}Yes, flexd is up :)${reset}"
else
echo -e "${red}No, flexd is down :(${reset}"
fi
echo -n "Checking for mheardd daemon: "
PID=`/bin/pidof -x mheardd`
if [ -n "$PID" ]; then
echo -e "${green}Yes, mheardd is up :)${reset}"
else
echo -e "${red}No, mheardd is down :(${reset}"
fi
echo -n "Checking for ax25ipd daemon: "
PID=`/bin/pidof -x ax25ipd`
if [ -n "$PID" ]; then
echo -e "${green}Yes, ax25ipd is up :)${reset}"
else
echo -e "${red}No, ax25ipd is down :(${reset}"
fi
echo -n "Checking for ax25udp daemon: "
PID=`/bin/pidof -x ax25udp`
if [ -n "$PID" ]; then
echo -e "${green}Yes, ax25udp is up :)${reset}"
else
echo -e "${red}No, ax25udp is down :(${reset}"
fi
echo -n "Checking for linuxnet node: "
PID=`/bin/pidof -x linuxnet`
if [ -n "$PID" ]; then
echo -e "${green}Yes, linuxnet is up :)${reset}"
else
echo -e "${red}No, linuxnet node is down :(${reset}"
fi
echo -n "Checking for jnos bbs: "
PID=`/bin/pidof -x jnos`
if [ -n "$PID" ]; then
echo -e "${green}Yes, jnos is up :)${reset}"
else
echo -e "${red}No, jnos is down :(${reset}"
fi
echo -n "Checking for kissattach: "
PID=`/bin/pidof -x kissattach`
if [ -n "$PID" ]; then
echo -e "${green}Yes, kissattach is up :)${reset}"
else
echo -e "${red}No, kissattach is down :(${reset}"
fi
echo -n "Checking for slattach: "
PID=`/bin/pidof -x slattach`
if [ -n "$PID" ]; then
echo -e "${green}Yes, slattach is up :)${reset}"
else
echo -e "${red}No, slattach is down :(${reset}"
fi
echo -n "Checking for kissnetd: "
PID=`/bin/pidof -x kissnetd`
if [ -n "$PID" ]; then
echo -e "${green}Yes, kissnetd is up :)${reset}"
else
echo -e "${red}No, kissnetd is down :(${reset}"
fi
echo -n "Checking for mkiss: "
PID=`/bin/pidof -x mkiss`
if [ -n "$PID" ]; then
echo -e "${green}Yes, mkiss is up :)${reset}"
else
echo -e "${red}No, mkiss is down :(${reset}"
fi
echo -n "Checking for socat: "
PID=`/bin/pidof -x socat`
if [ -n "$PID" ]; then
echo -e "${green}Yes, socat is up :)${reset}"
else
echo -e "${red}No, socat is down :(${reset}"
fi
echo -n "Checking for rstatrxd: "
PID=`/bin/pidof -x rstatrxd`
if [ -n "$PID" ]; then
echo -e "${green}Yes, rstatrxd is up :)${reset}"
else
echo -e "${red}No, rstatrxd is down :(${reset}"
fi
;;
*)
echo "Usage: $0 {start|stop|status|restart}"
exit 1
esac
exit 0