Merge pull request #316 from g0wfv/develop

Various directory housekeeping and a new sysadmin shell script
This commit is contained in:
Jonathan Naylor 2017-07-02 18:07:20 +01:00 committed by GitHub
commit d399ba9ebb
5 changed files with 145 additions and 7 deletions

View file

@ -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:
@ -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.

View file

@ -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.

124
linux/tg_shutdown.sh Executable file
View file

@ -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