Add dynamic talk group scripts from Jon G4TSN.

This commit is contained in:
Jonathan Naylor
2020-04-21 21:43:53 +01:00
parent 1542c9750d
commit 4ed53d9bab
18 changed files with 450 additions and 0 deletions

130
scripts/opt/script/README Normal file
View File

@@ -0,0 +1,130 @@
These scripts are supplied as is and work in conjuction with DMRGateway Mid April 2020 Onwards .....If you don't understand the notes ask someone who does please
Tested on rasp pi running MMDVMHost and DMRGateway Using SUDO-Reflector-TalkGroups
These scripts provide a means to setup via the config file default TG's for each slot on a repeater. These should be also setup as only Static TG setup via Brandmeister Selfcare, so that when
a slot is commanded to another dynamic TG by a user and then after use they forget to unlink. The BM Dynamic TG timer which is monitored by this script (expires 10 minutes after inactivity)
the slot will be returned to the configured Static default TG.
Both slots can be monitored together and as they maybe taken off to other dynamics at the same time or individually it is worth getting users in the habit of sending a PC 4000 once they finish
using a different TG as it ensures the repeater when not in use is in the correct place for most of the time.
A default TG of choice which can be configured linking provided on on both slots.
Installation
Firstly DMRGateway should have the following lines minimum configuring if running both timeslots for SUDO Reflector on a repeater
# Dynamic rewriting of slot 2 TGs 90-999999 to TG9 to emulate reflector behaviour Private call manual dial commands PC 2351 for SUDO REF TG 2351 PC 4000 unlink PC 5000 Status PC 9990 echo BM
TGDynRewrite0=1,90,4000,5000,9,999910,9990
TGDynRewrite1=2,90,4000,5000,9,999910,9990
Check you also have the following section added in your DMRGateway config file its usually at the bottom
[Dynamic TG Control]
Enabled=1
Port=3769
copy the package DMRGateway-TGDynRewrite-relinker-2.0.tgz to the folder / unpack with tar -xvf packagename which should create folders /opt/script/script runtimes and /var/log/script/various working files and log
configure the config file /opt/script/script.conf call repeater=235??? ID with your default slots and dont forget to set these static via BM selfcare also min relink timer minrelinktimer in seconds
this is the time before reconnection on a slot after someone finishes and either the slot is unlinked by the user or the dynamic times out
Add the following line to crontab on the rasp pi you dont need to do anything else just save crontab and exit
17 * * * * root echo -n "" > /var/log/script/checkBMAPI.log
Add one of the following to etc/rc.local right at end just before exit 0
/opt/script/./run-relinker.sh
or
/opt/script/./run-relinker-hotspot.sh
pi-star additional step
Also in same file etc/rc.local
look for
if [ ! -d /var/log/unattended-upgrades ]; then
mkdir -p /var/log/unattended-upgrades
fi
add only the below lines just below the above block
if [ ! -d /var/log/script ]; then
/opt/script/./start.sh
fi
reboot
you can tail the log file at the command prompt
tail -f /var/log/script/checkBMAPI.log
Have fun
73,
Jon G4TSN
jon@g4tsn.com

View File

@@ -0,0 +1,11 @@
#!/bin/bash
cp DMRG*.tgz /
cd /
tar -xvf DMRG*

View File

