diff options
| author | Jason D. McCormick <jason@mfamily.org> | 2020-04-07 14:22:14 -0400 |
|---|---|---|
| committer | Jason D. McCormick <jason@mfamily.org> | 2020-04-07 14:22:14 -0400 |
| commit | 3d62afb6bc0f708c5506430267bc217c24c22eda (patch) | |
| tree | fffeb154499b51f6d1d9e6373977ce0e24cf9777 | |
| parent | 514767dc3e5f8ee03d8f3d0e62daca512bfe7f0e (diff) | |
move pistar files
| -rw-r--r-- | pistar/README.md | 41 | ||||
| -rwxr-xr-x | pistar/bmcli | 15 | ||||
| -rwxr-xr-x | pistar/bmcli-wrapper | 36 | ||||
| -rwxr-xr-x | pistar/pistar-activity-report | 52 | ||||
| -rwxr-xr-x | pistar/pistar-send-activity-report | 8 |
5 files changed, 152 insertions, 0 deletions
diff --git a/pistar/README.md b/pistar/README.md new file mode 100644 index 0000000..efed545 --- /dev/null +++ b/pistar/README.md @@ -0,0 +1,41 @@ +# pistar-scripts +A collection of scripts to manage various aspects of the Pi-Star system +from the command line. + +IMPORTANT: These scripts are NOT supported by Pi-Star. Do not request support +for them on the Pi-Star forums or the Pi-Star Facebook group. + +# System Requirements +- Pi-Star 3.4.n + +# Installation +Copy the contents of the repository somewhere useful. All scripts are +hardcoded to be called from the same directory where they reside. +This will be changed in the future to make them more portable. + +# Scripts +The following scripts are in this package. + +## bmcli +bmcli (and its associated bmcli-wapper) are command-line interfaces +to the DMR Brandmeister API. Uses all configuration from Pi-Star and +requires the Brandmeister API to configured in the web interface +before using. + +``` +usage: + bmcli add TALKGROUP TIMESLOT + bmcli del TALKGROUP TIMESLOT + bmcli dropdyn TIMESLOT + +``` + +This script has only rudimentary error checking so make sure you +call it correctly or you could have some interesting BM configurations +pointing to your repeater/hotspot. + +Brandmeister currently does not properly support dropping dynamic talkgroups +from simplex talkgroups (i.e. "auto statics" instead of dynamic TGs) so +this script doesn't work on the combination of simplex hotspots + +dynamic groups. +to drop dynamic diff --git a/pistar/bmcli b/pistar/bmcli new file mode 100755 index 0000000..34d429e --- /dev/null +++ b/pistar/bmcli @@ -0,0 +1,15 @@ +#!/bin/bash + +if [ ! -f /usr/local/bin/bmcli-wrapper ]; then + echo "missing /usr/local/bin/bmcli-wrapper" + exit 1 +fi + +if [ $# -lt 1 ]; then + ./bmcli-wrapper + exit 1 +else + ./bmcli-wrapper $* 2>&1 | \ + grep '<tr><td>' | \ + sed 's/<...?>//g' +fi diff --git a/pistar/bmcli-wrapper b/pistar/bmcli-wrapper new file mode 100755 index 0000000..251114c --- /dev/null +++ b/pistar/bmcli-wrapper @@ -0,0 +1,36 @@ +#!/usr/bin/php +<?php + +$_SERVER['DOCUMENT_ROOT'] = "/var/www/dashboard"; + +switch($argv[1]) { + case "add": + $_POST["TGmgr"] = "ADD"; + $_POST["tgNr"] = $argv[2]; + $_POST["TS"] = $argv[3]; + $_POST["tgSubmit"] = 1; + break; + + case "del": + $_POST["TGmgr"] = "DEL"; + $_POST["tgNr"] = $argv[2]; + $_POST["TS"] = $argv[3]; + $_POST["tgSubmit"] = 1; + break; + + case "dropdyn": + $_POST["dropDyn"] = 1; + $_POST["TS"] = $argv[2]; + break; + + default: + echo "usage:\n"; + echo " bmcli add TALKGROUP TIMESLOT\n"; + echo " bmcli del TALKGROUP TIMESLOT\n"; + echo " bmcli dropdyn TIMESLOT\n"; + exit; +} + +include_once $_SERVER['DOCUMENT_ROOT'] . "/mmdvmhost/bm_manager.php"; + +?> diff --git a/pistar/pistar-activity-report b/pistar/pistar-activity-report new file mode 100755 index 0000000..572bf4c --- /dev/null +++ b/pistar/pistar-activity-report @@ -0,0 +1,52 @@ +#!/usr/bin/perl + +use strict; +use Getopt::Std; +use POSIX qw(strftime); +use Sys::Hostname; + +our($opt_f, $opt_s, $opt_r); +my $nowiso = strftime "%Y-%m-%d", gmtime(time - 86400); + +getopts('f:r:s:'); +if( !defined($opt_f)){ + $opt_f = sprintf("/var/log/pi-star/MMDVM-%s.log", $nowiso); +} +if( ! -f $opt_f ){ + print STDERR "File $opt_f not found\n"; + exit 1; +} + +if( !defined($opt_s) || !defined($opt_r) ){ + print STDERR "Usage: pistar-activity-report [-f FILE] -s SENDERADDR -r RECEIVEADDR[,RECEIVEADDR]\n"; + exit 1; +} + +my $dstar=0; +my $dmr=0; + +open(IN, "<" . $opt_f) or die($!); +while(<IN>){ + chomp $_; + + if( $_ =~ m/D\-Star,\s+received\s+\w+\send of transmission/ ){ + ( my $s = $_ ) =~ s/^.*\s([0-9]+\.[0-9])\sseconds.*$/$1/; + $dstar += $s; + } elsif( $_ =~ m/DMR.*received network end of voice/) { + ( my $s = $_ ) =~ s/^.*\s([0-9]+\.[0-9])\sseconds.*$/$1/; + $dmr += $s; + } +} +close(IN); + +printf("From: %s\n", $opt_s); +printf("To: %s\n", $opt_r); +printf("Subject: %s - Daily Tx Report for %s (UTC)\n", hostname, $nowiso); +print "\n"; +printf("D-STAR TX Seconds: %i\n", $dstar); +printf("DMR TX Seconds: %i\n", $dmr); +print "\n"; +print "DSTAR,DMR\n"; +printf("%i,%i\n", $dstar, $dmr); + +exit 0; diff --git a/pistar/pistar-send-activity-report b/pistar/pistar-send-activity-report new file mode 100755 index 0000000..034c785 --- /dev/null +++ b/pistar/pistar-send-activity-report @@ -0,0 +1,8 @@ +#!/bin/bash + +if [ -z $1 ] || [ -z $2 ]; then + echo "Usage: $0 SEND_ADDR REC_ADDR[,REC_ADDR...]" + exit 1 +fi + +/usr/local/sbin/pistar-activity-report -s "$1" -r "$2" | sendmail -oi -oem "$2" |
