diff --git a/.travis.yml b/.travis.yml index 2a7b632..d1103be 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,7 @@ sudo: required branches: only: - master + - beta - develop before_script: @@ -12,15 +13,15 @@ before_script: - sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu trusty main" - sudo apt-get update -qq - sudo apt-get install -qq wget python2.7 -# - wget https://raw.githubusercontent.com/thejockel/BOSWatch/develop/install.sh - - wget https://raw.githubusercontent.com/Schrolli91/BOSWatch/master/install.sh + + - wget https://raw.githubusercontent.com/Schrolli91/BOSWatch/${TRAVIS_BRANCH}/install.sh - chmod +x install.sh - cat /etc/os-release - echo ${TRAVIS_BRANCH} - - sudo ./install.sh -b ${TRAVIS_BRANCH} -r no + - sudo ./install.sh -b ${TRAVIS_BRANCH} env: - - module=bash + - module=base - module=mysql - module=httpRequest diff --git a/Konzept.md b/Konzept.md new file mode 100644 index 0000000..6e3a5b1 --- /dev/null +++ b/Konzept.md @@ -0,0 +1,118 @@ +# BOSWatch 3.0 +============ + + +Verpacken der Funktionalitäten in Klassen um OOP-Grundsätze zu erreichen. + + + +## Dekodierung und Auswertung trennen. + +### Client: + - reine Dekodierung mittels rtl-fm und multimon + - Keine Filter usw. nur die Dekoder, Daten verpacken, verschicken + - per TCP Socket an den Server + + ### Server: + - Empfängt die TCP Socket Pakete der einzelnen Clients + - Durch doubleFiltering fallen doppelt eingehende Alarme der Clienten sowieso raus + - Danach Filterung usw. dann call an die plugins + + + +## Konfiguration: +- Alle Einstellungen in INI File +- Einziges Argument beim Start des Clienten ist der Name der INI (-v -q -t sollen auch bleiben) +- So werden mehrere Sticks auf einem Rechner einfach möglich ohne BOSWatch Ordner kopieren zu müssen + +### Client: + +``` +[Server] +IP = 127.0.0.1 +PORT = 23 + +[Client] +Name = BOSWatch Client 1 +LogDir = log/ + +[Stick] +device = 0 +Frequency = 85...M +PPMError = 0 +Squelch = 0 +gain = 100 + +[Decoder] +FMS = 0 +ZVEI = 0 +POC512 = 0 +POC1200 = 1 +POC2400 = 0 +``` + +### Server: +``` +[Server] +PORT = 23 + +[Filter] +... + +[Plugins] +MySQL = 1 +template = 0 +... +``` + +### Plugin: +- Konfigurations Datei für Plugin mit in den Plugin Ordner +- Plugin läd bei Bedarf seine Config selbst, die geht BOSWatch ja nichts an +- Aktuell wird eine ewig lange Config geladen, obwohl 90% der Plugins nicht genutzt werden + + + +## Filterung +Ein Vernünftiges Filterkonzept sollte aufgestellt werden, welches bei POC, FMS und ZVEI gleichermaßen funktioniert +und daher nicht 3 mal implementiert erden muss. + + + +## Versions Überprüfung + +über die LIB sched.py - https://docs.python.org/3/library/sched.html - können Zeitgesteuerte Events gestartet werden. +Dies kann zur Überprüfung einer neuen Software version verwendet werden. +information des Nutzers muss noch überlegt werden - evtl als "Alarm" absetzen über normalen Plugin weg. + + + +## Code Dokumentation +Dokumentiert werden sollten alle Funktion und Klassen in Doxygen gerechter Notation. +Genaue Erklärung und Bennenung der Tags in der Doxygen Hilfe +``` +class Hello: + ## @brief Short description. + # Longer description. + # + # @param self + # @param name Another Parameter + # @return value Returns a Value + + def __init__(self, name): + ## @brief Constructor + # Longer description optinal. + # + # @param self + # @param name Another Parameter + dosomething(12) + + def dosomething(self, x): + ## @brief Do something + # Longer description for do something. + # + # @param self + # @param x Another Parameter + # @return value Returns a 0 + dosomethingelse + return 0 +``` diff --git a/README.md b/README.md index 6c9a3c3..c08f805 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,13 @@ -## Bitte den beta-Branch auf Fehler testen - Neues Release steht bevor -**Der beta-Branch kann über den normalen Installer mittles dem Flag `-b beta` installiert werden** - -|branch|quality|CI-Build| +|Branch|Code Qualität|CI-Build| |---|---|---| -|master-branch|[![Codacy Badge](https://img.shields.io/codacy/grade/d512976554354a199555bd34ed179bb1/master.svg)](https://www.codacy.com/app/Schrolli91/BOSWatch/dashboard?bid=3763821)|[![Build Status](https://travis-ci.org/Schrolli91/BOSWatch.svg?branch=master)](https://travis-ci.org/Schrolli91/BOSWatch)| -|develop-branch|[![Codacy Badge](https://img.shields.io/codacy/grade/d512976554354a199555bd34ed179bb1/develop.svg)](https://www.codacy.com/app/Schrolli91/BOSWatch/dashboard?bid=3763820)|[![Build Status](https://travis-ci.org/Schrolli91/BOSWatch.svg?branch=develop)](https://travis-ci.org/Schrolli91/BOSWatch)| +|master|[![Codacy Badge](https://img.shields.io/codacy/grade/d512976554354a199555bd34ed179bb1/master.svg)](https://www.codacy.com/app/Schrolli91/BOSWatch/dashboard?bid=3763821)|[![Build Status](https://travis-ci.org/Schrolli91/BOSWatch.svg?branch=master)](https://travis-ci.org/Schrolli91/BOSWatch)| +|beta|[![Codacy Badge](https://img.shields.io/codacy/grade/d512976554354a199555bd34ed179bb1/beta.svg)](https://www.codacy.com/app/Schrolli91/BOSWatch/dashboard?bid=4213030)|[![Build Status](https://travis-ci.org/Schrolli91/BOSWatch.svg?branch=beta)](https://travis-ci.org/Schrolli91/BOSWatch)| +|develop|[![Codacy Badge](https://img.shields.io/codacy/grade/d512976554354a199555bd34ed179bb1/develop.svg)](https://www.codacy.com/app/Schrolli91/BOSWatch/dashboard?bid=3763820)|[![Build Status](https://travis-ci.org/Schrolli91/BOSWatch.svg?branch=develop)](https://travis-ci.org/Schrolli91/BOSWatch)| + **Unterstützung gesucht** -Zur Weiterentwicklung des Programms benötigen wir Deine Mithilfe - bitte melde dich per Issue, wenn du Anwender in einem verschlüsselten POCSAG-Netz und im (legalen) Besitz des dazugehörigen Schlüssels bist. +Zur Weiterentwicklung des Programms benötigen wir Deine Mithilfe - bitte melde dich per Issue, wenn du Anwender in einem verschlüsselten POCSAG-Netz und im (legalen) Besitz des dazugehörigen Schlüssels bist. In der Zukunft wollen wir die Möglichkeit schaffen, codierte Nachrichten zu entschlüsseln (und nur dann, wenn der Schlüssel bekannt ist!), dafür brauchen wir Dich als Tester! **Readme ist veraltet** - bitte im [Wiki](https://github.com/Schrolli91/BOSWatch/wiki) nachschauen! @@ -133,19 +132,11 @@ optional arguments: ### Installation -You can easy install BOSWatch with the install.sh Script. -- Download the install.sh in any folder you want. -- Make it executeable `sudo chmod +x install.sh` -- And use the script `sudo sh install.sh` +Please follow the instructions written down in the wiki: -Now the script downloads and compile all needed data. -At the end you can find BOSWatch in `~/boswatch/` -Rename `config.template.ini` to `config.ini` and configure -In case of an error during the installation, check the logfile in `~/boswatch/install/setup_log.txt` +https://github.com/Schrolli91/BOSWatch/wiki -Caution, script don't install a webserver with PHP and MySQL. -So you have to make up manually if you want to use MySQL support. -Database Structure `boswatch.sql` in the MySQL Plugin Folder +You just need to download a single file since the installer manages the whole process except the installation of a webserver and a database. If you want to use BOSWatch as a daemon, you have to set your configuration in `service/boswatch.sh` and copy it to `/etc/init.d`. diff --git a/boswatch.py b/boswatch.py index 071028e..e8b7b3a 100755 --- a/boswatch.py +++ b/boswatch.py @@ -26,11 +26,16 @@ import subprocess # for starting rtl_fm and multimon-ng from includes import globalVars # Global variables from includes import MyTimedRotatingFileHandler # extension of TimedRotatingFileHandler -from includes import signalHandler # TERM-Handler for use script as a daemon from includes import checkSubprocesses # check startup of the subprocesses from includes.helper import configHandler from includes.helper import freqConverter +# +# Check for exisiting config/config.ini-file +# +if not os.path.exists(os.path.dirname(os.path.abspath(__file__))+"/config/config.ini"): + print "ERROR: No config.ini found" + exit(1) # # ArgParser @@ -42,15 +47,15 @@ try: description="BOSWatch is a Python Script to recive and decode german BOS information with rtl_fm and multimon-NG", epilog="More options you can find in the extern config.ini file in the folder /config") # parser.add_argument("-c", "--channel", help="BOS Channel you want to listen") - parser.add_argument("-f", "--freq", help="Frequency you want to listen", required=True) - parser.add_argument("-d", "--device", help="Device you want to use (Check with rtl_test)", required=True) - parser.add_argument("-e", "--error", help="Frequency-Error of your device in PPM", type=int, default=0) + parser.add_argument("-f", "--freq", help="Frequency you want to listen to", required=True) + parser.add_argument("-d", "--device", help="Device you want to use (check with rtl_test)", type=int, default=0) + parser.add_argument("-e", "--error", help="Frequency-error of your device in PPM", default=0) parser.add_argument("-a", "--demod", help="Demodulation functions", choices=['FMS', 'ZVEI', 'POC512', 'POC1200', 'POC2400'], required=True, nargs="+") parser.add_argument("-s", "--squelch", help="Level of squelch", type=int, default=0) parser.add_argument("-g", "--gain", help="Level of gain", type=int, default=100) parser.add_argument("-u", "--usevarlog", help="Use '/var/log/boswatch' for logfiles instead of subdir 'log' in BOSWatch directory", action="store_true") - parser.add_argument("-v", "--verbose", help="Shows more information", action="store_true") - parser.add_argument("-q", "--quiet", help="Shows no information. Only logfiles", action="store_true") + parser.add_argument("-v", "--verbose", help="Show more information", action="store_true") + parser.add_argument("-q", "--quiet", help="Show no information. Only logfiles", action="store_true") # We need this argument for testing (skip instantiate of rtl-fm and multimon-ng): parser.add_argument("-t", "--test", help=argparse.SUPPRESS, action="store_true") args = parser.parse_args() @@ -173,7 +178,7 @@ try: demodulation += "-a FMSFSK " logging.debug(" - Demod: FMS") if "ZVEI" in args.demod: - demodulation += "-a ZVEI2 " + demodulation += "-a ZVEI1 " logging.debug(" - Demod: ZVEI") if "POC512" in args.demod: demodulation += "-a POCSAG512 " @@ -372,13 +377,13 @@ try: rawMmOut.close() else: logging.debug("start testing") - testFile = open(globalVars.script_path+"/testdata/testdata.txt","r") + testFile = open(globalVars.script_path+"/citest/testdata.txt","r") for testData in testFile: if (len(testData.rstrip(' \t\n\r')) > 1) and ("#" not in testData[0]): logging.info("Testdata: %s", testData.rstrip(' \t\n\r')) from includes import decoder decoder.decode(freqConverter.freqToHz(args.freq), testData) - time.sleep(1) + #time.sleep(1) logging.debug("test finished") except KeyboardInterrupt: diff --git a/citest/test.sh b/citest/test.sh index 2e3d21e..616544d 100644 --- a/citest/test.sh +++ b/citest/test.sh @@ -1,5 +1,6 @@ #!/bin/bash -bospath=/opt/boswatch/ +bospath=/opt/boswatch + echo $module # ---------------------------------------------------------------------------------------------------------------------------------- # base Tests diff --git a/testdata/testdata.txt b/citest/testdata.txt similarity index 98% rename from testdata/testdata.txt rename to citest/testdata.txt index 58e5a5e..e4ac22e 100644 --- a/testdata/testdata.txt +++ b/citest/testdata.txt @@ -106,15 +106,15 @@ FMS: 43f314170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Stat # #with csv description -ZVEI2: 12345 +ZVEI1: 12345 #without csv description -ZVEI2: 56789 +ZVEI1: 56789 #duplicate -ZVEI2: 56789 +ZVEI1: 56789 #with repeat Tone -ZVEI2: 1F2F3 +ZVEI1: 1F2F3 #in case of invalid id -ZVEI2: 135 +ZVEI1: 135 #in case of a double-tone for siren n-'D's are sended -ZVEI2: DDD -ZVEI2: DDDDD +ZVEI1: DDD +ZVEI1: DDDDD diff --git a/config/config.template.ini b/config/config.template.ini index 05c4c1f..be5484b 100644 --- a/config/config.template.ini +++ b/config/config.template.ini @@ -1,457 +1,463 @@ -######################## -# BOSWatch Config File # -######################## - -[BOSWatch] -# set loglevel for logfile -# 10 = debug -# 20 = info -# 30 = warning -# 40 = error -# 50 = critical -loglevel = 10 - -# BOSWatch use a rotating logfile -# Rotating is at midnight -# You can set the backupCount here -# backupCount = 7 (keeps logfiles for a week) -backupCount = 7 - -# if you want to start BOSWatch as a daemon with rc2.d, -# you have to set the path to rtl_fm and multimon-ng ! -# the path have to end with an / -#rtl_path = /usr/local/bin/ -#multimon_path = /usr/local/bin/ - -# if you are using many Plugins or Plugins with a long execution time -# you could execute them in an asynchronous manner -# It must be pointed out that enabling (0|1) this consume time, -# so don't use it for one rapid Plugin -processAlarmAsync = 0 - -# Using RegEx-Filter (0 - off | 1 - on) -# Filter-configuration in section [Filters] -useRegExFilter = 0 - -# for double check save the last n IDs -# it is used in combination with double_ignore_time -# 1 is required if you want to use the double alarm filter -doubleFilter_ignore_entries = 10 - -# time to ignore same alarm (only ID is checked) (sek) -doubleFilter_ignore_time = 5 - -# ignore msg is only usefull for POCSAG (0 - off | 1 - on) -# 0: double check ignores the msg-text (only check ID + function) -# 1: if you want to differentiate between with/ without msg -# f.e. if they use quick-alarm (without text, then same ric with msg) -# you will get more then one alarm anyway if the msg is different (receiving-problems) -doubleFilter_check_msg = 0 - -# writes the multimon-ng raw data stream into a text file named mm_raw.txt -writeMultimonRaw = 1 - -[NMAHandler] -# you could use an logging handler for sending logging records to NotifyMyAndroid -# enableHandler (0|1) will enable the NMA handler -enableHandler = 0 - -# loglevel for NMAHandler (see BOSWatch loglevel description) -loglevel = 50 - -# logging record will send to APIKey -APIKey = - -# You could change the name of the application (default: BOSWatch) -# (f.e. if you use more than one instance of BOSWatch) -appName = BOSWatch - - -[FMS] -# look-up-table for adding a description -# Using Description (0 - off | 1 - on) -# descriptions loaded from csv/fms.csv -idDescribed = 0 - -[ZVEI] -# look-up-table for adding a description -# Using Description (0 - off | 1 - on) -# descriptions loaded from csv/zvei.csv -idDescribed = 0 - -[POC] -# some very simple filters: -# Allow only this RICs (empty: allow all, separator ",") -# f.e.: allow_ric = 1234566,1234567,1234568 -allow_ric = - -# Deny this RICs (empty: allow all, separator ",") -# f.e.: deny_ric = 1234566,1234567,1234568 -deny_ric = - -# start and end of an allowed filter range -filter_range_start = 0000000 -filter_range_end = 9999999 - -# look-up-table for adding a description -# Using Description (0 - off | 1 - on) -# descriptions loaded from csv/poc.csv -idDescribed = 0 - -# Static Massages for Subrics. -rica = Feuer -ricb = TH -ricc = AGT -ricd = Unwetter - -[Filters] -# RegEX Filter Configuration -# http://www.regexr.com/ - RegEX Test Tool an Documentation -# No Filter for a Typ/Plugin Combination = all Data pass -# INDIVIDUAL_NAME = TYP;DATAFIELD;PLUGIN;FREQUENZ;REGEX -# TYP = the Data Typ (FMS|ZVEI|POC) -# DATAFIELD = the field of the Data Array (see readme.md in plugin folder) -# PLUGIN = the name of the Plugin to call with this Filter (* for all) -# FREQUENZ = the Frequenz to use the Filter (for more SDR Sticks (* for all)) -# REGEX = the RegEX - -# only ZVEI to all Plugins with 25### at 85.5MHz -#testfilter = ZVEI;zvei;*;85500000;25[0-9]{3} - -# only POCSAG to MySQL with the text "ALARM:" in the Message -#pocTest = POC;msg;MySQL;*;ALARM: - - -[Plugins] -# turn the plugins on or off (0 - off | 1 - on) -MySQL = 0 -httpRequest = 0 -eMail = 0 -BosMon = 0 -firEmergency = 0 -jsonSocket = 0 -notifyMyAndroid = 0 -SMS = 0 -Sms77 = 0 -FFAgent = 0 -Pushover = 0 -Telegram = 0 -yowsup = 0 - -# for developing template-module -template = 0 - - -[MySQL] -# MySQL configuration -dbserver = localhost -dbuser = boswatch -dbpassword = root -database = boswatch - -# tables in the database -tableFMS = bos_fms -tableZVEI = bos_zvei -tablePOC = bos_pocsag -tableSIG = bos_signal - -# Signal RICs (empty: none set, separator ",") -# f.e.: signal_ric = 1234566,1234567,1234568 -signal_ric = ## SIGNAL-RICS ## - - -[httpRequest] -# example URL http://example.com/remote.php?DESCR=%DESCR% - -# you can use the following wildcards in your URL as GET params: -# http://en.wikipedia.org/wiki/Query_string - -# %FMS% = FMS Code -# %STATUS% = FMS Status -# %DIR% = Direction of the telegram (0/1) -# %DIRT% = Direction of the telegram (Text-String) -# %TSI% = Tactical Short Information (I-IV) -# %DESCR% = Description from csv-file -# %TIME% = Time (by script) -# %DATE% = Date (by script) -#fms_url = http://www.google.de?code=%FMS%&stat=%STATUS% -fms_url = - -# %ZVEI% = ZVEI 5-tone Code -# %DESCR% = Description from csv-file -# %TIME% = Time (by script) -# %DATE% = Date (by script) -#zvei_url = http://www.google.de?zvei=%ZVEI% -zvei_url = - -# %RIC% = Pocsag RIC -# %FUNC% = Pocsac function/Subric (1-4) -# %FUNCCHAR% = Pocsac function/Subric als character (a-d) -# %FUNCTEXT% = Pocsac function/Subric static massage definded in pocsag section -# %MSG% = Message of the Pocsag telegram -# %BITRATE% = Bitrate of the Pocsag telegram -# %DESCR% = Description from csv-file -# %TIME% = Time (by script) -# %DATE% = Date (by script) -#poc_url = http://www.google.de?ric=%RIC%&subric=%FUNC%&msg=%MSG% -poc_url = - - -[eMail] -# SMTP-Server -smtp_server = localhost -# Port of SMTP-Server (default: -smtp_port = -# use tls for connection (0|1) -tls = 0 -# Use this, when SMTP-Server has restricted access -user = -password = - -# Parameters for Alarm-Msg: -# "to" could be more than one address, comma separated -from = local@localhost -to = user@irgendwo, user2@woanders - -# Priority of the eMail: -# normal|urgent|non-urgent -priority = urgent - -# %FMS% = FMS Code -# %STATUS% = FMS Status -# %DIR% = Direction of the telegram (0/1) -# %DIRT% = Direction of the telegram (Text-String) -# %TSI% = Tactical Short Information (I-IV) -# %DESCR% = Description, if description-module is used -# %DATE% = Date (by script) -# %TIME% = Time (by script) -# %BR% = Insert line wrap (only in message) -# %LPAR% = ( -# %RPAR% = ) -fms_subject = FMS: %FMS% -fms_message = %DATE% %TIME%: %FMS%%BR%Status: %STATUS% - Direction: %DIRT% - TSI: %TSI% - -# %ZVEI% = ZVEI 5-tone Code -# %DESCR% = Description, if description-module is used -# %DATE% = Date (by script) -# %TIME% = Time (by script) -# %BR% = Insert line wrap (only in message) -# %LPAR% = ( -# %RPAR% = ) -zvei_subject = Alarm: %ZVEI% -zvei_message = %DATE% %TIME%: %ZVEI% - -# %RIC% = Pocsag RIC -# %FUNC% = Pocsac function/Subric (1-4) -# %FUNCCHAR% = Pocsac function/Subric als character (a-d) -# %FUNCTEXT% = Pocsac function/Subric static massage definded in pocsag section -# %MSG% = Message of the Pocsag telegram -# %BITRATE% = Bitrate of the Pocsag telegram -# %DESCR% = Description, if description-module is used -# %DATE% = Date (by script) -# %TIME% = Time (by script) -# %BR% = Insert line wrap (only in message) -# %LPAR% = ( -# %RPAR% = ) -poc_subject = Alarm: %RIC%%LPAR%%FUNCCHAR%%RPAR% -poc_message = %DATE% %TIME% - %DESCR%: %MSG% - - -[BosMon] -# Server as IP of DNS-Name (without http://) -# actually no ssl supported -bosmon_server = 192.168.0.1 -bosmon_port = 80 - -# channel-name of typ "Web-Telegramm" -bosmon_channel = channel - -# Use this, when BosMon has restricted access -bosmon_user = -bosmon_password = - - -[firEmergency] -# firEmergency configuration -firserver = localhost -firport = 9001 - - -[jsonSocket] -# Protocol for socket (TCP|UDP) -protocol = UDP -# Server as IP of DNS-Name (without http://) -server = 192.168.0.1 -port = 8888 - - -[notifyMyAndroid] -# this APIKey is used for Plugin -APIKey = - -# Priority goes from -2 (lowest) to 2 (highest). the default priority is 0 (normal) -priority = 0 - -# You could change the name of the application (default: BOSWatch) -# (f.e. if you use more than one instance of BOSWatch) -appName = BOSWatch - -# instead of a given APIKey/priority you could import them by a csv-file (0|1) -# APIKey and prioiry above will be ignored, if you use a csv -# configuration loaded from csv/nma.csv -usecsv = 0 - - -[SMS] -# be aware that you need 'gammu' installed and running -# at least you need an UMTS-stick which is supported by 'gammu' - -quantity = 1 -# be sensitive to single RIC -ric1 = 1234567 - -# but you can watch several subrics, comma-separated -subric1 = a, b - -# a single cellphone-number -phonenumber1 = 0160321654987 - -# and the text for the sms -# ! DO NOT USE ANY UMLAUT ! -text1 = Rueckruf Leitstelle! - - -[Sms77] -# SMS77 configuration -# Login Username -user = - -# Password or API Key -password = - -# Receiver singlenumber or groupname from adressbook -to = - -# Sender number or name -from = - -# Type of Message (see https://www.sms77.de/funktionen/smstypen and https://www.sms77.de/funktionen/http-api) -type = quality - - -[FFAgent] -# set live mode (0/1) -live = 0 - -# send messages as type test (0/1) -test = 1 - -# path to server certificate file -serverCertFile = - -# path to client certificate file (LIVE) -clientCertFile = - -# path to client certificate password file (LIVE) -clientCertPass = - -# webapi token -webApiToken = - -# webapi key -webApiKey = - -# access token -accessToken = - -# selective Call Code -selectiveCallCode = - - -[Pushover] -# Pushover API Key -api_key = - -# Pushover Userkey or Groupkey to receive message -user_key = - -# Title of the message -title = BOSWatch Message - -# Adapt Pocsag Subric (a,b,c,d) to Pushover Priorities (see https://pushover.net/api#priority) -SubA = 0 -SubB = 2 -SubC = 1 -SubD = 0 - -# how often should Pushover re-alert in seconds (emergency-messages) -retry = 30 - -# when should Pushover stop to re-alert in seconds (emergency-messages) -expire = 90 - -# use HTML in messages (0/1) -html = 1 - - -[Telegram] -# This is your unique BOT token. You will get it from the BotFather once you have created your BOT. -BOTTokenAPIKey = -# Create a group chat with your BOT and enter the chat ID here. -# The plugin will send messages as your BOT and post everything in this group chat. -BOTChatIDAPIKey = -# The plugin can extract a location from the POCSAG message. -# However, this will be done for the following RIC only (7 digits e.g. 0012345). -RICforLocationAPIKey = -# This is your Google API key. -# Required if you want to create a map based on location information received with the above RIC. -GoogleAPIKey = - -[yowsup] -# number or chat-number who whants to become the news -empfaenger = -# WhatsApp-number of that the news comes -sender = -# password from this number -password= - -# %FMS% = FMS Code -# %STATUS% = FMS Status -# %DIR% = Direction of the telegram (0/1) -# %DIRT% = Direction of the telegram (Text-String) -# %TSI% = Tactical Short Information (I-IV) -# %DESCR% = Description, if description-module is used -# %DATE% = Date (by script) -# %TIME% = Time (by script) -# %LPAR% = ( -# %RPAR% = ) -fms_message = %DATE% %TIME%: %FMS% - -# %ZVEI% = ZVEI 5-tone Code -# %DESCR% = Description, if description-module is used -# %DATE% = Date (by script) -# %TIME% = Time (by script) -# %LPAR% = ( -# %RPAR% = ) -zvei_message = %DATE% %TIME%: %ZVEI% - -# %RIC% = Pocsag RIC -# %FUNC% = Pocsac function/Subric (1-4) -# %FUNCCHAR% = Pocsac function/Subric als character (a-d) -# %MSG% = Message of the Pocsag telegram -# %BITRATE% = Bitrate of the Pocsag telegram -# %DESCR% = Description, if description-module is used -# %DATE% = Date (by script) -# %TIME% = Time (by script) -# %LPAR% = ( -# %RPAR% = ) -poc_message = %MSG% - - -##################### -##### Not ready yet # -##################### - -[template] -test1 = testString -test2 = 123456 +######################## +# BOSWatch Config File # +######################## + +[BOSWatch] +# set loglevel for logfile +# 10 = debug +# 20 = info +# 30 = warning +# 40 = error +# 50 = critical +loglevel = 10 + +# BOSWatch uses a rotating logfile +# Rotating is at midnight +# You can set the backupCount here +# backupCount = 7 (keeps logfiles for 7 days) +backupCount = 7 + +# if you want to start BOSWatch as a daemon with rc2.d, +# you have to set the path to rtl_fm and multimon-ng ! +# both pathes have to end with an / +#rtl_path = /usr/local/bin/ +#multimon_path = /usr/local/bin/ + +# if you are using many plugins or plugins with a long execution time +# you can execute them in an asynchronous manner +# It must be pointed out that enabling (0|1) this consumes time, +# so don't use it for one rapid plugin +processAlarmAsync = 0 + +# Using RegEx-filter (0 - off | 1 - on) +# filter-configuration in section [Filters] +useRegExFilter = 0 + +# for double check save the last n IDs +# it is used in combination with double_ignore_time +# 1 is required if you want to use the double alarm filter +doubleFilter_ignore_entries = 10 + +# time to ignore same alarm (only ID is checked) (sec) +doubleFilter_ignore_time = 5 + +# ignore msg is only usefull for POCSAG (0 - off | 1 - on) +# 0: double check ignores the msg-text (only check ID + function) +# 1: if you want to differentiate between with/ without msg +# f.e. if they use quick-alarm (without text, then same RIC with msg) +# you will get more then one alarm anyway if the msg is different (receiving-problems) +doubleFilter_check_msg = 0 + +# writes the multimon-ng raw data stream into a text file named mm_raw.txt +writeMultimonRaw = 1 + +[NMAHandler] +# you can use a logging handler for sending logging records to NotifyMyAndroid +# enableHandler (0|1) will enable the NMA handler +enableHandler = 0 + +# loglevel for NMAHandler (see BOSWatch loglevel description) +loglevel = 50 + +# logging record will send to APIKey +APIKey = + +# you can change the name of the application (default: BOSWatch) +# (f.e. if you use more than one instance of BOSWatch) +appName = BOSWatch + + +[FMS] +# look-up-table for adding a description +# using description (0 - off | 1 - on) +# descriptions are loaded from csv/fms.csv +idDescribed = 0 + +# Check for correct CRC-information is provided by multimon-ng +# As this seems to be incorrect in many cases it might be useful to disable this +# (0 - off | 1 - on) +# Better use RegEX to verify the correct data +checkCRC = 0 + +[ZVEI] +# look-up-table for adding a description +# using description (0 - off | 1 - on) +# descriptions are loaded from csv/zvei.csv +idDescribed = 0 + +[POC] +# some very simple filters: +# Allow only this RICs (empty: allow all, separator ",") +# f.e.: allow_ric = 1234566,1234567,1234568 +allow_ric = + +# Deny this RICs (empty: allow all, separator ",") +# f.e.: deny_ric = 1234566,1234567,1234568 +deny_ric = + +# start and end of an allowed filter range +filter_range_start = 0000000 +filter_range_end = 9999999 + +# look-up-table for adding a description +# using description (0 - off | 1 - on) +# descriptions are loaded from csv/poc.csv +idDescribed = 0 + +# Static Massages for Subrics. +rica = Feuer +ricb = TH +ricc = AGT +ricd = Unwetter + +# RIC for net identification +# Usually sent periodically, separated by comma +netIdent_ric = 0174760, 1398098 + +[Filters] +# RegEX Filter Configuration +# http://www.regexr.com/ - RegEX Test Tool an Documentation +# No Filter for a Typ/Plugin Combination = all Data pass +# INDIVIDUAL_NAME = TYP;DATAFIELD;PLUGIN;FREQUENZ;REGEX +# TYP = the Data Typ (FMS|ZVEI|POC) +# DATAFIELD = the field of the Data Array (see readme.md in plugin folder) +# PLUGIN = the name of the Plugin to call with this Filter (* for all) +# FREQUENZ = the Frequenz to use the Filter (for more SDR Sticks (* for all)) +# REGEX = the RegEX + +# only ZVEI to all plugins with 25### at 85.5MHz +#testfilter = ZVEI;zvei;*;85500000;25[0-9]{3} + +# only POCSAG to MySQL with the text "ALARM:" in the message +#pocTest = POC;msg;MySQL;*;ALARM: + + +[Plugins] +# turn the plugins on or off (0 - off | 1 - on) +MySQL = 0 +httpRequest = 0 +eMail = 0 +BosMon = 0 +firEmergency = 0 +jsonSocket = 0 +notifyMyAndroid = 0 +SMS = 0 +Sms77 = 0 +FFAgent = 0 +Pushover = 0 +Telegram = 0 +yowsup = 0 + +# for developing template-module +template = 0 + + +[MySQL] +# MySQL configuration +dbserver = localhost +dbuser = boswatch +dbpassword = root +database = boswatch + +# tables in the database +tableFMS = bos_fms +tableZVEI = bos_zvei +tablePOC = bos_pocsag +tableSIG = bos_signal + + +[httpRequest] +# example URL http://example.com/remote.php?DESCR=%DESCR% + +# you can use the following wildcards in your URL as GET params: +# http://en.wikipedia.org/wiki/Query_string + +# %FMS% = FMS Code +# %STATUS% = FMS Status +# %DIR% = Direction of the telegram (0/1) +# %DIRT% = Direction of the telegram (Text-String) +# %TSI% = Tactical Short Information (I-IV) +# %DESCR% = Description from csv-file +# %TIME% = Time (by script) +# %DATE% = Date (by script) +#fms_url = http://www.google.de?code=%FMS%&stat=%STATUS% +fms_url = + +# %ZVEI% = ZVEI 5-tone Code +# %DESCR% = Description from csv-file +# %TIME% = Time (by script) +# %DATE% = Date (by script) +#zvei_url = http://www.google.de?zvei=%ZVEI% +zvei_url = + +# %RIC% = POCSAG RIC +# %FUNC% = POCSAG function/Subric (1-4) +# %FUNCCHAR% = POCSAG function/Subric as character (a-d) +# %FUNCTEXT% = POCSAG function/Subric static massage definded in POCSAG section +# %MSG% = Message of the POCSAG telegram +# %BITRATE% = Bitrate of the POCSAG telegram +# %DESCR% = Description from csv-file +# %TIME% = Time (by script) +# %DATE% = Date (by script) +#poc_url = http://www.google.de?ric=%RIC%&subric=%FUNC%&msg=%MSG% +poc_url = + + +[eMail] +# SMTP-Server +smtp_server = localhost +# Port of SMTP-server (default: ) +smtp_port = +# use tls for connection (0|1) +tls = 0 +# Use this, when SMTP-server has restricted access +user = +password = + +# Parameters for Alarm-Msg: +# "to" can be more than one address, comma separated +from = local@localhost +to = user@irgendwo, user2@woanders + +# Priority of the eMail: +# normal|urgent|non-urgent +priority = urgent + +# %FMS% = FMS Code +# %STATUS% = FMS Status +# %DIR% = Direction of the telegram (0/1) +# %DIRT% = Direction of the telegram (Text-String) +# %TSI% = Tactical Short Information (I-IV) +# %DESCR% = Description, if description-module is used +# %DATE% = Date (by script) +# %TIME% = Time (by script) +# %BR% = Insert line wrap (only in message) +# %LPAR% = ( +# %RPAR% = ) +fms_subject = FMS: %FMS% +fms_message = %DATE% %TIME%: %FMS%%BR%Status: %STATUS% - Direction: %DIRT% - TSI: %TSI% + +# %ZVEI% = ZVEI 5-tone Code +# %DESCR% = Description, if description-module is used +# %DATE% = Date (by script) +# %TIME% = Time (by script) +# %BR% = Insert line wrap (only in message) +# %LPAR% = ( +# %RPAR% = ) +zvei_subject = Alarm: %ZVEI% +zvei_message = %DATE% %TIME%: %ZVEI% + +# %RIC% = POCSAG RIC +# %FUNC% = POCSAG function/Subric (1-4) +# %FUNCCHAR% = POCSAG function/Subric als character (a-d) +# %FUNCTEXT% = POCSAG function/Subric static massage definded in POCSAG section +# %MSG% = Message of the POCSAG telegram +# %BITRATE% = Bitrate of the POCSAG telegram +# %DESCR% = Description, if description-module is used +# %DATE% = Date (by script) +# %TIME% = Time (by script) +# %BR% = Insert line wrap (only in message) +# %LPAR% = ( +# %RPAR% = ) +poc_subject = Alarm: %RIC%%LPAR%%FUNCCHAR%%RPAR% +poc_message = %DATE% %TIME% - %DESCR%: %MSG% + + +[BosMon] +# IP-address of the server (without http://) +# actually no SSL-support +bosmon_server = 192.168.0.1 +bosmon_port = 80 + +# channel-name of type "Web-Telegramm" +bosmon_channel = channel + +# Use this, when BosMon has restricted access +bosmon_user = +bosmon_password = + + +[firEmergency] +# firEmergency configuration +firserver = localhost +firport = 9001 + + +[jsonSocket] +# Protocol for socket (TCP|UDP) +protocol = UDP +# IP-address of the server (without http://) +server = 192.168.0.1 +port = 8888 + + +[notifyMyAndroid] +# APIKey given from notifyMyAndroid +APIKey = + +# Priority goes from -2 (lowest) to 2 (highest). The default priority is 0 (normal) +priority = 0 + +# You can change the name of the application (default: BOSWatch) +# (f.e. if you use more than one instance of BOSWatch) +appName = BOSWatch + +# instead of a given APIKey/priority you could import them by a csv-file (0|1) +# APIKey and priority above will be ignored, if you use a csv +# configuration loaded from csv/nma.csv +usecsv = 0 + + +[SMS] +# be aware that you need 'gammu' installed and running +# at least you need an UMTS-stick which is supported by 'gammu' + +quantity = 1 +# be sensitive to single RIC +ric1 = 1234567 + +# but you can watch several subrics, comma-separated +subric1 = a, b + +# a single cellphone-number +phonenumber1 = 0160321654987 + +# and the text for the sms +# ! DO NOT USE ANY UMLAUT ! +text1 = Rueckruf Leitstelle! + + +[Sms77] +# SMS77 configuration +# Login Username +user = + +# Password or API Key +password = + +# Receiver singlenumber or groupname from adressbook +to = + +# Sender number or name +from = + +# Type of Message (see https://www.sms77.de/funktionen/smstypen and https://www.sms77.de/funktionen/http-api) +type = quality + + +[FFAgent] +# set live mode (0/1) +live = 0 + +# send messages as type test (0/1) +test = 1 + +# path to server certificate file +serverCertFile = + +# path to client certificate file (LIVE) +clientCertFile = + +# path to client certificate password file (LIVE) +clientCertPass = + +# webapi token +webApiToken = + +# webapi key +webApiKey = + +# access token +accessToken = + +# selective Call Code +selectiveCallCode = + + +[Pushover] +# Pushover API Key +api_key = + +# Pushover Userkey or Groupkey to receive message +user_key = + +# Title of the message +title = BOSWatch Message + +# Adapt Pocsag Subric (a,b,c,d) to Pushover Priorities (see https://pushover.net/api#priority) +SubA = 0 +SubB = 2 +SubC = 1 +SubD = 0 + +# how often should Pushover re-alert in seconds (emergency-messages) +retry = 30 + +# when should Pushover stop to re-alert in seconds (emergency-messages) +expire = 90 + +# use HTML in messages (0/1) +html = 1 + + +[Telegram] +# This is your unique BOT token. You will get it from the BotFather once you have created your BOT. +BOTTokenAPIKey = +# Create a group chat with your BOT and enter the chat ID here. +# The plugin will send messages as your BOT and post everything in this group chat. +BOTChatIDAPIKey = +# The plugin can extract a location from the POCSAG message. +# However, this will be done for the following RIC only (7 digits e.g. 0012345). +RICforLocationAPIKey = +# This is your Google API key. +# Required if you want to create a map based on location information received with the above RIC. +GoogleAPIKey = + +[yowsup] +# number or chat-number who whants to become the news +empfaenger = +# WhatsApp-number of that the news comes +sender = +# password from this number +password= + +# %FMS% = FMS Code +# %STATUS% = FMS Status +# %DIR% = Direction of the telegram (0/1) +# %DIRT% = Direction of the telegram (Text-String) +# %TSI% = Tactical Short Information (I-IV) +# %DESCR% = Description, if description-module is used +# %DATE% = Date (by script) +# %TIME% = Time (by script) +# %LPAR% = ( +# %RPAR% = ) +fms_message = %DATE% %TIME%: %FMS% + +# %ZVEI% = ZVEI 5-tone Code +# %DESCR% = Description, if description-module is used +# %DATE% = Date (by script) +# %TIME% = Time (by script) +# %LPAR% = ( +# %RPAR% = ) +zvei_message = %DATE% %TIME%: %ZVEI% + +# %RIC% = POCSAG RIC +# %FUNC% = POCSAG function/Subric (1-4) +# %FUNCCHAR% = POCSAG function/Subric als character (a-d) +# %MSG% = Message of the POCSAG telegram +# %BITRATE% = Bitrate of the POCSAG telegram +# %DESCR% = Description, if description-module is used +# %DATE% = Date (by script) +# %TIME% = Time (by script) +# %LPAR% = ( +# %RPAR% = ) +poc_message = %MSG% + + +##################### +##### Not ready yet # +##################### + +[template] +test1 = testString +test2 = 123456 diff --git a/includes/decoder.py b/includes/decoder.py index d62604d..9c979d3 100644 --- a/includes/decoder.py +++ b/includes/decoder.py @@ -27,21 +27,21 @@ def decode(freq, decoded): # FMS Decoder Section # check FMS: -> check CRC -> validate -> check double alarm -> log if "FMS:" in decoded: - logging.debug("recieved FMS") + logging.debug("received FMS") from includes.decoders import fms fms.decode(freq, decoded) # ZVEI Decoder Section # check ZVEI: -> validate -> check double alarm -> log - elif "ZVEI2:" in decoded: - logging.debug("recieved ZVEI") + elif "ZVEI1:" in decoded: + logging.debug("received ZVEI") from includes.decoders import zvei zvei.decode(freq, decoded) # POCSAG Decoder Section # check POCSAG -> validate -> check double alarm -> log elif "POCSAG512:" in decoded or "POCSAG1200:" in decoded or "POCSAG2400:" in decoded: - logging.debug("recieved POCSAG") + logging.debug("received POCSAG") from includes.decoders import poc poc.decode(freq, decoded) diff --git a/includes/decoders/fms.py b/includes/decoders/fms.py index 88c3234..a53c6ce 100644 --- a/includes/decoders/fms.py +++ b/includes/decoders/fms.py @@ -37,14 +37,22 @@ def decode(freq, decoded): try: fms_service = decoded[19] # Organisation fms_country = decoded[36] # Bundesland - fms_location = decoded[65:67] # Ort + fms_location = decoded[61:63] # Ort fms_vehicle = decoded[72:76] # Fahrzeug fms_status = decoded[84] # Status fms_direction = decoded[101] # Richtung fms_directionText = decoded[103:110] # Richtung (Text) fms_tsi = decoded[114:117] # Taktische Kruzinformation - if "CRC correct" in decoded: #check CRC is correct + proceed = True # no CRC-check required - proceed + + # shall we use the CRC-check? + if (globalVars.config.getboolean("FMS", "CheckCRC")): + if "CRC correct" not in decoded: + # if CRC must be checked and is not correct - dont proceed + proceed = False + + if (proceed == True): fms_id = fms_service+fms_country+fms_location+fms_vehicle+fms_status+fms_direction # build FMS id # if FMS is valid if re.search("[0-9a-f]{8}[0-9a-f]{1}[01]{1}", fms_id): diff --git a/includes/decoders/poc.py b/includes/decoders/poc.py index b0d1fcd..46be042 100644 --- a/includes/decoders/poc.py +++ b/includes/decoders/poc.py @@ -29,9 +29,12 @@ def isAllowed(poc_id): @requires: Configuration has to be set in the config.ini - @return: True if the Ric is allowed, other False + @return: Checks both allow/deny-rule and filter-range (suitable for signal-RIC) @exception: none """ + + allowed = 0 + # 1.) If allowed RICs is set, only they will path, # If RIC is the right one return True, else False if globalVars.config.get("POC", "allow_ric"): @@ -40,17 +43,27 @@ def isAllowed(poc_id): return True else: logging.info("RIC %s is not in the allowed list", poc_id) - return False + allowed = 0 # 2.) If denied RIC, return False - elif poc_id in globalVars.config.get("POC", "deny_ric"): + if poc_id in globalVars.config.get("POC", "deny_ric"): logging.info("RIC %s is denied by config.ini", poc_id) - return False + return False # RIC is denied - strongest way to block # 3.) Check Range, return False if outside def. range - elif int(poc_id) < globalVars.config.getint("POC", "filter_range_start"): - logging.info("RIC %s out of filter range (start)", poc_id) - return False - elif int(poc_id) > globalVars.config.getint("POC", "filter_range_end"): - logging.info("RIC %s out of filter range (end)", poc_id) + if globalVars.config.getint("POC", "filter_range_start") < int(poc_id) < globalVars.config.getint("POC", "filter_range_end"): + logging.info("RIC %s in between filter range", poc_id) + return True + else: + logging.info("RIC %s out of filter range", poc_id) + allowed = 0 + # 4.) Implementation for net identifiers + if globalVars.config.get("POC", "netIdent_ric"): + if poc_id in globalVars.config.get("POC", "netIdent_ric"): + logging.info("RIC %s as net identifier", poc_id) + return True + else: + allowed = 0 + + if allowed == 0: return False return True @@ -61,7 +74,7 @@ def isAllowed(poc_id): # def decode(freq, decoded): """ - Export POCSAG Information from Multimon-NG RAW String and call alarmHandler.processAlarmHandler() + Export POCSAG information from Multimon-NG string and call alarmHandler.processAlarmHandler() @type freq: string @param freq: frequency of the SDR Stick @@ -98,7 +111,7 @@ def decode(freq, decoded): logging.debug("POCSAG Bitrate: %s", bitrate) if "Alpha:" in decoded: #check if there is a text message - poc_text = decoded.split('Alpha: ')[1].strip().rstrip('').strip() + poc_text = decoded.split('Alpha: ')[1].strip().replace('','').replace('','').replace('','').replace('','').strip() else: poc_text = "" diff --git a/includes/decoders/zvei.py b/includes/decoders/zvei.py index ac747da..cabe68c 100644 --- a/includes/decoders/zvei.py +++ b/includes/decoders/zvei.py @@ -17,24 +17,24 @@ from includes import doubleFilter # double alarm filter ## # -# Local function to remove the 'F' +# Local function to remove the 'E' # -def removeF(zvei): +def removeE(zvei): """ - Resolve the F from the repeat Tone + Resolve the E from the repeat Tone @type zvei: string @param zvei: ZVEI Information - @return: ZVEI without F + @return: ZVEI without E @exception: none """ - if "F" in zvei: + if "E" in zvei: zvei_old = zvei for i in range(1, len(zvei_old)): - if zvei[i] == "F": - zvei = zvei.replace("F",zvei[i-1],1) - logging.debug("resolve F: %s -> %s", zvei_old, zvei) + if zvei[i] == "E": + zvei = zvei.replace("E",zvei[i-1],1) + logging.debug("remove E: %s -> %s", zvei_old, zvei) return zvei ## @@ -58,7 +58,7 @@ def decode(freq, decoded): """ try: zvei_id = decoded[7:12] # ZVEI Code - zvei_id = removeF(zvei_id) # resolve F + zvei_id = removeE(zvei_id) # remove E (repeated tone) if re.search("[0-9]{5}", zvei_id): # if ZVEI is valid # check for double alarm if doubleFilter.checkID("ZVEI", zvei_id): diff --git a/includes/globalVars.py b/includes/globalVars.py index 736deed..bd0cd55 100644 --- a/includes/globalVars.py +++ b/includes/globalVars.py @@ -9,8 +9,8 @@ Global variables """ # version info -versionNr = "2.1" -buildDate = "2016/11/20" +versionNr = "2.2-beta" +buildDate = "2016/02/23" # Global variables config = 0 diff --git a/includes/helper/wildcardHandler.py b/includes/helper/wildcardHandler.py index 358f4b6..d67dde2 100644 --- a/includes/helper/wildcardHandler.py +++ b/includes/helper/wildcardHandler.py @@ -53,7 +53,7 @@ def replaceWildcards(text, data, lineBrakeAllowed=False): # replace POC data if "ric" in data: text = text.replace("%RIC%", data["ric"]) - if "function" in data: + if "function" in data: text = text.replace("%FUNC%", data["function"]) if data["function"] == "1": text = text.replace("%FUNCTEXT%", globalVars.config.get("POC","rica")) if data["function"] == "2": text = text.replace("%FUNCTEXT%", globalVars.config.get("POC","ricb")) diff --git a/install.sh b/install.sh index 5e8092b..5c251ea 100644 --- a/install.sh +++ b/install.sh @@ -8,8 +8,12 @@ function exitcodefunction { if [ $errorcode -ne "0" ]; then echo "Action: $action on $module failed." >> $boswatchpath/install/setup_log.txt echo "Exitcode: $errorcode" >> $boswatchpath/install/setup_log.txt + echo "" echo "Action: $action on $module failed." echo "Exitcode: $errorcode" + echo "" + echo " -> If you want to open an Issue at https://github.com/Schrolli91/BOSWatch/issues" + echo " please post the logfile, located at $boswatchpath/install/setup_log.txt" exit 1 else echo "Action: $action on $module ok." >> $boswatchpath/install/setup_log.txt @@ -40,8 +44,28 @@ echo "Caution, script does not install a webserver with PHP and MySQL" echo "So you have to make up manually if you want to use MySQL support" boswatchpath=/opt/boswatch -mkdir -p $boswatchpath reboot=false +didBackup=false + +# check for old version (for the old ones...) +if [ -f $boswatchpath/BOSWatch/boswatch.py ]; then + echo "Old installation found!" + echo "A backup will be copied to $boswatchpath/old" + + mkdir /tmp/boswatch + mv $boswatchpath/BOSWatch/* /tmp/boswatch/ + didBackup=true +fi + +#and the future... +if [ -f $boswatchpath/boswatch.py ]; then + echo "Old installation found!" + echo "A backup will be copied to $boswatchpath/old" + + mkdir /tmp/boswatch + mv $boswatchpath/* /tmp/boswatch/ + didBackup=true +fi for (( i=1; i<=$#; i=$i+2 )); do t=$((i + 1)) @@ -49,23 +73,22 @@ for (( i=1; i<=$#; i=$i+2 )); do eval arg2=\$$t case $arg in - -r|--reboot) - case $arg2 in - y|yes) reboot=true ;; - n|no) reboot=false ;; - *) echo "Please use y/yes or n/no for reboot" ; exit 1 ;; - esac ;; + -r|--reboot) reboot=true ;; -b|--branch) case $arg2 in - dev|develop) echo " !!! WARNING: you are using the DEV BRANCH !!! "; branch=dev ;; + dev|develop) echo " !!! WARNING: you are using the DEV BRANCH !!! "; branch=dev ;; + beta) echo " !!! WARNING: you are using the BETA BRANCH !!! "; branch=beta ;; *) branch=master ;; esac ;; + -p|--path) echo " !!! WARNING: you install BOSWATCH to alternative path !!! "; boswatchpath=$arg2 ;; + *) echo "Internal error!" ; exit 1 ;; esac done +mkdir -p $boswatchpath mkdir -p $boswatchpath/install echo "" @@ -169,8 +192,9 @@ cd $boswatchpath/ case $branch in "dev") git clone -b develop https://github.com/Schrolli91/BOSWatch >> $boswatchpath/install/setup_log.txt 2>&1 && \ -# "dev") git clone -b develop https://github.com/thejockel/BOSWatch >> $boswatchpath/install/setup_log.txt 2>&1 && \ exitcodefunction $? git-clone BOSWatch-develop ;; + "beta") git clone -b beta https://github.com/Schrolli91/BOSWatch >> $boswatchpath/install/setup_log.txt 2>&1 && \ + exitcodefunction $? git-clone BOSWatch-beta ;; *) git clone -b master https://github.com/Schrolli91/BOSWatch >> $boswatchpath/install/setup_log.txt 2>&1 && \ exitcodefunction $? git-clone BOSWatch ;; esac @@ -203,6 +227,16 @@ rm $boswatchpath/install/ -R mv $boswatchpath/BOSWatch/* $boswatchpath/ rm $boswatchpath/BOSWatch -R +#copy the template config to run boswatch +cp $boswatchpath/config/config.template.ini $boswatchpath/config/config.ini + + +#replay the backup +if [ $didBackup = "true" ]; then + mkdir $boswatchpath/old/ + mv /tmp/boswatch/* $boswatchpath/old/ +fi + if [ $reboot = "true" ]; then /sbin/reboot fi diff --git a/plugins/Telegram/Telegram.py b/plugins/Telegram/Telegram.py index c787405..0d890c8 100644 --- a/plugins/Telegram/Telegram.py +++ b/plugins/Telegram/Telegram.py @@ -113,11 +113,28 @@ def run(typ,freq,data): gcode_result = gcode.geocode(address) logging.debug("Send location via Telegram BOT API") bot.sendLocation('%s' % BOTChatIDAPIKey, gcode_result[0]['geometry']['location']['lat'], gcode_result[0]['geometry']['location']['lng'], disable_notification='true') - elif typ == "FMS": - logging.debug("FMS not supported yet") + logging.debug("Compose output from FMS-message") + # compose message content + output = timeHandler.curtime()+"\n"+data["fms"]+"\n"+data["description"]+"\n"+data["status"] + + # Initiate Telegram Bot + logging.debug("Initiate Telegram BOT") + bot = telegram.Bot(token='%s' % BOTTokenAPIKey) + # Send message to chat via Telegram BOT API + logging.debug("Send message to chat via Telegram BOT API") + bot.sendMessage('%s' % BOTChatIDAPIKey, output) elif typ == "ZVEI": - logging.debug("ZVEI not supported yet") + logging.debug("Compose output from ZVEI-message") + # compose message content + output = timeHandler.curtime()+"\n"+data["zvei"]+"\n"+data["description"] + + # Initiate Telegram Bot + logging.debug("Initiate Telegram BOT") + bot = telegram.Bot(token='%s' % BOTTokenAPIKey) + # Send message to chat via Telegram BOT API + logging.debug("Send message to chat via Telegram BOT API") + bot.sendMessage('%s' % BOTChatIDAPIKey, output) else: logging.warning("Invalid Typ: %s", typ) except Unauthorized: diff --git a/plugins/eMail/eMail.py b/plugins/eMail/eMail.py index cd697b9..d054c85 100644 --- a/plugins/eMail/eMail.py +++ b/plugins/eMail/eMail.py @@ -18,7 +18,7 @@ from email.utils import make_msgid # need for confirm to RFC2822 standard from includes import globalVars # Global variables -from includes.helper import timeHandler # helper function +#from includes.helper import timeHandler # helper function from includes.helper import configHandler # helper function from includes.helper import wildcardHandler # helper function @@ -187,7 +187,7 @@ def run(typ,freq,data): return else: - logging.warning("Invalid Typ: %s", typ) + logging.warning("Invalid Type: %s", typ) finally: logging.debug("close eMail-Connection") diff --git a/plugins/httpRequest/httpRequest.py b/plugins/httpRequest/httpRequest.py index 81b9ba5..3d8d90e 100644 --- a/plugins/httpRequest/httpRequest.py +++ b/plugins/httpRequest/httpRequest.py @@ -91,7 +91,8 @@ def run(typ,freq,data): logging.debug("send %s HTTP request", typ) try: - resp = urllib2.urlopen(url) + #resp = urllib2.urlopen(url) + urllib2.urlopen(url) except urllib2.HTTPError as e: logging.warning("HTTP response: %s", e.code) except urllib2.URLError as e: diff --git a/service/README.md b/service/README.md index c5c8cac..3057ee4 100644 --- a/service/README.md +++ b/service/README.md @@ -18,6 +18,7 @@ To actually use this script, put BOSWatch where you want (recommend `/usr/local/ and make sure it is executable (e.g. `sudo chmod 755 boswatch.py`). Edit the init script accordingly. Copy it into /etc/init.d using e.g. `sudo cp boswatch.sh /etc/init.d`. Make sure the script is executable (chmod again) and make sure that it has UNIX line-endings. +After creating this new daemon it's neccessary to do a `sudo systemctl daemon-reload` in order to make it findable. At this point you should be able to start BOSWatchcd ~/srt using the command `sudo /etc/init.d/boswatch.sh start`, check its status with the `sudo /etc/init.d/boswatch.sh status` argument and stop it with `sudo /etc/init.d/boswatch.sh stop`. diff --git a/service/boswatch.sh b/service/boswatch.sh index bbfacba..70263b4 100755 --- a/service/boswatch.sh +++ b/service/boswatch.sh @@ -11,7 +11,7 @@ ### END INIT INFO # Change the next 3 lines to suit where you install your script and what you want to call it -DIR=/usr/local/bin/BOSWatch +DIR=/opt/boswatch DAEMON=$DIR/boswatch.py DAEMON_NAME=boswatch diff --git a/testdata/rt_fm errors.txt b/testdata/rt_fm errors.txt deleted file mode 100644 index 3b3705e..0000000 --- a/testdata/rt_fm errors.txt +++ /dev/null @@ -1,7 +0,0 @@ -Error Messages from RTL_FM - -fprintf(stderr, "Signal caught, exiting!\n"); -fprintf(stderr, "Failed to open rtlsdr device #%d.\n", dongle.dev_index); -fprintf(stderr, "Failed to open %s\n", output.filename); -fprintf(stderr, "\nUser cancel, exiting...\n"); -fprintf(stderr, "\nLibrary error %d, exiting...\n", r);