@@ -0,0 +1,135 @@
#!/bin/bash
source /opt/script/script.conf
#check BM API
check_BM_API(){
echo "Repeater $call $repeater"
date
curl "https://api.brandmeister.network/v1.0/repeater/?action=profile&q=$repeater" > /var/log/script/test1.txt
sed -n -e 's/^.*tarantool"}],//p' /var/log/script/test1.txt > /var/log/script/test2.txt
sed 's/}],"timedSubscriptions.*//' /var/log/script/test2.txt > /var/log/script/test3.txt
sed -n -e 's/^.*slot":1,"timeout"://p' /var/log/script/test3.txt > /var/log/script/slot1.txt
#sed -n -e 's/^.*slot":2,"timeout"://p' /var/log/script/test3.txt > /var/log/script/test4.txt
sed -n -e 's/^.*slot":0,"timeout"://p' /Var/log/script/test3.txt > /var/log/script/test4.txt
sed 's/},{"repeaterid.*//' /var/log/script/test4.txt > /var/log/script/slot2.txt
}
check_status_slot1(){
if [ -s "/var/log/script/slot1.txt" ]
then
echo "Dynamic is linked slot 1."
echo -n "" > /var/log/script/static-slot1.txt
else
echo
#echo "Dynamic is not linked slot 1."./check
fi
if [ -s "/var/log/script/static-slot1.txt" ]
then
echo "Static is linked slot 1."
echo
else
#echo "Static is not linked slot 1."
echo
fi
}
check_status_slot2(){
if [ -s "/var/log/script/slot2.txt" ]
then
echo "Dynamic is linked slot 2."
echo -n "" > /var/log/script/static-slot2.txt
else
echo
#echo "Dynamic is not linked slot 2."
fi
if [ -s "/var/log/script/static-slot2.txt" ]
then
echo "Static is linked slot 2."
echo
else
#echo "Static is not linked slot 2."
echo
fi
}
#check if static-slot1.txt and slot.txt are blank
check_if_nothing_linked_slot1(){
if [ -s "/var/log/script/static-slot1.txt" ]
then
echo "Linked to Static $defaultslot1 Slot 1"
elif [ -s "/var/log/script/slot1.txt" ]
then
echo "Dynamic is Linked slot 1"
else
echo "DMRGateway slot 1 is Unlinked"
echo "Linking slot 1 $defaultslot1" && sleep $minrelinktimerslot1; echo "DynTG1,$defaultslot1" > /dev/udp/127.0.0.1/3769
echo -n "Linked to $defaultslot1" > /var/log/script/static-slot1.txt
fi
}
#check if static-slot2.txt and slot.txt are blank
check_if_nothing_linked_slot2(){
if [ -s "/var/log/script/static-slot2.txt" ]
then
echo "Linked to Static $defaultslot2 Slot 2"
elif [ -s "/var/log/script/slot2.txt" ]
then
echo "Dynamic is Linked slot 2"
else
echo "DMRGateway slot 2 is Unlinked"
echo "Linking slot 2 $defaultslot2" && sleep $minrelinktimerslot2; echo "DynTG2,$defaultslot2" > /dev/udp/127.0.0.1/3769
echo -n "Linked to $defaultslot2" > /var/log/script/static-slot2.txt
fi
}
check_BM_API
echo
#check_status_slot1
check_status_slot2
#check_if_nothing_linked_slot1
check_if_nothing_linked_slot2
echo

View File

