Script – Initial ID / Normal ID

Many of us that are use to the older premiumĀ  “hard-wire” style repeater controller are also use to having a initial ID that would allow for a separate ID to be played when the repeater was keyed for the first time from a sleep state.

Then afterwards, would play a normal ID at “id-interval” timing that would be a short ID for in-use.

Most of us would use that Initial ID to play a long ID stating extended info about the repeater like location information so when someone stumbled on the repeater late at night or when nobody was around to ask, they would have the correct info about which repeater they were accessing and where it was.

While there was limited ways to accurately obtain this info and act on it in a way that was uncomplicated for a control-op to install correctly and use, I took it to task.

This is totally a Bash Script that needs to be run from start-up
or from a command line (should do for testing beforehand).
Made/Tested with ACID.

Here is the result.

You need two audio files of the ID's before you start.
Here called "idmsg1" (initial/sleep id)
& "idmsg2" (wake/regular id) and 
our actual id message is "idmsg"
You can just take one of those files and copy ( cp ) it to a new filename for idmsg 
like this:  cp idmsg1.wav idmsg.wav
(assuming you are in the directory of the files)

I'll call the shell script init-id.sh
If running multi-nodes on a single server, you might want to make a new filename like:
init-id-29283.sh
init-id-29284.sh
so you can have separate id's for each nodes.
This would mean making a script for each node and running a new process for each.
If you do this, change the /tmp/init-id.txt located in "two places" in the
file to the same unique format.

In rpt.conf
You need to give it a command:ex
909804=cmd,/etc/asterisk/myscripts/init-id-29283.sh

Use the startup macro to call it:ex
startup_macro=*9401,*9410,*909804

You need to edit before running:
Node number
files and locations of your 2 id files and the /location/name of your voice-id file
(idrecording =/etc/asterisk/msg/idmsg) in both locations in the script.
Pay close attention to spaces when editing as it will change things in error.

Make the files & script we are using 775 ownership

"DO" RUN THIS FROM A COMMAND LINE FOR TEST BEFORE LOADING FROM rpt.conf
(from a shell)
cd /etc/asterisk/myscripts (where located)
./init-id-29283.sh  ( ./ with actual name you use .sh)
and you use <ctrl> + C to break and stop it from command line running it.
change sleep number to 20 for command line testing and 200 when auto
loading to limit file accesses. 
I'm Assuming a 5 minute or better id interval.

Do pay close attention to spaces in the file when editing.
You will create errors if not and not understand where from.

Download as File

At the bottom of this page is shown what the response will look like from a command line.

When needed, the script simply 
copies idmsg1 to idmsg (sleep/init-id)
or
copies idmsg2 to idmsg (wake/normal-id)
But will not attempt to write while ID is playing. ider_state=0

#!/bin/bash
# init-id.sh - mike/kb8jnm
# overwrite id files to create initial id & regular id
# based on app_rpt - "ider_state" variable.
#
# make ownership of this file 775
#
# -See sleep ### at the bottom is in seconds.
# Lower the value to 20 for testing live from a command line.
# You will see the updates faster.
#

# preset some parms
idis='wakeid'

# this is a infinate loop
while :
do

# read our parms for node - put in text file - (edit node number)
 asterisk -rx "rpt xnode 29283" > /tmp/init-id-29283.txt

# parse our parms from that file and only rewrite id if it needs it
 while read line
 do
 echo $line
 idsleep='ider_state=2'
 idwake='ider_state=1'

 if [ "$line" = "$idsleep" ] && [ "$idis" = "wakeid" ]; then
# edit locations and names next line
 cp /etc/asterisk/msg/idmsg1.wav /etc/asterisk/msg/idmsg.wav
 echo " ** " $line $idsleep "-init ID"
 idis='sleepid'
 fi
 if [ "$line" = "$idwake" ] && [ "$idis" = "sleepid" ]; then
# edit locations and names next line
 cp /etc/asterisk/msg/idmsg2.wav /etc/asterisk/msg/idmsg.wav
 echo " ** " $line $idwake "-normal ID"
 idis='wakeid'
 fi
 done </tmp/init-id-29283.txt

# show status if running from a command line for test
echo "ID IS " $idis

# wait a bit to limit file access (in seconds)
sleep 200

done


If everything is working fine, 
you will see something like this at a command line
when you execute it:

RPT_NUMLINKS=1     ;these are parms returned by app_rpt on xnode
RPT_LINKS=1,T41715
RPT_NUMALINKS=1
RPT_ALINKS=1,41715TU
RPT_AUTOPATCHUP=0
RPT_ETXKEYED=0
RPT_TXKEYED=0
RPT_RXKEYED=0

parrot_ena=0
sys_ena=1
tot_ena=1
link_ena=1
patch_ena=1
patch_state=4
sch_ena=1
user_funs=1
tail_type=0
iconns=1
tot_state=2
ider_state=2       ;when our script sees this line it acts.
 **  ider_state=2 ider_state=2 -init ID     ;these are echos of internal vars
tel_mode=2

ID IS  sleepid      ;this is a echo of internal var of current state.

Don't forget to check your timers...
totime=600000 ;in milisoconds 300000=5min
idtime=590000 ; in 10ms
politeid=500000 ; =8m20s
sleeptime=1830 ;in seconds 300=5m