Tuesday, January 3, 2023

AllStarLink - Announce IP Address

The following script can be used to announce your AllStarLink's node IP address.  I needed this because my portable node connects via WIFI and the IP address changes.

Create /usr/sbin/sayip.sh and insert the following code:

#!/bin/sh

Node=54362

DONE=0

while [ $DONE -eq 0 ]

do

IPADDR=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/')    

if [ ".$IPADDR" = "." ]

     then

echo "no ip address"

DONE=1

else

         CMD="cat "

         for x in `echo "$IPADDR" | fold -w1`; do

           if [ "$x" = "." ]

           then

           CMD=$CMD"/var/lib/asterisk/sounds/letters/dot.ulaw "

     else

           CMD=$CMD"/var/lib/asterisk/sounds/digits/$x.ulaw "

           fi

         done

`$CMD >/tmp/ip.ulaw`

        /usr/sbin/asterisk -rx "rpt playback $Node /tmp/ip" 

DONE=1

     fi

done

Change Node=54362 to your node number.

Make the file executable with the command: chmod ugo+x /usr/sbin/sayip.sh

Edit /etc/rpt.conf and add a command like the following in the [functions] stanza.

980=cmd,/usr/sbin/sayip.sh

In your node stanza, change the startupmacro so that it reads startupmacro=*980

Now when your node boots, you it will automatically announce the assigned ip address.

Note:  This code is based on the sayip.sh script included with ASL-Asterisk.



No comments:

Post a Comment