====== Example AX.25 config files using systemd ====== * These files are taken from a system setup with scripts found [[ https://github.com/nwdigitalradio/n7nix | here]] ===== systemd files in /etc/systemd/system ===== * Up-to-date files can be found in nwdigitalradio/n7nix repo [[https://github.com/nwdigitalradio/n7nix/tree/master/systemd/sysd | here]] === ax25dev.service === [Unit] Description=AX.25 device BindsTo=direwolf.service Requires=direwolf.service After=direwolf.service [Service] # Use for debug Type=oneshot ExecStart=/bin/bash -c '/etc/ax25/ax25-upd' RemainAfterExit=yes # Install KISS Parameter: P=32, W=200, TX-Delay=500 # -l txtail Sets the TX Tail time in milliseconds, in steps of ten milliseconds only # -r persist Sets the persist value. range 0 to 255. # -s slottime Sets the slottime in milliseconds, in steps of ten milliseconds only # -t txdelay Sets the TX Delay in milliseconds, in steps of ten milliseconds only ExecStartPost=/bin/bash -c '/usr/local/sbin/kissparms -p udr0 -f no -l 30 -r 128 -s 20 -t 400' ExecStop=/bin/bash -c '/etc/ax25/ax25-downd' [Install] WantedBy=multi-user.target === ax25-mheard.service === [Unit] Description=AX.25 mheard daemon After=ax25dev.service After=sys-subsystem-net-devices-ax0.device BindsTo=sys-subsystem-net-devices-ax0.device [Service] ExecStart=/usr/local/sbin/mheardd -f -n 150 #RestartSec=1min #Restart=on-failure [Install] WantedBy=multi-user.target === ax25dev.path === [Path] PathExists=/tmp/kisstnc [Install] WantedBy=multi-user.target ===ax25d.service === Unit] Description=General purpose AX.25 daemon After=ax25dev.service After=sys-subsystem-net-devices-ax0.device [Service] ExecStart=/usr/local/sbin/ax25d -l [Install] WantedBy=multi-user.target === direwolf.service === [Unit] Description=Direwolf Daemon After=sound.target [Service] ExecStartPre=/bin/rm -f /tmp/kisstnc ExecStart=/usr/bin/direwolf -t 0 -c /etc/direwolf.conf -p ExecStop=/bin/rm -f /tmp/kisstnc [Install] WantedBy=multi-user.target DefaultInstance=1 ===== Files in /etc ===== * Up-to-date files can be found in nwdigitalradio/n7nix repo [[https://github.com/nwdigitalradio/n7nix/tree/master/systemd/sysd | here]] === direwolf.conf === ############################################################# # # # Configuration file for Dire Wolf # # # # Linux version # # # ############################################################# # # Consult the User Guide for more details on configuration options. ############################################################# # # # FIRST AUDIO DEVICE PROPERTIES # # (Channel 0 + 1 if in stereo) # # # ############################################################# ADEVICE plughw:CARD=udrc,DEV=0 plughw:CARD=udrc,DEV=0 ACHANNELS 2 ############################################################# # # # CHANNEL 0 PROPERTIES # # # ############################################################# CHANNEL 0 PTT GPIO 12 MODEM 1200 MYCALL N7NIX-1 ############################################################# # # # CHANNEL 1 PROPERTIES # # # ############################################################# CHANNEL 1 PTT GPIO 23 MODEM 1200 MYCALL N7NIX-2 ############################################################# # # # VIRTUAL TNC SERVER PROPERTIES # # # ############################################################# AGWPORT 8000 KISSPORT 8001 ===== Files in /etc/ax25 ===== * Up-to-date files can be found in nwdigitalradio/n7nix repo [[https://github.com/nwdigitalradio/n7nix/tree/master/systemd/ax25 | here]] === ax25dev-parms === #!/bin/bash if [[ $# -gt 0 ]] ; then Device=$1 else awk '/device/ { print $7 }' /tmp/ax25-config.tmp > /tmp/ax25-config-tmp read Device < /tmp/ax25-config-tmp if [[ -z "$Device" ]] ; then Device="ax0" echo "Set Device to default: $Device" fi fi echo "Using Device = $Device" if [ -d /proc/sys/net/ax25/$Device ] ; then PARMDIR="/proc/sys/net/ax25/$Device" # Parms for a USER Port echo 3000 > $PARMDIR/t1_timeout # (Frack) /1000 = ? Sec echo 1000 > $PARMDIR/t2_timeout # (RESPtime) /1000 = ? sec echo 300000 > $PARMDIR/t3_timeout # (Check) /6000 = ? Min echo 900000 > $PARMDIR/idle_timeout # Idle Timer /6000 = ? min echo 2 > $PARMDIR/standard_window_size # Outstanding Frames echo 12 > $PARMDIR/maximum_retry_count # Max Retrys echo 256 > $PARMDIR/maximum_packet_length # Paclen echo 0 > $PARMDIR/ax25_default_mode echo 0 > $PARMDIR/ip_default_mode echo 0 > $PARMDIR/backoff_type echo 2 > $PARMDIR/connect_mode #echo 180000 > $PARMDIR/dama_slave_timeout echo 32 > $PARMDIR/extended_window_size echo 0 > $PARMDIR/protocol ifconfig $Device netmask 255.255.255.255 echo " Port ${PORTNAME} attached to ${Device} " else echo "** Error setting Device: $Device parms**" fi echo "ax25dev-parms finished" exit 0 === ax25-upd === #!/bin/bash # # ax25-upd for use with systemd & direwolf # Ax25, rose, & mkiss - are pre-loaded via /etc/modules or built into kernel # # Uncomment this statement for debug echos DEBUG=1 SBINDIR=/usr/local/sbin BINDIR=/usr/local/bin UDRCII=false # portname set in /etc/ax25/axports PORTNAME_1="udr0" PORTNAME_2="udr1" SERIALPORT_DIREWOLF="/tmp/kisstnc" firmware_prodfile="/sys/firmware/devicetree/base/hat/product" firmware_prod_idfile="/sys/firmware/devicetree/base/hat/product_id" firmware_vendorfile="/sys/firmware/devicetree/base/hat/vendor" PROD_ID_NAMES=("INVALID" "INVALID" "UDRC" "UDRC II" "DRAWS" "1WSpot") NWDIG_VENDOR_NAME="NW Digital Radio" function dbgecho { if [ ! -z "$DEBUG" ] ; then echo "$*"; fi } # ===== function EEPROM id_check # Return code: # 0 = no EEPROM or no device tree found # 1 = HAT found but not a UDRC # 2 = UDRC # 3 = UDRC II # 4 = DRAWS # 5 = 1WSpot function id_check() { # Initialize to EEPROM not found udrc_prod_id=0 # Does firmware file exist if [ -f $firmware_prodfile ] ; then # Read product file UDRC_PROD="$(tr -d '\0' < $firmware_prodfile)" # Read vendor file FIRM_VENDOR="$(tr -d '\0' < $firmware_vendorfile)" # Read product id file UDRC_ID="$(tr -d '\0' < $firmware_prod_idfile)" #get last character in product id file UDRC_ID=${UDRC_ID: -1} dbgecho "UDRC_PROD: $UDRC_PROD, ID: $UDRC_ID" if [[ "$FIRM_VENDOR" == "$NWDIG_VENDOR_NAME" ]] ; then case $UDRC_PROD in "Universal Digital Radio Controller") udrc_prod_id=2 ;; "Universal Digital Radio Controller II") udrc_prod_id=3 ;; "Digital Radio Amateur Work Station") udrc_prod_id=4 ;; "1WSpot") udrc_prod_id=5 ;; *) echo "Found something but not a UDRC: $UDRC_PROD" udrc_prod_id=1 ;; esac else dbgecho "Probably not a NW Digital Radio product: $FIRM_VENDOR" udrc_prod_id=1 fi if [ udrc_prod_id != 0 ] && [ udrc_prod_id != 1 ] ; then if (( UDRC_ID == udrc_prod_id )) ; then dbgecho "Product ID match: $udrc_prod_id" else echo "Product ID MISMATCH $UDRC_ID : $udrc_prod_id" udrc_prod_id=1 fi fi dbgecho "Found HAT for ${PROD_ID_NAMES[$UDRC_ID]} with product ID: $UDRC_ID" else # RPi HAT ID EEPROM may not have been programmed in engineering samples # or there is no RPi HAT installed. udrc_prod_id=0 fi return $udrc_prod_id } # ===== main ===== echo "ax25-upd: Start Port ${PORTNAME_1} with device ${SERIALPORT_DIREWOLF}" if [ -L $SERIALPORT_DIREWOLF ] ; then echo "Direwolf serial port ready" else echo "Direwolf serial port NOT FOUND" d exit 1 fi # Check which UDRC product is found id_check id_check_ret="$?" # Initialize kissattach return code kissattach_ret=-1 case $id_check_ret in 0|1) echo "No UDRC found, exiting" exit 1 ;; 2) echo "Original UDRC is installed." # use port 1 with mkiss pseudoterm=$($SBINDIR/mkiss $SERIALPORT_DIREWOLF /dev/ptmx none | tail -1) echo "using mkiss with UDRC and pseudo term=$pseudoterm on port 1" $SBINDIR/kissattach ${pseudoterm} ${PORTNAME_1} 44.24.197.66 >/tmp/ax25-config.tmp kissattach_ret=$? dbgecho "kissattach return: $?" /etc/ax25/ax25dev-parms ax0 ;; 3|4) echo "UDRC II or DRAWS installed" # use port 2 with mkiss pseudoterm=$($SBINDIR/mkiss $SERIALPORT_DIREWOLF /dev/ptmx /dev/ptmx | tail -1) echo "$pseudoterm" > /tmp/ax25-config.tmp pseudoterm_1=$(echo $pseudoterm | cut -d ' ' -f1) pseudoterm_2=$(echo $pseudoterm | cut -d ' ' -f2) echo "using mkiss with UDRC II and pseudo term_1: $pseudoterm_1 pseudo term_2: $pseudoterm_2" $SBINDIR/kissattach ${pseudoterm_1} ${PORTNAME_1} 44.24.197.66 >/tmp/ax25-config_1.tmp $SBINDIR/kissattach ${pseudoterm_2} ${PORTNAME_2} 44.24.197.67 >/tmp/ax25-config_2.tmp kissattach_ret=$? dbgecho "kissattach return: $?" /etc/ax25/ax25dev-parms ax0 /etc/ax25/ax25dev-parms ax1 echo " Port ${PORTNAME_1} attached to ax0" echo " Port ${PORTNAME_2} attached to ax1" ;; 5) echo "One Watt Spot installed" # use port 1 with mkiss pseudoterm=$($SBINDIR/mkiss $SERIALPORT_DIREWOLF /dev/ptmx none | tail -1) echo "using mkiss with UDRC and pseudo term=$pseudoterm on port 1" $SBINDIR/kissattach ${pseudoterm} ${PORTNAME_1} 44.24.197.66 >/tmp/ax25-config.tmp kissattach_ret=$? dbgecho "kissattach return: $?" /etc/ax25/ax25dev-parms ax0 ;; *) echo "Invalid udrc id ... exiting" exit 1 ;; esac # configure netrom # Needs a callsign # source /home/pi/n7nix/systemd/ax25/nr-up.sh # AX25-upd (End) echo echo "ax25-upd script finished" exit 0 === ax25-downd === #!/bin/bash # SBINPATH="/usr/local/sbin" echo "ax25-downd start" # Stop FPAC # /usr/local/sbin/myfpac.sh stop # Stop Ax25 support # for PROC_NAME in beacon ax25d ax25ipd ax25rtd mheardd listen saxIgate for PROC_NAME in beacon ax25d ax25ipd ax25rtd mheardd saxIgate do PID=`/bin/pidof -x $PROC_NAME` if [ -n "$PID" ]; then kill -TERM $PID > /dev/null echo "$PROC_NAME - $PID " sleep 1 fi done # If netromd is running pidof netromd > /dev/null if [ $? -eq 0 ]; then # Save NetRom routes $SBINPATH/nodesave -p $SBINPATH /var/ax25/nrsave && echo "N/R routes saved" # Stop NetRom killall netromd > /dev/null echo "Netrom Stopped" else echo "Netrom daemon not running" fi # Close sockets echo "Detach Ax/Nr/Sp Devices" ifconfig|grep AMPR > /tmp/ax25-config.tmp i=0 iface=$(awk ' NR == '1' { print $1 }' /tmp/ax25-config.tmp) while [ "$iface" != "" ] ; do let i=i+1 iface=$(awk ' NR == '$i' { print $1 }' /tmp/ax25-config.tmp) if [ "$iface" != "" ] && [ "${iface:0:2}" == "nr" ] ; then # echo "select: $iface, iface: ${iface:0:2}" ifconfig "$iface" down echo " $iface down" fi done # Stop Kissattach killall -KILL kissattach > /dev/null # Empty Heard List #cat /dev/null > /var/ax25/mheard/mheard.dat # End of ax25-down echo "ax25-downd finished" exit 0 === axports === # /usr/local/etc/ax25/axports # # Use simple descriptive names for the ports, to make debugging # other associated software easier. # # The format of this file is: #portname callsign speed paclen window description udr0 N7NIX-10 9600 255 2 Winlink === ax25d.conf === # /usr/local/etc/ax25/ax25d.conf # # ax25d Configuration File. # # [N7NIX-10 VIA udr0] NOCALL * * * * * * L NOCALL * * * * * * L default * * * * * * - rmsgw /usr/local/bin/rmsgw rmsgw -l debug -P %d %U # [N7NIX VIA udr0] NOCALL * * * * * * L default * * * * * * 0 gunn /usr/local/bin/wl2kax25d wl2kax25d -c %U -a %d #