From 652a30cecdefd64b7e6f53ac41b75e66a91e189d Mon Sep 17 00:00:00 2001 From: "Tony Corbett, G0WFV" Date: Sun, 2 Jul 2017 17:13:48 +0100 Subject: [PATCH 1/5] Add log monitoring shutdown script --- linux/tg_shutdown.sh | 124 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100755 linux/tg_shutdown.sh diff --git a/linux/tg_shutdown.sh b/linux/tg_shutdown.sh new file mode 100755 index 0000000..fd4f35f --- /dev/null +++ b/linux/tg_shutdown.sh @@ -0,0 +1,124 @@ +#! /bin/bash + +# tg_shutdown.sh - Automated shutdown and reboot on receipt of talkgroup +# Copyright (C) 2017 Tony Corbett, G0WFV and Stuart Scott, VK6LS +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USAp + +# exit status ... +# 1 script not run as root +# 2 ini file doesn't exist + +### CONFIG VARIABLES ### + +sysopCallsign=XX0XXX +iniFile=/path/to/MMDVM.ini +shutdownTG=999999 +rebootTG=888888 +allowShutdown=1 +allowReboot=1 + +### DON'T EDIT BELOW HERE ### + +# exit if we're not root ... +[[ $EUID -ne 0 ]] && exit 1 + +# exit if we can't find the ini file +[[ -f $iniFile ]] || exit 2 + +# process the inifile and convert to variables ... +# +# [Foo] +# Bar=Baz +# +# ... becomes the variable $FooBar with the value "Baz" +# (NOTE: spaces in section headers are replaced by underscores) +# +# a real life example ... +# +# [General] +# Callsign=G0WFV +# +# ... becomes the variable $GeneralCallsign with the value "G0WFV" + +foo=$( + cat $iniFile | while read line + do + if echo $line | grep '^#.*$' >/dev/null # comment line + then + # Ignore! + continue + elif echo $line | grep '^$' >/dev/null # blank line + then + # Ignore! + continue + elif echo $line | grep '^\[.*\]$' >/dev/null # [Section Header] + then + iniSection=$(echo $line | sed 's/^\[\(.*\)\]$/\1/' | sed 's/[ -]//g') + elif echo $line | grep '^.*=.*$' >/dev/null # Key=Value pair + then + iniKey=$(echo $line | sed 's/\(.*\)=.*$/\1/') + iniValue=$(echo $line | sed 's/.*=\(.*\)$/\1/') + echo $iniSection$iniKey=\"$iniValue\" # print the result in a specific format + else # hopefully we'll never get here, but you never know! + continue + fi + done +) +eval $foo + +# fix filepath if it doesn't end with a / +[[ "$(echo ${LogFilePath: -1})" != "/" ]] && LogFilePath="$LogFilePath/" + +currentDate=foo # dummy current date variable to kick off the 1st tail! +shuttingDown=0 + +while true # main outer loop (run this forever!) +do + checkDate=$(date -u +%Y-%m-%d) + if [ "$checkDate" != "$currentDate" ] + then + kill $tailPID 2>/dev/null + currentDate=$checkDate + logFile=$LogFilePath$LogFileRoot-$currentDate.log + + tail -n 0 -F $logFile | while read line # inner loop to tail the logfile + do + # only react to sysop callsign ... + foo=$(echo $line | grep "received RF voice header from $sysopCallsign to TG") + + if [ $? = 0 ] + then + TG=$(echo $line | sed "s/.*TG\(.*\)$/\1/g") + + if [ $TG -eq $shutdownTG ] && [ $shuttingDown -eq 0 ] && [ $allowShutdown -eq 1 ] + then + # shutdown in 1 minute ... + shutdown -h +1 >/dev/null 2>&1 && shuttingDown=1 + elif [ $TG -eq $rebootTG ] && [ $shuttingDown -eq 0 ] && [ $allowReboot -eq 1 ] + then + # reboot in 1 minute ... + shutdown -r +1 >/dev/null 2>&1 && shuttingDown=1 + elif [ $shuttingDown -eq 1 ] + then + # cancel shutdown or reboot if sysop tx any TG in 1 min grace period ... + shutdown -c && shuttingDown=0 + fi + fi + done & 2>/dev/null # inner loop is run in background so we can periodically check if the date's changed + tailPID=$(($! - 1)) # save the PID of the inner loop so we can kill it when the date rolls over + fi + sleep 1 # check every second for date rollover (reduces cpu load) +done From 29a38986268d5ab17bc268769e3f90ae5355395f Mon Sep 17 00:00:00 2001 From: "Tony Corbett, G0WFV" Date: Sun, 2 Jul 2017 17:14:31 +0100 Subject: [PATCH 2/5] Move DMR ID update scripts to linux sub-directory --- DMRIDUpdate.sh => linux/DMRIDUpdate.sh | 0 DMRIDUpdateBM.sh => linux/DMRIDUpdateBM.sh | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename DMRIDUpdate.sh => linux/DMRIDUpdate.sh (100%) rename DMRIDUpdateBM.sh => linux/DMRIDUpdateBM.sh (100%) diff --git a/DMRIDUpdate.sh b/linux/DMRIDUpdate.sh similarity index 100% rename from DMRIDUpdate.sh rename to linux/DMRIDUpdate.sh diff --git a/DMRIDUpdateBM.sh b/linux/DMRIDUpdateBM.sh similarity index 100% rename from DMRIDUpdateBM.sh rename to linux/DMRIDUpdateBM.sh From 08d5a3fe569572a1526c03d712cf3fc8d56ffc13 Mon Sep 17 00:00:00 2001 From: "Tony Corbett, G0WFV" Date: Sun, 2 Jul 2017 17:32:14 +0100 Subject: [PATCH 3/5] Update README.md in linux sub-directory --- linux/README.md | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/linux/README.md b/linux/README.md index 7ebbc3c..f221bb6 100644 --- a/linux/README.md +++ b/linux/README.md @@ -1,5 +1,20 @@ -Linux Daemon Startup Scripts -============================ +# Linux Scripts + +This directory (and its sub-directories) contain various third-party Linux shell scripts that have been written to provide certain system administration functions. + +These are: + +### DMRIDUpdate.sh (and DMRIDUpdateBM.sh) + +Updates the DMRIds.dat file periodically from a cron job. +The only difference between the two scripts is the source of the data. + +### tg_shutdown.sh + +Automated shutdown on receipt of a specific talkgroup. +The script relies on at least a file loglevel of 2. + +# Daemon Startup Scripts In the subfolders here you will find start scripts for running MMDVMHost as a daemon on Linux systems using either systemd or init for their boot. @@ -8,7 +23,3 @@ In both cases the scripts are fully functional providing the usual start / stop These have been writting specifically for Raspbian Wheezy (init) and Rasbian Jessie (systemd) although there is no reason that they shouldnt work on many other distributions. - - -Andy Taylor -Have fun, 73 de MW0MWZ. From 87635060b5f851faff92a364eca638796dc37c18 Mon Sep 17 00:00:00 2001 From: "Tony Corbett, G0WFV" Date: Sun, 2 Jul 2017 17:43:38 +0100 Subject: [PATCH 4/5] Update README.md in main directory to include LCDproc can't believe I missed this one out when I wrote it! --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 0fde4b0..a490556 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ It builds on 32-bit and 64-bit Linux as well as on Windows using VS2015 on x86 a - Nextion TFTs (sizes 2.4", 2.8", 3.2" and 3.5") - TFT display sold by Hobbytronics in UK - OLED 128x64 (SSD1306) +- LCDproc The Nextion displays can connect to the UART on the Raspberry Pi, or via a USB to TTL serial converter like the FT-232RL. It may also be connected to the UART output of the MMDVM modem (Arduino Due, STM32, Teensy), or to the UART output on the UMP. @@ -20,4 +21,6 @@ The Hobbytronics TFT Display, which is a Pi-Hat, connects to the UART on the Ras The OLED display needs a extra library see OLED.md +The LCDproc support enables the use of a multitude of other LCD screens. See the [supported devices](http://lcdproc.omnipotent.net/hardware.php3) page on the LCDproc website for more info. + This software is licenced under the GPL v2 and is intended for amateur and educational use only. Use of this software for commercial purposes is strictly forbidden. From b362fe41b8d48125d8d401f7c0a3f627ad5a8826 Mon Sep 17 00:00:00 2001 From: "Tony Corbett, G0WFV" Date: Sun, 2 Jul 2017 17:47:25 +0100 Subject: [PATCH 5/5] Add XLX and DMRGateway as supported DMR networks --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a490556..904a5ae 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ These are the source files for building the MMDVMHost, the program that interfaces to the MMDVM or DVMega on the one side, and a suitable network on the other. It supports D-Star, DMR, P25 Phase 1, and System Fusion. -On the D-Star side the MMDVMHost interfaces with the ircDDB Gateway, on DMR it can connect to BrandMeister, DMR+, or HB Link, on System Fusion it connects to the YSF Gateway. On P25 it connects to the P25 Gateway. +On the D-Star side the MMDVMHost interfaces with the ircDDB Gateway, on DMR it can connect to BrandMeister, DMR+, HB Link, XLX or [DMRGateway](https://github.com/g4klx/DMRGateway) (to connect to multiple DMR networks at once) on System Fusion it connects to the YSF Gateway. On P25 it connects to the P25 Gateway. It builds on 32-bit and 64-bit Linux as well as on Windows using VS2015 on x86 and x64. It can optionally control various Displays. Currently these are: