rc.ax25 file.

#!/bin/sh

# Get config.
. /etc/rc.d/axdefs

check () {
daemon="$input"
PID=`ps ax | grep $daemon | grep -v grep | awk '{ print $1 }'`
if [ "$PID" = "" ]; then
	echo "No $daemon running, starting it now..."
	s$daemon
else
	echo "$daemon is running, PID=$PID"
fi
}

smheardd () {
${UDIR}/mheardd -l -n25 &
input=mheard
scheck
}

sax25d () {
${UDIR}/ax25d -l &
input=ax25d
scheck
}

scheck () {
daemon="$input"
# Allow the deamon to be started.
sleep 1
PID=`ps ax | grep $daemon | grep -v grep | awk '{ print $1 }'`
if [ "$PID" = "" ]; then
	echo "ERROR, $input failed to start..."
else
	echo "$input has been restarted, PID=$PID"
fi
}

assoc () {
call="$input"
OK=`${UDIR}/axparms -assoc show | grep $input | wc -l`
if [ $OK = 0 ]; then
	echo "$input not found, adding $input to the list..."
	${UDIR}/axparms -assoc $input $input
	if [ $OK = 1 ]; then
		echo "$input has been added..."
		${UDIR}/axparms -assoc show | grep $input
else
	echo "$input is associated"
	${UDIR}/axparms -assoc show | grep $input
	fi
fi
}

interface () {
UP=`${SDIR}/ifconfig $ifc | grep RUNNING | awk '{ print $2 }'`
}

boldon () {
setterm -bold on
}

boldoff () {
setterm -bold off
clear
}

interstats () {
OK=`${SDIR}/ifconfig $input | grep RUNNING | awk '{ print $2 }'`
if [ "$OK" = "RUNNING" ]; then
	${SDIR}/ifconfig > $TMP/TMP001
	dialog --title "Stats  for interface." --textbox "$TMP/TEMP001" 16 73
fi
}

case "$1" in

  up)
	MODMKISS=`${SDIR}/lsmod | grep mkiss | head -n1 | awk '{ print $1 }'`
	if [ "$MODMKISS" = "mkiss" ]; then
		echo "Module mkiss already loaded..."
	else
		${SDIR}/modprobe mkiss
	fi

	MODNETROM=`${SDIR}/lsmod | grep netrom | head -n1 | awk '{ print $1 }'`
	if [ "$MODNETROM" = "netrom" ]; then
		echo "Module netrom already loaded..."
	else
		${SDIR}/modprobe netrom
	fi
	
	RUNNING=`${SDIR}/ifconfig nr0 | grep RUNNING | awk '{ print $2 }'`
	if [ "$RUNNING" = "RUNNING" ]; then
		echo "Interface nr0 is already up and running..."
	else
		${UDIR}/nrattach -i ${IPADDR} -m 236 netrom
		${SDIR}/ifconfig nr0 broadcast ${BROADCAST}
		${SDIR}/route del -net 44.0.0.0 netmask 255.0.0.0 nr0
#		${UDIR}/netromd -i -d -l -q220 -p1 -t30 &
		echo 50 > /proc/sys/net/netrom/transport_acknowledge_delay
	fi
	
	#${SDIR}/modprobe bpqether
	#${SDIR}/ifconfig bpq0 ${IPADDR} hw ax25 ${BPQC} up
	#${SDIR}/ifconfig bpq0 broadcast ${BROADCAST}
	#${UDIR}/bpqparms bpq0 -d ${BPQ}
        #${SDIR}/route del -net 44.0.0.0 netmask 255.0.0.0 bpq0

	if [ -f /etc/rc.d/rc.tunnel ]; then
		/etc/rc.d/rc.tunnel up
	fi

	if [ -f /etc/rc.d/rc.ax0 ]; then
		/etc/rc.d/rc.ax0 up
	fi

	if [ -f /etc/rc.d/rc.scc ]; then
		/etc/rc.d/rc.scc up
	fi
	
	# Start netromd here, see what happens...
	${UDIR}/netromd -i -d -l -q220 -p1 -t30 &	

	# Adjust axparameters
	echo 200 >/proc/sys/net/ipv4/neigh/ax0/retrans_time
	echo 200 > /proc/sys/net/ipv4/neigh/ax0/anycast_delay

	input=mheardd
	check
	input=ax25d
	check
	# Check claasign assoc's.
	input=pa3gcu
	assoc
	input=pa5kt
	assoc
	input=pe1pts
	assoc
	input=pe9ghz
	assoc
	input=ve1drg
	assoc
	;;

  down)
	ifc=nr0
	interface
	if [ "$UP" = "RUNNING" ]; then
		ifconfig nr0 down
		killall -9 netromd
	else
		echo "Interface $ifc is not RUNNING..."
	fi
	
	ifc=tunl0
	interface
	if [ "$UP" = "RUNNING" ]; then
		/etc/rc.d/rc.tunnel down
	else
		echo "Interface $ifc is not RUNNING..."
	fi

	ifc=ax0
	interface
	if [ "$UP" = "RUNNING" ]; then
		/etc/rc.d/rc.ax0 down
	else
		echo "Interface $ifc is not RUNNING..."
	fi

	ifc=scc3
	interface
	if [ "$UP" = "RUNNING" ]; then
		/etc/rc.d/rc.scc down
	else
		echo "Interface $ifc is not RUNNING..."
	fi


	killall mheardd
	;;

  stats)
	echo -e "Enter interface to view" ; read x
	if [ "$x" = "" ]; then
		echo "No input..."
		exit 1
	fi
	OK=`${SDIR}/ifconfig | grep $x | wc -l`
	if [ "$OK" -eq 1 ]; then
		${SDIR}/ifconfig $x
		echo -n "Hit enter to Continue."
		read a
		clear
		${UBDIR}/mheard $x
		echo -n "Hit enter to Continue."
		read a
		clear
	else
		echo "Not a vlaid interface..."
		echo "OR its the port name, looking....."
		OK=`cat /etc/ax25/axports | grep $x | awk '{ print $1 }'`
		if [ "$OK" = "$x" ]; then
			cat /etc/ax25/axports | grep axip | awk '{ print "callsign = " $2 }'
			CALL=`cat /etc/ax25/axports | grep $x | awk '{ print $2 }'`
			${SDIR}/ifconfig | grep -A6 $CALL
			echo -n "Hit enter to continue..."
			read a
			clear
			${UBDIR}/mheard $x
		fi 
	fi
	;;
  *)
	echo "USAGE: rc.ax25 up | down | stats"

esac
exit 0
  • Back to ax25-description page.