#/bin/bash # #startax.sh #This is my own script to start the ax25 services on my Raspberry Pi node # #Declaring some variables that point to binaries needed for this script DIREWOLF=/usr/local/bin/direwolf ALSACTL=/usr/sbin/alsactl MKISS=/usr/sbin/mkiss KISSATTACH=/usr/sbin/kissattach KISSPARMS=/usr/sbin/kissparms AXLISTEN=/usr/bin/axlisten IP=/bin/ip #User variables for system settings AXINT=vhfdrop TXDELAY=400 TXTAIL=50 #Placeholder IP address for ax25 interface if you wish to run IP over AX25 IPADDR="0.0.0.0" #Declaring variables used in combination with the binaries above DIREWOLFCONF=/etc/ax25/direwolf-packet.conf #NETROM Interface name per /etc/ax25/nrports NETROMIF="netrom0" NETROMIF2="netrom1" #NETROM IP address NETROMIP="44.128.0.1" #Variable declared to point to the log file LOG="/var/log/packet.log" #-------------------------------------------- #0. Start up sequence begins. echo "startax25.sh starting up" echo "startax25.sh starting up" >> $LOG date date >> $LOG #1. Restoring alsa mixer settings echo "Restoring audio levels on soundcard" echo "Restoring audio levels on soundcard" >> $LOG $ALSACTL restore #Now check if it did happen or not. if [ $? -ne 0 ]; then # S? is a special variable that holds the return/exit code of the last executed command. If not equal to 0 then there are errors. echo -e "WARNING: alsamix audio level restore failed. Did you store your proper mixer levels with alsactl?" echo -e "WARNING: alsamix audio level restore failed. Did you store your proper mixer levels with alsactl?" >> $LOG fi #2. Start Direwolf echo "Starting direwolf" echo "Starting direwolf" >> $LOG $DIREWOLF -t 0 -c $DIREWOLFCONF -p >> $LOG 2>&1 & #Now check if it started properly if [ -z "`ps ax | grep -v grep | grep direwolf`" ]; then echo "ERROR: Direwolf did not start properly and is not running, please review $LOG" echo "ERROR: Direwolf did not start properly and is not running, please review $LOG" >> $LOG exit 1 fi sleep 3 #This is important to give direwolf some time to come up with /tmp/kisstnc. Only then the rest can run. #3. Kissattach and Kissparms kissattach /tmp/kisstnc $AXINT $IPADDR kissparms -p $AXINT -c 1 -f n -t $TXDELAY -s 100 -r 63 -l $TXTAIL #4. Bring up the netrom interface if nrports file has been configured and variables in this script are properly configured if [ -n "`grep -v -e "^#" -e "^$" /etc/ax25/nrports`" ]; then /sbin/modprobe netrom if [ $? -ne 0 ]; then echo "ERROR: netrom module did NOT start properly" echo "ERROR: netrom module did NOT start properly" >> $LOG else echo "netrom module loaded" echo "netrom module loaded" >> $LOG fi #The following IP addres here is just a placeholder and won't be used /usr/sbin/nrattach -i $NETROMIP $NETROMIF # /usr/sbin/nrattach -i $NETROMIP $NETROMIF2 if [ $? -ne 0 ]; then echo "ERROR: nrattach did not start properly" echo "ERROR: nrattach did not start properly" >> $LOG else echo "nrattach started" echo "nrattach started" >> $LOG fi # -i : will send a netrom route for this station within 60 seconds # -l : turns on logging for both programs # -t 60 : send future netrom route updates every 60 minutes (default) /usr/sbin/netromd -i -l -t 60 if [ $? -ne 0 ]; then echo "ERROR: netromd did not start properly" echo "ERROR: netromd did not start properly" >> $LOG else echo "netromd started" echo "netromd started" >> $LOG fi fi #5. Start the ax25 daemon /usr/sbin/ax25d
#!/bin/bash # #config files DIREWOLFCONF=/etc/ax25/direwolf-packet.conf #Logging result file LOG="/var/log/packet.log" #Let's shutdown everything, first of all LinPac echo "Shutting down Linpac" echo "Shutting down Linpac" >> $LOG /usr/bin/killall linpac > /dev/null #Stop Ax25 support for PROC_NAME in beacon axlisten mheardd ax25spyd ax25d ax25ipd ax25rtd do PID=`/bin/pidof -x $PROC_NAME` if [ -n "$PID" ]; then echo "Ending $PROC_NAME - $PID " echo "Ending $PROC_NAME - $PID " >> $LOG kill -TERM $PID > /dev/null sleep 1 fi done #Save the NetRom routes before shutting down it down #if [ -f /etc/ax25/nrports ]; then # Save NetRom routes # /usr/sbin/nodesave -p /usr/sbin/ /var/ax25/nrsave # echo "NetRom routes saved" # echo "NetRom routes saved" >> $LOG #fi #Now shut NetRom down pidof netromd > /dev/null if [ $? -eq 0 ]; then # Stop NetRom /usr/bin/killall netromd > /dev/null /sbin/ifconfig nr0 down /sbin/ifconfig nr1 down /sbin/ifconfig nr2 down /sbin/ifconfig nr3 down /sbin/ifconfig nr4 down /sbin/ifconfig nr5 down echo "Stopping Netrom" echo "Stopping Netrom" >> $LOG fi #Stopping Kissattach echo "Stopping Kissattach" echo "Stopping Kissattach" >> $LOG /usr/bin/killall -KILL kissattach > /dev/null #Shut down Direwolf if [ -f $DIREWOLFCONF ]; then #If direwolf is being used echo "Stopping Direwolf" echo "Stopping Direwolf" >> $LOG /usr/bin/killall direwolf fi #Shut down the ax25 daemon /usr/bin/killall ax25d echo -e "ax25 Stopped\n" echo -e "ax25 Stopped\n" >> $LOG