#!/bin/bash # Watches the COR state of the allstar node for activity, then does something after some elapsed time of first activity # Nice to trigger announcements based on activity, etc. # # The heart of this script is polling the node varibles, and isolating the RPT_ETXKEYED variable as this is the COR. # #[root@pi ~]# asterisk -rx "rpt showvars 43337" #Variable listing for node 43337: # RPT_ETXKEYED=0 # RPT_RXKEYED=0 # RPT_NUMLINKS=0 # RPT_LINKS=0 # RPT_NUMALINKS=0 # RPT_ALINKS=0 # RPT_TXKEYED=0 # RPT_AUTOPATCHUP=0 # -- 8 variables # LAST="0" while true do STATE=`asterisk -rx "rpt showvars 43337" | grep "RPT_ETXKEYED" | cut -d = -f2` # edit 43337 to match node number above # Motorola GM300 with COS inverted, using simpleusb; carrierfrom=usbinvert, and duplex=1 # # if [ $STATE -ne $LAST ]; then # determines if state has changed since last pool/loop echo "COR state is:" $STATE NEW=$STATE if [ $NEW = 1 ]; then echo "do something in 3 min" sleep 3m echo "times up.. doing thing" #asterisk -rx "rpt localplay 43337 soundfile" #asterisk -rx "rpt playback 43337 soundfile" # command to key and play file (specify no extension to the sound file) # /var/lib/asterisk/sounds/ has a lot of premade standard sound files # # fi fi LAST=$STATE sleep .1 done