@@ -0,0 +1,135 @@
#!/bin/bash
source /opt/script/script.conf
#check BM API
check_BM_API(){
echo "Repeater $call $repeater"
date
curl "https://api.brandmeister.network/v1.0/repeater/?action=profile&q=$repeater" > /var/log/script/test1.txt
sed -n -e 's/^.*tarantool"}],//p' /var/log/script/test1.txt > /var/log/script/test2.txt
sed 's/}],"timedSubscriptions.*//' /var/log/script/test2.txt > /var/log/script/test3.txt
sed -n -e 's/^.*slot":1,"timeout"://p' /var/log/script/test3.txt > /var/log/script/slot1.txt
sed -n -e 's/^.*slot":2,"timeout"://p' /var/log/script/test3.txt > /var/log/script/test4.txt
#sed -n -e 's/^.*slot":0,"timeout"://p' /Var/log/script/test3.txt > /var/log/script/test4.txt
sed 's/},{"repeaterid.*//' /var/log/script/test4.txt > /var/log/script/slot2.txt
}
check_status_slot1(){
if [ -s "/var/log/script/slot1.txt" ]
then
echo "Dynamic is linked slot 1."
echo -n "" > /var/log/script/static-slot1.txt
else
echo
#echo "Dynamic is not linked slot 1."./check
fi
if [ -s "/var/log/script/static-slot1.txt" ]
then
echo "Static is linked slot 1."
echo
else
#echo "Static is not linked slot 1."
echo
fi
}
check_status_slot2(){
if [ -s "/var/log/script/slot2.txt" ]
then
echo "Dynamic is linked slot 2."
echo -n "" > /var/log/script/static-slot2.txt
else
echo
#echo "Dynamic is not linked slot 2."
fi
if [ -s "/var/log/script/static-slot2.txt" ]
then
echo "Static is linked slot 2."
echo
else
#echo "Static is not linked slot 2."
echo
fi
}
#check if static-slot1.txt and slot.txt are blank
check_if_nothing_linked_slot1(){
if [ -s "/var/log/script/static-slot1.txt" ]
then
echo "Linked to Static $defaultslot1 Slot 1"
elif [ -s "/var/log/script/slot1.txt" ]
then
echo "Dynamic is Linked slot 1"
else
echo "DMRGateway slot 1 is Unlinked"
echo "Linking slot 1 $defaultslot1" && sleep $minrelinktimerslot1; echo "DynTG1,$defaultslot1" > /dev/udp/127.0.0.1/3769
echo -n "Linked to $defaultslot1" > /var/log/script/static-slot1.txt
fi
}
#check if static-slot2.txt and slot.txt are blank
check_if_nothing_linked_slot2(){
if [ -s "/var/log/script/static-slot2.txt" ]
then
echo "Linked to Static $defaultslot2 Slot 2"
elif [ -s "/var/log/script/slot2.txt" ]
then
echo "Dynamic is Linked slot 2"
else
echo "DMRGateway slot 2 is Unlinked"
echo "Linking slot 2 $defaultslot2" && sleep $minrelinktimerslot2; echo "DynTG2,$defaultslot2" > /dev/udp/127.0.0.1/3769
echo -n "Linked to $defaultslot2" > /var/log/script/static-slot2.txt
fi
}
check_BM_API
echo
check_status_slot1
check_status_slot2
check_if_nothing_linked_slot1
check_if_nothing_linked_slot2
echo
echo
sleep 5
#/opt/script/./check.sh >> /var/log/script/checkBMAPI.log

View File

@@ -0,0 +1,8 @@
#!/bin/bash
# This is just a nice way to start the script
while /bin/true; do
/opt/script/./relink-repeater-hotspot.sh >> /var/log/script/checkBMAPI.log 2>&1
done &

View File

@@ -0,0 +1,8 @@
#!/bin/bash
# This is just a nice way to start the script
while /bin/true; do
/opt/script/./relink-repeater.sh >> /var/log/script/checkBMAPI.log 2>&1
done &

View File

@@ -0,0 +1,7 @@
#!/usr/bin/bash
repeater=235192
call=GB3IN
defaultslot1=23590
defaultslot2=91
minrelinktimerslot1=30
minrelinktimerslot2=30

View File

@@ -0,0 +1,12 @@
#!/bin/bash
mkdir /var/log/script
sleep 1
cp /opt/script/var-log-script.tgz /var/log/script/
sleep 1
cd /var/log/script
sleep 1
tar -xvf var-log-script.tgz

Binary file not shown.

View File

View File

View File

@@ -0,0 +1 @@
Linked to 23590

View File

@@ -0,0 +1 @@
Linked to 91

View File

View File

@@ -0,0 +1 @@
"dynamicSubscriptions":[],"timedSubscriptions":[],"clusters":[]}

View File

@@ -0,0 +1 @@
"dynamicSubscriptions":[],"timedSubscriptions":[],"clusters":[]}

View File

Binary file not shown.