[App_rpt-users] modified custom nodenames

Doug Crompton doug at crompton.com
Tue Aug 18 22:42:20 UTC 2015


Here is a modified script that I think answers the need for not overwriting existing files in /var/lib/asterisk/sounds/rpt/nodenames
Read the comments! Directories need to be defined! Also I am open to any and all suggestions on improving this. I think it might be a useful script to include in the arm-allstar distributions.

You can call this anything you want to test.. Be sure to make it executable.

# !/bin/bash
#
#  Originally Created by Marshall Dias
#  Modified by Doug, WA3DSP 8/18/2015

# Script to write Calls to /var/lib/asterisk/sounds/rpt/nodenames
# which will then be used in place of node numbers. This script
# will NOT overwrite exisitng files.
#
# If you want to start clean and delete all nodename files do
#    rm -rf /var/lib/asterisk/sounds/rpt/nodenames/*
# or delete just the files you want to replace.
# See all comments below

# Set the source directory to the Allstar database on your system.
# 'locate astdb.txt'  This file will exist if you are running any of the
# images from hamvoip.org or you have installed allmon or lsnodes on
# your system. For the BBB and RPi2 it will generally be /var/log/asterisk

SRCDIR=/var/log/asterisk

# Set the destination directory. I recommend a test directory as shown at first.
# The final destination would be /var/lib/asterisk/sounds/rpt/nodenames

#DESTDIR=/var/lib/asterisk/sounds/rpt/nodenames
DESTDIR=/tmp/nodes

# Definitions of sound file directories

NODENAMES=/var/lib/asterisk/sounds/rpt/nodenames
LETTERS=/var/lib/asterisk/sounds/letters
NUMBERS=/var/lib/asterisk/sounds/digits
STRING=""

while IFS='|' read f1 f2 f3 f4
do

echo "Processing Node Number: $f1 - Callsign: $f2"

STRING=""

foo=${f2,,}
for (( i=0; i<${#foo}; i++ )); do
  char=${foo:$i:1}

                case ${foo:$i:1} in
                [0-9]*) FILENAME=$NUMBERS/$char.gsm ;;
                "/") FILENAME=$LETTERS/slash.gsm ;;
                "-") FILENAME=$LETTERS/dash.gsm ;;
                [a-z]*|[A-Z]*) FILENAME=$LETTERS/$char.gsm ;;
                esac

STRING="$STRING $FILENAME"
done
if [ -f "$DESTDIR/$f1.gsm" ]
  then
    echo "$DESTDIR/$f1.gsm exists - not overwriting"
  else
    cat $STRING > "$DESTDIR/$f1.gsm"
fi
done < $SRCDIR/astdb.txt

# End of script

73 Doug
WA3DSP
http://www.crompton.com/hamradio
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.keekles.org/pipermail/app_rpt-users/attachments/20150818/a6755a45/attachment.html>


More information about the App_rpt-users mailing list