<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'><font style="" color="#000000" face="Tahoma,sans-serif">Here is a modified script that I think answers the need for not overwriting existing files in /var/lib/asterisk/sounds/rpt/nodenames<br id="FontBreak"></font><br><font style="" face="Tahoma,sans-serif">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.</font><font style="" face="Tahoma,sans-serif"><br></font><br><font style="" face="Tahoma,sans-serif">You can call this anything you want to test.. Be sure to make it executable.</font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif"># !/bin/bash</font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif">#</font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif"># Originally Created by Marshall Dias</font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif"># Modified by Doug, WA3DSP 8/18/2015</font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif"># Script to write Calls to /var/lib/asterisk/sounds/rpt/nodenames</font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif"># which will then be used in place of node numbers. This script</font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif"># will NOT overwrite exisitng files.</font><font style="" face="Tahoma,sans-serif"><br>#<br></font><font style="" face="Tahoma,sans-serif"># If you want to start clean and delete all nodename files do</font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif"># rm -rf /var/lib/asterisk/sounds/rpt/nodenames/*</font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif"># or delete just the files you want to replace.</font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif"># See all comments below</font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif"># Set the source directory to the Allstar database on your system.</font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif"># 'locate astdb.txt' This file will exist if you are running any of the</font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif"># images from hamvoip.org or you have installed allmon or lsnodes on</font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif"># your system. For the BBB and RPi2 it will generally be /var/log/asterisk</font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif">SRCDIR=/var/log/asterisk</font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif"># Set the destination directory. I recommend a test directory as shown at first.</font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif"># The final destination would be /var/lib/asterisk/sounds/rpt/nodenames</font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif">#DESTDIR=/var/lib/asterisk/sounds/rpt/nodenames</font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif">DESTDIR=/tmp/nodes</font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif"># Definitions of sound file directories</font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif">NODENAMES=/var/lib/asterisk/sounds/rpt/nodenames</font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif">LETTERS=/var/lib/asterisk/sounds/letters</font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif">NUMBERS=/var/lib/asterisk/sounds/digits</font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif">STRING=""</font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif">while IFS='|' read f1 f2 f3 f4</font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif">do</font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif">echo "Processing Node Number: $f1 - Callsign: $f2"</font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif">STRING=""</font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif">foo=${f2,,}</font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif">for (( i=0; i<${#foo}; i++ )); do</font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif"> char=${foo:$i:1}</font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif"> case ${foo:$i:1} in</font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif"> [0-9]*) FILENAME=$NUMBERS/$char.gsm ;;</font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif"> "/") FILENAME=$LETTERS/slash.gsm ;;</font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif"> "-") FILENAME=$LETTERS/dash.gsm ;;</font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif"> [a-z]*|[A-Z]*) FILENAME=$LETTERS/$char.gsm ;;</font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif"> esac</font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif">STRING="$STRING $FILENAME"</font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif">done</font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif">if [ -f "$DESTDIR/$f1.gsm" ]</font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif"> then</font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif"> echo "$DESTDIR/$f1.gsm exists - not overwriting"</font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif"> else</font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif"> cat $STRING > "$DESTDIR/$f1.gsm"</font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif">fi</font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif">done < $SRCDIR/astdb.txt</font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif"><br></font><font style="" face="Tahoma,sans-serif"># End of script</font><br><br><b><font style="font-size:16pt;" size="4">73 Doug</font><font style="font-size:16pt;" size="4"><br></font><font style="font-size:16pt;" size="4">WA3DSP</font><font style="font-size:16pt;" size="4"><br></font><font style="font-size:16pt;" size="4">http://www.crompton.com/hamradio</font></b><font style="font-size:16pt;" size="4"><br></font> </div></body>
</html>