From bd0de76f865e8b867dffe8f39b1c94ccb1333f35 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Wed, 22 Apr 2020 17:47:33 +0100 Subject: [PATCH] Updated script files. --- scripts/lib/systemd/system/relinker.service | 12 ++ .../lib/systemd/system/relinkerhot.service | 12 ++ scripts/opt/script/README | 109 +++++++++++++++--- scripts/opt/script/install-relinker.sh | 20 ++-- scripts/opt/script/relink-hotspot.sh | 15 ++- scripts/opt/script/relink-repeater.sh | 13 +-- scripts/opt/script/script.conf | 21 +++- scripts/var/log/script/test1.txt | 1 + 8 files changed, 166 insertions(+), 37 deletions(-) create mode 100644 scripts/lib/systemd/system/relinker.service create mode 100644 scripts/lib/systemd/system/relinkerhot.service diff --git a/scripts/lib/systemd/system/relinker.service b/scripts/lib/systemd/system/relinker.service new file mode 100644 index 0000000..bd91ae7 --- /dev/null +++ b/scripts/lib/systemd/system/relinker.service @@ -0,0 +1,12 @@ +[Unit] +Description=relinker service +After=multi-user.target + +[Service] +Type=idle + +ExecStart=/bin/bash /opt/script/relink-repeater.sh >> /var/log/script/checkBMAPI.log 2>&1 + + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/scripts/lib/systemd/system/relinkerhot.service b/scripts/lib/systemd/system/relinkerhot.service new file mode 100644 index 0000000..4848676 --- /dev/null +++ b/scripts/lib/systemd/system/relinkerhot.service @@ -0,0 +1,12 @@ +[Unit] +Description=relinkerhot service +After=multi-user.target + +[Service] +Type=idle + +ExecStart=/bin/bash /opt/script/relink-hotspot.sh >> /var/log/script/checkBMAPI.log 2>&1 + + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/scripts/opt/script/README b/scripts/opt/script/README index c582fe9..e4865b7 100644 --- a/scripts/opt/script/README +++ b/scripts/opt/script/README @@ -1,8 +1,14 @@ +DMR SUDO Reflector - TG +This is the first release version of the relinker scripts 3.1 + + + + 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 @@ -40,33 +46,62 @@ 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 +1. Copy the package DMRGateway-TGDynRewrite-relinker-3.1.tgz to the folder/boot and also the install-relinker.sh script supplied (you can do this with a card reader from windows if you like) + + +2. run /boot#./install-relinker which should create folders /opt/script/script and /var/log/script/various working files and logfile. it also sets up services in systemd + +ready to run the script required + + + +3. Edit the config file /opt/script/script.conf repeater=235??? ID call callsign your defaults for slot linking + +also min relink timer minrelinktimer in seconds this is the time before reconnection on a slot after someone finishes RF and either the slot is unlinked by the user + +or the dynamic times out i.e BM timer + +it waits a further minlinktimer seconds before relinking + +slowdown=10 This is higher for faster rasp pi 10 for pi 3B + or 1 for original Pi B + +checkslot1=check_status_slot1 +checkslot2=check_status_slot2 +slot1notlinked=check_if_nothing_linked_slot1 +slot2notlinked=check_if_nothing_linked_slot2 + +Above checks all slots default for repeater with prefered config SUDO Reflectors both slots ............if in doubt include all these lines !!!! + + +checkslot1= +checkslot2=check_status_slot2 +slot1notlinked= +slot2notlinked=check_if_nothing_linked_slot2 + +Above checks only slot 2 typically a hotspot........ or a repeater that only has SUDO Reflectors enabled in DMRGateway on one of the slots + + +............if in doubt include all these lines in first example!!!! +4. Don't forget to set these static via Brandmeister selfcare + -Add the following line to crontab on the rasp pi you dont need to do anything else just save crontab and exit + +5. 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 + +6. Pi-star additional step Also in same file etc/rc.local @@ -88,9 +123,57 @@ if [ ! -d /var/log/script ]; then fi +7. start one of the services with following command + + +choose either Repeater + +systemctl start relinker.service + + + +or Hotspot ? + +systemctl start relinkerhot.service + + +systemctl status relinker.service + +or + +systemctl status relinkerhot.service + + +will show if its running if it is running ? + + +you can tail the log file at the command prompt + + +tail -f /var/log/script/checkBMAPI.log + + +once it is confirmed running and working + + +enable the service you chose to enable automatically at boot example + +systemctl enable relinker.service + +for repeater + +or + +systemctl enable relinkerhot.service + +for hotspot + + reboot +once you have rebooted check all is auto starting + you can tail the log file at the command prompt diff --git a/scripts/opt/script/install-relinker.sh b/scripts/opt/script/install-relinker.sh index 25b23e2..0bb8850 100644 --- a/scripts/opt/script/install-relinker.sh +++ b/scripts/opt/script/install-relinker.sh @@ -1,11 +1,17 @@ #!/bin/bash -cp DMRG*.tgz / + + + cd / +rm -rf DMRGa* +cd /opt +rm -rf script +cd /var/log +rm -rf script -tar -xvf DMRG* - - - - - +cd /boot +cp DMRGateway*.tgz / +cd / +tar -xvf DMRGateway*.tgz +systemctl daemon-reload diff --git a/scripts/opt/script/relink-hotspot.sh b/scripts/opt/script/relink-hotspot.sh index a1c9fcd..4221849 100644 --- a/scripts/opt/script/relink-hotspot.sh +++ b/scripts/opt/script/relink-hotspot.sh @@ -24,7 +24,7 @@ check_BM_API(){ #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 -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 @@ -124,11 +124,14 @@ check_if_nothing_linked_slot2(){ check_BM_API echo -#check_status_slot1 -check_status_slot2 -#check_if_nothing_linked_slot1 -check_if_nothing_linked_slot2 -echo +$checkslot1 +$checkslot2 +$slot1notlinked +$slot2notlinked +echo +sleep $slowdown +/bin/bash /opt/script/relink-hotspot.sh >> /var/log/script/checkBMAPI.log 2>&1 + diff --git a/scripts/opt/script/relink-repeater.sh b/scripts/opt/script/relink-repeater.sh index 9e89601..d333513 100644 --- a/scripts/opt/script/relink-repeater.sh +++ b/scripts/opt/script/relink-repeater.sh @@ -124,12 +124,11 @@ check_if_nothing_linked_slot2(){ check_BM_API echo -check_status_slot1 -check_status_slot2 -check_if_nothing_linked_slot1 -check_if_nothing_linked_slot2 -echo +$checkslot1 +$checkslot2 +$slot1notlinked +$slot2notlinked echo -sleep 5 -#/opt/script/./check.sh >> /var/log/script/checkBMAPI.log +sleep $slowdown +/bin/bash /opt/script/relink-repeater.sh >> /var/log/script/checkBMAPI.log 2>&1 diff --git a/scripts/opt/script/script.conf b/scripts/opt/script/script.conf index 3e7d1c4..ab1bbf4 100644 --- a/scripts/opt/script/script.conf +++ b/scripts/opt/script/script.conf @@ -1,7 +1,20 @@ #!/usr/bin/bash -repeater=235192 -call=GB3IN -defaultslot1=23590 -defaultslot2=91 +repeater=234587501 +call=M0VUB +defaultslot1=0 +defaultslot2=2350 minrelinktimerslot1=30 minrelinktimerslot2=30 +slowdown=10 +checkslot1= +checkslot2=check_status_slot2 +slot1notlinked= +slot2notlinked=check_if_nothing_linked_slot2 + +#configuration above enabled to watch slot 2 only on a hotspot + +# add the lines as required you may only have 1 slot monitored on a repeater if thats + +# all using SUDO Reflectors Cant imagine why + + \ No newline at end of file diff --git a/scripts/var/log/script/test1.txt b/scripts/var/log/script/test1.txt index e69de29..4f60d09 100644 --- a/scripts/var/log/script/test1.txt +++ b/scripts/var/log/script/test1.txt @@ -0,0 +1 @@ +{"reflector":{"reflector":0,"interval":0,"active":4000},"blockedGroups":[],"staticSubscriptions":[{"talkgroup":91,"networkid":2341,"repeaterid":235192,"slot":2,"type":"tarantool"},{"talkgroup":23590,"networkid":2341,"repeaterid":235192,"slot":1,"type":"tarantool"}],"dynamicSubscriptions":[],"timedSubscriptions":[],"clusters":[]} \ No newline at end of file