How To Set Up NewsLine On Multiple Allstar Nodes
There are several HOWTOs out there that explain how to set up your Allstar node to broadcast Newsline. Those methods work well if you only have one node to deal with. But what if you have more than one?
My system currently consists of 4 repeaters, all linked via Allstar to a hub Allstar node at my house (I use Private Node Numbering and my nodes are not advertised via the Allstar Registration Server). The reason for this is that I have Internet connectivity at my house but not my repeater sites and I want to be able to tie IRLP/EchoLink into my system, as well as a S.A.M.E. weather receiver.
This document will explain how to automate the process of broadcasting Amateur Radio NewsLine through your mutli-node Allstar system.
On my system, the latest news.mp3 from https://www.arnewsline.org/ is automatically downloaded on Friday afternoon, giving me lots of time to manually insert my IDs before broadcasting NewsLine on Sunday and Monday evenings. In addition, all day Sunday and Monday, my system sends a tail message out to all repeaters informing about the 6 pm broadcast time.
The process works like this:
- Every Friday at 4:10 pm local time, a cronjob downloads the NewsLine news.mp3 file and moves it to its own directory (/etc/asterisk/audio/newsfiles/).
- On Sunday and Monday, 0700 hours local time, another cronjob starts the Tail Message script to announce the broadcast at 1800 hours. The script runs 2 minutes after the last activity on any repeater in the system but cannot run more frequently than every 15 minutes. It sends commands to each of the other nodes (via passwordless ssh login) to play the appropriate tail message directly on that node. The script self-terminates at 1749 hours local time.
- At 1750 local time, another cronjob starts the script that send commands to each node to announce the 10 and 5 minute warning at 1750 and 1755 hours local time respectively and then broadcasts NewsLine.
- At 1752 hours local time on Sunday, a cronjob runs the script that converts the news.mp3 file to news.ul, an audio format that Allstar understands and sends a copy to each of the nodes in the system. It then deletes the now unneeded news.mp3 and news.wav files (the .wav version is created as part of the conversion process from .mp3 to .ul).
- Right before NewsLine plays, send the appropriate command to instruct each of the remote Allstar nodes to send DTMF to their connected RC210 Repeater Controller, which in turn runs a Macro to disable the repeater’s receiver, Timeout Timer and IDs for 30 minutes (as the NewsLine audio file contains the necessary IDs, there is no need for the controller to do so). Disabling the Timeout Timer ensures the transmitter stays active for the entire broadcast.
- After NewsLine completes, send the appropriate command to instruct each of the remote Allstar nodes to send DTMF to their connected RC210 Repeater Controller, which in turn runs a Macro to re-enable the repeater’s receiver, Timeout Timer IDs
As I broadcast Newsline on both Sunday and Monday evenings, I have crontabs set to duplicate everything except the download and file convert/copy on Mondays.
Assumptions Made In This Document
It is assumed that you know how to create and edit files on your Allstar Node and have a basic understanding of Linux and how it works.
My Allstar link system consists of a main hub and 3 remote nodes.
As you will see my scripts for distributing files, etc are tailored for my system. Of course, you will probably need to make some changes as your needs may be different and the scripts should be easy to edit as such. At the bare minimum, you’ll want to use your own Node numbers and IP addresses.
I use the AREDN Mesh Network to link it all together (https://willamettevalleymesh.net/ and https://www.arednmesh.org/) and it works very well. There is no reason you can’t use the Internet in place of the AREDN Mesh and my scripts, etc, will work just as well that way.
You might also notice each Allstar node/server also has something called “WebRCP” installed. This is a custom web browser based suite I created to manage my RC210 Repeater Controllers over the Mesh. You can see a demo of it here https://www.arcomcontrollers.com/WebRCP
You should already have Perl installed on your system. You can check by typing (at the command line)
perl -v
Next, check that cpan is installed as we need to use the perl module Time::ParseDate.pm in one of the scripts
You can check by typing (at the command line)
cpan
Once in, use the following command to install the needed module
install Time::ParseDate.pm
If you’re missing perl and/or cpan, there is lots of info on the Internet about how to get and install them.
Remember that the scripts, creation of ramdisk and most other changes only need be done on your “hub” node (the exception to this are the DTMF commands additions that need to be added to each of your remote nodes’ rpt.conf file. More on this later).
For now, let’s get to work!
How To Connect To Your Remote Allstar Nodes Without A Password
You probably know how to use ssh to connect to your various Allstar nodes and also realize that (depending on which ssh client you use), you need to enter your password each time you log in. Fortunately for us, Linux provides an easy way to allow us to ssh to a remote node without requiring a password be entered every time we do so, FROM A PARTICULAR COMPUTER. This is very secure and allows for unattended operation, such as from a cronjob.
The first thing we need to do is to generate a public key from the Allstar server/node that will serve as our “master” or “hub” so we can send commands to the remote Allstar nodes without needing a password.
Log onto your Hub Allstar node and drop to the bash shell. Change your directory to /root if not already there.
From the command line, enter the following command:
ssh-keygen
From the output, you will see that it created a private-public key pair saved in /root/.ssh/id_rsa and /root/.ssh/id_rsa.pub respectively.
In order to connect to a remote host with your private key, you need to copy the public key to it. This needs to be done only once. As we need to connect as user root, use the following command:
ssh-copy-id root@destination_address>
“destination_address” is the IP (or domain name) of the remote node you want to connect to
You can test that this worked by sending a command to the remote node. For example, from the command line:
ssh root@destination_address ls /etc
If all is working, you should receive a directory listing back from the remote node of its /etc directory.
You need to copy your public key to each remote node you wish to connect to without the need of providing a password. Remember however that this will only work from the current node you’re working with.
In addition to playing the NewsLine news file, my scripts also play various advisories sound files
You can click on the above files and download them for your own use. I had them professionally recorded but you may use them for your own personal non-commercial Amateur Radio use. Move them to /etc/asterisk/audio/newsfiles/ on EACH OF YOUR NODES.
Creating ramdisk on your Allstar node
In order for the new scripts to know when your node is actively receiving or transmitting, we’re going to add some items to its rpt.conf file that checks for such activity and create a file so applications other than Allstar know about it. As I’m running my server/node on a Raspberry Pi, I didn’t want to do continuous writes to the SD card so I created ramdisk on the server.
From the command line (as root), enter:
mkdir /etc/ramdisk
Now edit /etc/fstab to create ramdisk on startup of Linux and add the following line
tmpfs /etc/ramdisk tmpfs nodev,nosuid,size=1M 0 0
Reboot your server and you’ll see the new ramdisk. Enter the command:
df -h |grep ramdisk
which should return:
tmpfs 1.0M 0 1.0M 0% /etc/ramdisk
Editing the /etc/asterisk/rpt.conf file on your local (“hub”) node
There are some additions that are needed to your Allstar node’s rpt.conf file in order to generate the file that is used by the scripts to determine activity. This only needs to be done on your hub node.
Under the node stanza, add the following line;
events = events1234
At the end of the file, add the following 6 lines:
[events1234]
;the following 4 lines create a file and delete it in response to either Allstar RX or TX activity/inactivity
Save the changes and restart your Allstar node
If you look at /etc/ramdisk, you’ll see that a file “cor” exists while your node is either receiving or transmitting. When it is doing neither, there will be no file in /etc/ramdisk. We now have a way for our scripts to know that our node is transmitting/receiving or not.
Editing the /etc/asterisk/rpt.conf file on your remote nodes
In order to allow the remote nodes to send pre-configured DTMF to the RC210 (in order to run the Macros to disable Timeout, etc and later re-enable it), we need to define DTMF digits to send and the code to send them. Remember, these lines need to be added to each of your remote nodes’ rpt.conf file
Under the [functions] stanza, add the following 4 lines:
As you see above, if we send the DMTF command *880 to the remote node, it will send DTMF AACD to the controller. Likewise, if we send the DTMF command *881 to the node, it will send DTMF AABD to the controller. You will probably need to make some changes to the DTMF digits for your particular setup. Save the file and restart the node.
copy_news Script
If not already present, create a directory /etc/asterisk/custom then change to it (cd /etc/asterisk/custom) Note that Allstar (asterisk) only knows how to deal with ul type sound files. As such, we need to convert the downloaded news.mp3 file to news.ul. We need to do this in 2 steps and then send the converted news file to each node.
Create the file /etc/asterisk/custom/copy_news and place the following in it:
You may need to add (or subtract) entries for each node depending on your system
Save the file and, from the command line, enter chmod u+x copy_news
news_download Script
This script is the one to download the NewsLine mp3 news file. Make sure you’re still in /etc/asterisk/custom, create a file called news_download and place the following in it:
!/bin/bash
Save the file and, from the command line, enter chmod u+x news_download
tailmsg Script
This is the script to send the announcement 2 minutes after the last use of any repeater in the system. Note that this script is written in Perl as it runs continuously in the background and Perl does this “better” than a bash or PHP script. Create the file /etc/asterisk/custom/tailmsg and place the following in it:
my $active=0;
my $lastmsg=0;
my $inactive_halfseconds=1;
my $howoften = 120;
my $msgtimer=0;
my $filename = '/etc/ramdisk/cor';
if( ($Hour == 17 && $Minute > 30) || $Hour > 17 ){
print "Quitting\n";
exit;
}
print ("Success\n");
$active=1;
}
if($active) {
print "ACTIVE\n";
$inactive_halfseconds=1;
} else {
$inactive_halfseconds++;
}
if( ($inactive_halfseconds / 120) > $howoften) {
send_tailmessage();
print "TAIL MESSAGE!!! $lastmsg \n" ;
$inactive_halfseconds = 0;
}
$msgtimer=0;
while($active==1) {
sleep 1;
$msgtimer++;
print "Timer $msgtimer \n" ;
if($msgtimer > 120){
print "TAIL MESSAGE!!! $lastmsg \n" ;
send_tailmessage();
$active=0;
}
}
}
# abort if last message was less than 300 seconds ago
my $now = time();
print "now=$now, lastmsg=$lastmsg\n";
if( ( (time() - 900) < $lastmsg) && $lastmsg > 0) {
print "tail message aborted, too soon \n";
return;
}
# abort if COR is active
if(-e $filename){
print "tail message aborted, COR ACTIVE \n";
$msgtimer=0;
return;
}
select(undef,undef,undef,.5);
system("/usr/sbin/asterisk -rx 'rpt playback 1100 /etc/asterisk/audio/newsfiles/newstonight'");
my @args = ( '-l', 'root',
'10.48.13.20',
"/usr/sbin/asterisk -rx 'rpt playback 1101 /etc/asterisk/audio/newsfiles/newstonight'"
);
system('ssh',@args);
@args = ( '-l', 'root',
'10.45.104.70',
"/usr/sbin/asterisk -rx 'rpt playback 1102 /etc/asterisk/audio/newsfiles/newstonight'"
);
system('ssh',@args);
@args = ( '-l', 'root',
'10.45.104.68',
"/usr/sbin/asterisk -rx 'rpt playback 1103 /etc/asterisk/audio/newsfiles/newstonight'"
);
system('ssh',@args);
$lastmsg=time();
}
Save the file and, from the command line, enter chmod u+x tailmsg
news_tx Script
This is the script that commands all nodes to announce the 10 and 5 minute warnings, send DMTF to the controller (instructing it to run the Macros to disable timeouts, repeater receiver and IDs), play the NewsLine audio file and re-enable timeouts, receiver and IDs after the broadcast has concluded. It starts right after the tailmsg script self-terminates
Create the file /etc/asterisk/custom/news_tx and place the following in it:
Save the file and, from the command line, enter chmod u+x news_tx
And finally, we need to program up some crontabs so we can automate the process
At the command prompt, type crontab -e
and add the following lines:
Save the crontab
The first line runs on Friday at 1610 hours local time to download the news.mp3 from the ARNewsLine website
The second line runs on Sunday at 1752 hours local time to convert the downloaded news.mp3 file to news.ul and then sends the converted file to each of our nodes
The third and fourth lines run on Sunday and Monday respectively at 1749 hours local time to give the 10 and 5 minute warnings and plays the actual NewLine broadcast.
Of course, you may wish to modify the days and/or times to fit your needs. Just remember that you need to run copy_news before your NewsLine broadcast starts and be sure to give it at least a few minutes to copy to each of your nodes.
And there you have it. You can automate your NewsLine broadcast on your multiple node Allstar system easily and without too much fuss. In fact, all you need do is edit the downloaded mp3 from NewsLine to insert your own ID and you’re done. The rest will take care of itself
73,
Ken, AH6LE