diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d14a03..cf8fdf2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,26 +1,54 @@ # Changelog - -#### __[v2.2.1]__ - 19.09.2017 +### __[2.3]__ - unreleased ##### Added -- Neues Service Script -- Eigene Message fpr jeden Typ im Telegram Plugin - ##### Changed -- Name der csv Dateien um überschreiben bei Update zu vermeiden -- Description Liste kann nun zusätzlich Einträge für jede Subric enthalten -- RegEX verbietet nun grundsätzlich alles - Es muss explizit zugelassen werden - ##### Deprecated ##### Removed ##### Fixed -- Bug im SMS77 Plugin - ##### Security +### __[v2.2.2]__ - 21.10.2017 +##### Added +- Installations Script für Services [#316](https://github.com/Schrolli91/BOSWatch/pull/316) +##### Changed +- Telegram Plugin importiert Google Maps Funktionen nur noch wenn API Key eingetragen ist [#315](https://github.com/Schrolli91/BOSWatch/pull/315) +- Versions Nummer und Branch Name getrennt [3fed1ac](https://github.com/Schrolli91/BOSWatch/commit/3fed1ac12af8690213766e0e81d71c237530ed2c) +##### Deprecated +- Beta Branch wird mit nächstem Update entfernt [Forum](http://boswatch.de/index.php?thread/16-beta-branch-abschaffen/&postID=113#post113) +##### Fixed +- Schreibfehler der Pfadangabe im Installer [#317](https://github.com/Schrolli91/BOSWatch/pull/317) +- Schreibfehler in Service Readme [#313](https://github.com/Schrolli91/BOSWatch/issues/313) +- Einige Code-Style Verbesserungen [#310](https://github.com/Schrolli91/BOSWatch/pull/310) + + +### __[v2.2.1]__ - 19.09.2017 +##### Added +- Neues Service Script [#263](https://github.com/Schrolli91/BOSWatch/pull/263) +- Eigene Message für jeden Typ im Telegram Plugin in der config definierbar [#267](https://github.com/Schrolli91/BOSWatch/pull/267) +- httpRequest Plugin unterstützt nun mehrere URLs [254](https://github.com/Schrolli91/BOSWatch/pull/254) + +##### Changed +- Name der csv Dateien geändert um überschreiben bei Update zu vermeiden [#262](https://github.com/Schrolli91/BOSWatch/pull/262) +- Description Liste kann nun zusätzlich Einträge für jede Subric enthalten (POCSAG) [#271](https://github.com/Schrolli91/BOSWatch/pull/271) +- RegEX verbietet nun grundsätzlich alles - Es muss explizit zugelassen werden (wenn RegEX aktiv) [#284](https://github.com/Schrolli91/BOSWatch/pull/284) + +##### Fixed +- Bug im SMS77 Plugin behoben [#257](https://github.com/Schrolli91/BOSWatch/issues/257) +- einige Code-Style Verbesserungen + + ---------------------------- Zum schreiben des Changelog's siehe: http://keepachangelog.com/de/1.0.0/ + +### __[version]__ - date +##### Added +##### Changed +##### Deprecated +##### Removed +##### Fixed +##### Security diff --git a/README.md b/README.md index ac3d336..eb8e805 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,10 @@ In der Zukunft wollen wir die Möglichkeit schaffen, codierte Nachrichten zu ent :satellite: Python Script to receive and decode German BOS Information with rtl_fm and multimon-NG :satellite: +#### WICHTIG +**Es wird darauf hingewiesen, dass für die Teilnahme am BOS-Funk nur nach den Technischen Richtlinien der BOS zugelassene Funkanlagen verwendet werden dürfen.** +**Der BOS-Funk ist ein nichtöffentlicher mobiler Landfunk. Privatpersonen gehören nicht zum Kreis der berechtigten Funkteilnehmer.** _(Quelle: TR-BOS)_ + #### Notice: The intercept of the German BOS radio is **strictly prohibited** and will be prosecuted. the use is **only authorized** personnel permitted. The software was developed using the Multimon-NG code, a function in the real operation can not be guaranteed. @@ -23,10 +27,13 @@ The software was developed using the Multimon-NG code, a function in the real op **Please** only use Code from **master**-Branch - thats **the only stable!** +beta-branch is for beta-test of new features + unless you are developer you can use the develop-Branch - may be unstable! ### Features ##### Implemented features: +**list is not complete!** - FMS, ZVEI and POCSAG512/1200/2400 decoding and displaying - Plugin support for easy functional extension - Filtering double alarms with adjustable time and check width @@ -41,30 +48,12 @@ unless you are developer you can use the develop-Branch - may be unstable! - possibility to start plugins asynchron - NMA Error Handler -##### Features for the future: -- more plugins -- other Ideas per Issues please - ### Plugins If you want to code your own Plugin, see `plugins/README.md`. ##### Implemented plugins: - -|Plugin|Function|FMS|ZVEI|POC| -|-----|---------|:-:|:--:|:-:| -|MySQL|insert data into MySQL database|:white_check_mark:|:white_check_mark:|:white_check_mark:| -|httpRequest|send a request with parameter to an URL|:white_check_mark:|:white_check_mark:|:white_check_mark:| -|eMail|send Mails with own text|:white_check_mark:|:white_check_mark:|:white_check_mark:| -|BosMon|send data to BosMon server|:white_check_mark:|:white_check_mark:|:white_check_mark:| -|firEmergency|send data to firEmergency server|:x:|:white_check_mark:|:white_check_mark:| -|jsonSocket|send data as jsonString to a socket server|:white_check_mark:|:white_check_mark:|:white_check_mark:| -|NMA|send data to Notify my Android|:white_check_mark:|:white_check_mark:|:white_check_mark:| - -- for more Information to the plugins see `config.ini` - -##### Plugins for the Future: -- Ideas per Issues please +please look at the wiki page ### Configuration @@ -105,52 +94,15 @@ Take a look into the parser.php for the parsing functions~~ ### Usage -`sudo python boswatch.py -f 85.235M -a FMS ZVEI` -Starts boswatch at frequency 85.235 MHz with the demodulation functions FMS and ZVEI. -Parameter -f/--freq and -a/--demod are required! - -Help to all usable parameters with `sudo python boswatch.py -h` - -``` -usage: boswatch.py [-h] -f FREQ [-d DEVICE] [-e ERROR] -a - {FMS,ZVEI,POC512,POC1200,POC2400} - [{FMS,ZVEI,POC512,POC1200,POC2400} ...] [-s SQUELCH] [-v] - -optional arguments: - -h, --help show this help message and exit - -f FREQ, --freq FREQ Frequency you want to listen - -d DEVICE, --device DEVICE Device you want to use (Check with rtl_test) - -e ERROR, --error ERROR Frequency-Error of your device in PPM - -a {FMS,ZVEI,POC512,POC1200,POC2400} [{FMS,ZVEI,POC512,POC1200,POC2400} ...], - --demod {FMS,ZVEI,POC512,POC1200,POC2400} [{FMS,ZVEI,POC512,POC1200,POC2400} ...] - Demodulation functions - -s SQUELCH, --squelch SQUELCH level of squelch - -u, --usevarlog Use '/var/log/boswatch' for logfiles instead of subdir 'log' in BOSWatch directory - -v, --verbose Shows more information - -q, --quiet Shows no information. Only logfiles -``` - +please look at the wiki page ### Installation -Please follow the instructions written down in the wiki: - -https://github.com/Schrolli91/BOSWatch/wiki - -You just need to download a single file since the installer manages the whole process except the installation of a webserver and a database. +please look at the wiki page 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`. Then you can start BOSWatch with `sudo /etc/init.d/boswatch.sh start`. For configuration-details see `service/README.md`. -### Requirements -- RTL_SDR (rtl_fm) -- Multimon-NG -- Python Support -- MySQL Connector for Python (for MySQL-plugin) - -Thanks to smith_fms and McBo from Funkmeldesystem.de - Forum for Inspiration and Groundwork! - - -### Code your own Plugin -See `plugins/README.md` +##### Big thanks +to smith_fms and McBo from Funkmeldesystem.de - Forum for Inspiration and Groundwork! diff --git a/boswatch.py b/boswatch.py index e8b7b3a..df1e5e6 100755 --- a/boswatch.py +++ b/boswatch.py @@ -18,11 +18,12 @@ GitHUB: https://github.com/Schrolli91/BOSWatch import logging import logging.handlers -import argparse # for parse the args -import ConfigParser # for parse the config file -import os # for log mkdir -import time # for time.sleep() -import subprocess # for starting rtl_fm and multimon-ng +import argparse # for parse the args +import ConfigParser # for parse the config file +import os # for log mkdir +import sys # for py version +import time # for time.sleep() +import subprocess # for starting rtl_fm and multimon-ng from includes import globalVars # Global variables from includes import MyTimedRotatingFileHandler # extension of TimedRotatingFileHandler @@ -162,7 +163,9 @@ try: # try: logging.debug("SW Version: %s",globalVars.versionNr) + logging.debug("Branch: %s",globalVars.branch) logging.debug("Build Date: %s",globalVars.buildDate) + logging.debug("Python Vers: %s",sys.version) logging.debug("BOSWatch given arguments") if args.test: logging.debug(" - Test-Mode!") @@ -220,6 +223,9 @@ try: configHandler.checkConfig("FMS") configHandler.checkConfig("ZVEI") configHandler.checkConfig("POC") + configHandler.checkConfig("Plugins") + configHandler.checkConfig("Filters") + #NMAHandler is outputed below except: # we couldn't work without config -> exit logging.critical("cannot read config file") diff --git a/config/config.template.ini b/config/config.template.ini index d943faf..7a959f2 100644 --- a/config/config.template.ini +++ b/config/config.template.ini @@ -1,6 +1,17 @@ -######################## -# BOSWatch Config File # -######################## + +# ____ ____ ______ __ __ __ +# / __ )/ __ \/ ___/ | / /___ _/ /______/ /_ +# / __ / / / /\__ \| | /| / / __ / __/ ___/ __ \ +# / /_/ / /_/ /___/ /| |/ |/ / /_/ / /_/ /__/ / / / +# /_____/\____//____/ |__/|__/\__,_/\__/\___/_/ /_/ +# German BOS Information Script +# configuration file +# +# The intercept of the German BOS radio is strictly +# prohibited and will be prosecuted. +# The use is only authorized personnel permitted! +# + [BOSWatch] # set loglevel for logfile @@ -31,6 +42,7 @@ processAlarmAsync = 0 # Using RegEx-filter (0 - off | 1 - on) # filter-configuration in section [Filters] +# if you are using the RegEx filter you must add filter rules to forward alarms useRegExFilter = 0 # for double check save the last n IDs @@ -51,6 +63,7 @@ doubleFilter_check_msg = 0 # writes the multimon-ng raw data stream into a text file named mm_raw.txt writeMultimonRaw = 0 + [NMAHandler] # you can use a logging handler for sending logging records to NotifyMyAndroid # enableHandler (0|1) will enable the NMA handler @@ -79,12 +92,14 @@ idDescribed = 0 # 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 ",") @@ -114,16 +129,17 @@ ricd = Unwetter # 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 +# If RegEX is enabled - only alloewd data will 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) +# 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 +# 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} @@ -148,7 +164,7 @@ Pushover = 0 Telegram = 0 yowsup = 0 -# for developing template-module +# for developing - template-module template = 0 @@ -171,36 +187,18 @@ tableSIG = bos_signal # multiple URLs can be separated by comma -# you can use the following wildcards in your URL as GET params: +# you can use the 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) +#Wildcards can be used, see end of the file! #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) +#Wildcards can be used, see end of the file! #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) +#Wildcards can be used, see end of the file! #poc_url = http://www.google.de?ric=%RIC%&subric=%FUNC%&msg=%MSG% poc_url = @@ -225,42 +223,15 @@ to = user@irgendwo, user2@woanders # 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% = ) +#Wildcards can be used, see end of the file! 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% = ) +#Wildcards can be used, see end of the file! 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% = ) +#Wildcards can be used, see end of the file! poc_subject = Alarm: %RIC%%LPAR%%FUNCCHAR%%RPAR% poc_message = %DATE% %TIME% - %DESCR%: %MSG% @@ -415,36 +386,13 @@ RICforLocationAPIKey = # Required if you want to create a map based on location information received with the above RIC. GoogleAPIKey = -# %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% = ) +#Wildcards can be used, see end of the file! 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% = ) +#Wildcards can be used, see end of the file! 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% = ) +#Wildcards can be used, see end of the file! POC_message = %MSG% @@ -456,36 +404,13 @@ 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% = ) +#Wildcards can be used, see end of the file! 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% = ) +#Wildcards can be used, see end of the file! 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% = ) +#Wildcards can be used, see end of the file! poc_message = %MSG% @@ -496,3 +421,43 @@ poc_message = %MSG% [template] test1 = testString test2 = 123456 + + +##################### +##### WILDCARDS ##### +##################### + +##### FMS +# %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% = ) + +##### ZVEI +# %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% = ) + +##### POCSAG +# %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) +# %BR% = Insert line wrap (only in message) +# %LPAR% = ( +# %RPAR% = ) diff --git a/csv/poc.template.csv b/csv/poc.template.csv index 87a5073..9dfe7d4 100644 --- a/csv/poc.template.csv +++ b/csv/poc.template.csv @@ -5,6 +5,12 @@ ric,description # For each RIC-Address you could set a description-text # Use the structure: ric,"Description-Text" # +# You can even define specific subrics, therefore you +# 1. need to specify a main RIC: 1234567, "Unit One" +# 2. specify a certain subric: 1234567B, "Subunit Bravo" +# The result for 1234567B will be "Unit One Subunit Bravo" +# - Be sure having defined the main RIC (step one)! - +# # !!! DO NOT delete the first line !!! # 1234567,"POCSAG testdata äöüß" diff --git a/includes/globalVars.py b/includes/globalVars.py index 3b34dcd..be4305d 100644 --- a/includes/globalVars.py +++ b/includes/globalVars.py @@ -9,8 +9,9 @@ Global variables """ # version info -versionNr = "2.2.1" -buildDate = "2017/09/19" +versionNr = "2.2.2" +branch = "dev" +buildDate = "unreleased" # Global variables diff --git a/includes/helper/stringConverter.py b/includes/helper/stringConverter.py index 01ada06..acd9a26 100644 --- a/includes/helper/stringConverter.py +++ b/includes/helper/stringConverter.py @@ -159,7 +159,6 @@ def convertToUTF8(inputString = ""): raise # End of exception UnicodeDecodeError: check given string is already UTF-8 - pass except: logging.warning("error checking given string") diff --git a/includes/pynma/pynma.py b/includes/pynma/pynma.py index 08a71cb..5649f05 100644 --- a/includes/pynma/pynma.py +++ b/includes/pynma/pynma.py @@ -3,14 +3,14 @@ from xml.dom.minidom import parseString try: - from http.client import HTTPSConnection + from http.client import HTTPSConnection except ImportError: - from httplib import HTTPSConnection + from httplib import HTTPSConnection try: - from urllib.parse import urlencode + from urllib.parse import urlencode except ImportError: - from urllib import urlencode + from urllib import urlencode __version__ = "1.0" @@ -55,10 +55,10 @@ takes 2 optional arguments: def delkey(self, key): "Removes a key (unregister ?)" - if type(key) == str: + if isinstance(key, str): if key in self._apikey: self._apikey.remove(key) - elif type(key) == list: + elif isinstance(key, list): for k in key: if key in self._apikey: self._apikey.remove(k) @@ -71,7 +71,7 @@ takes 2 optional arguments: def pushWithAPIKey(self, apikey=[], application="", event="", description="", url="", contenttype=None, priority=0, batch_mode=False, html=False): """Special Funktion""" if apikey: - if type(apikey) == str: + if isinstance(apikey, str): apikey = [apikey] self._apikey = uniq(apikey) return self.push(application, event, description, url, contenttype, priority, batch_mode, html) diff --git a/includes/shellHeader.py b/includes/shellHeader.py index 561603a..ab82eae 100644 --- a/includes/shellHeader.py +++ b/includes/shellHeader.py @@ -31,6 +31,7 @@ def printHeader(args): print " by Bastian Schroll, Jens Herrmann " print "" print "SW Version: "+globalVars.versionNr + print "Branch: "+globalVars.branch print "Build Date: "+globalVars.buildDate print "" diff --git a/install.sh b/install.sh index 5c251ea..3fc8140 100644 --- a/install.sh +++ b/install.sh @@ -12,7 +12,7 @@ function exitcodefunction { 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 " -> 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 @@ -51,7 +51,7 @@ didBackup=false 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 @@ -61,7 +61,7 @@ fi 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 @@ -82,7 +82,7 @@ for (( i=1; i<=$#; i=$i+2 )); do *) branch=master ;; esac ;; - -p|--path) echo " !!! WARNING: you install BOSWATCH to alternative path !!! "; boswatchpath=$arg2 ;; + -p|--path) echo " !!! WARNING: you'll install BOSWATCH to alternative path !!! "; boswatchpath=$arg2 ;; *) echo "Internal error!" ; exit 1 ;; esac @@ -205,16 +205,15 @@ tput cup 15 5 echo "-> configure..........................." cd $boswatchpath/ chmod +x * -echo $'# BOSWatch - blacklist the DVB drivers to avoid conflict with the SDR driver\n blacklist dvb_usb_rtl28xxu \n blacklist rtl2830\n blacklist dvb_usb_v2\n blacklist dvb_core' >> /etc/modprobe.d/boswatch_blacklist_sdr.conf +echo $'# BOSWatch - blacklist the DVB drivers to avoid conflicts with the SDR driver\n blacklist dvb_usb_rtl28xxu \n blacklist rtl2830\n blacklist dvb_usb_v2\n blacklist dvb_core' >> /etc/modprobe.d/boswatch_blacklist_sdr.conf tput cup 17 1 echo "BOSWatch is now installed in $boswatchpath/" echo "Installation ready!" tput cup 19 3 -echo "Watch out: to run BOSWatch you have to generate and modify the config.ini!" -echo "Do the following steps to have a running version of BOSWatch:" -echo "sudo cp $boswatchpath/BOSWatch/config/config.template.ini $boswatchpath/BOSWatch/config/config.ini" -echo "sudo nano $boswatchpath/BOSWatch/config/config.ini" +echo "Watch out: to run BOSWatch you have to modify the config.ini!" +echo "Do the following step to do so:" +echo "sudo nano $boswatchpath/config/config.ini" echo "and modify the config as you need. This step is optional if you are upgrading an old version of BOSWatch. " tput cnorm diff --git a/plugins/MySQL/MySQL.py b/plugins/MySQL/MySQL.py index 5941571..e9d3d7e 100644 --- a/plugins/MySQL/MySQL.py +++ b/plugins/MySQL/MySQL.py @@ -21,23 +21,23 @@ from includes import globalVars # Global variables from includes.helper import configHandler def isSignal(poc_id): - """ - @type poc_id: string - @param poc_id: POCSAG Ric + """ + @type poc_id: string + @param poc_id: POCSAG Ric - @requires: Configuration has to be set in the config.ini + @requires: Configuration has to be set in the config.ini - @return: True if the Ric is Signal, other False - @exception: none - """ - # If RIC is Signal return True, else False - if globalVars.config.get("POC", "netIdent_ric"): - if poc_id in globalVars.config.get("POC", "netIdent_ric"): - logging.info("RIC %s is net ident", poc_id) - return True - else: - logging.info("RIC %s is no net ident", poc_id) - return False + @return: True if the Ric is Signal, other False + @exception: none + """ + # If RIC is Signal return True, else False + if globalVars.config.get("POC", "netIdent_ric"): + if poc_id in globalVars.config.get("POC", "netIdent_ric"): + logging.info("RIC %s is net ident", poc_id) + return True + else: + logging.info("RIC %s is no net ident", poc_id) + return False ## @@ -87,7 +87,7 @@ def run(typ,freq,data): if configHandler.checkConfig("MySQL"): #read and debug the config try: - # + # # Connect to MySQL # logging.debug("connect to MySQL") diff --git a/plugins/Sms77/Sms77.py b/plugins/Sms77/Sms77.py index e4353d1..6d30a1a 100644 --- a/plugins/Sms77/Sms77.py +++ b/plugins/Sms77/Sms77.py @@ -58,7 +58,7 @@ def run(typ,freq,data): """ try: if configHandler.checkConfig("Sms77"): #read and debug the config - + # create an empty message an fill it with the required information message = "Alarm" if typ == "FMS": diff --git a/plugins/Telegram/Telegram.py b/plugins/Telegram/Telegram.py index fc4acc7..dc4cc6e 100644 --- a/plugins/Telegram/Telegram.py +++ b/plugins/Telegram/Telegram.py @@ -11,9 +11,11 @@ Plugin to send FMS-, ZVEI- and POCSAG-messages via Telegram # Imports # import logging # Global logger -import urllib, telegram, googlemaps +import telegram from telegram.error import (TelegramError, Unauthorized, BadRequest, NetworkError) from includes import globalVars # Global variables +if globalVars.config.get("Telegram","RICforLocationAPIKey"): + import urllib, googlemaps # Helper function, uncomment to use from includes.helper import wildcardHandler diff --git a/plugins/httpRequest/httpRequest.py b/plugins/httpRequest/httpRequest.py index 744f621..56e35a6 100644 --- a/plugins/httpRequest/httpRequest.py +++ b/plugins/httpRequest/httpRequest.py @@ -71,8 +71,8 @@ def run(typ,freq,data): # Replace special characters in data Strings for URL # for key in data: - if isinstance(data[key], basestring): - data[key] = urllib.quote(data[key]) + if isinstance(data[key], basestring): + data[key] = urllib.quote(data[key]) # # Get URLs # diff --git a/plugins/notifyMyAndroid/notifyMyAndroid.py b/plugins/notifyMyAndroid/notifyMyAndroid.py index 7fa535f..a8ab127 100644 --- a/plugins/notifyMyAndroid/notifyMyAndroid.py +++ b/plugins/notifyMyAndroid/notifyMyAndroid.py @@ -268,23 +268,23 @@ def run(typ,freq,data): # nothing found pass # 3. lets look for ric prefixes in pocAPIKeyList - for prefixLength in reversed(range(6)): - ricPrefix = data['ric'][:prefixLength] - #fill the ric with stars - ricPrefix = ricPrefix.ljust(8,'*') - try: - xID = ricPrefix - # data structure: pocAPIKeyList[xID][i] = (xAPIKey, xPriority, xEventPrefix) - for i in range(len(pocAPIKeyList[xID])): - xEvent = event - (xAPIKey, xPriority, xEventPrefix) = pocAPIKeyList[xID][i] - if len(xEventPrefix) > 0: - xEvent = xEventPrefix + ": " + xEvent - response = nma.pushWithAPIKey(xAPIKey, application, xEvent, msg, priority=xPriority) - checkResponse(response, xAPIKey) - except KeyError: - # nothing found - pass + for prefixLength in reversed(range(6)): + ricPrefix = data['ric'][:prefixLength] + #fill the ric with stars + ricPrefix = ricPrefix.ljust(8,'*') + try: + xID = ricPrefix + # data structure: pocAPIKeyList[xID][i] = (xAPIKey, xPriority, xEventPrefix) + for i in range(len(pocAPIKeyList[xID])): + xEvent = event + (xAPIKey, xPriority, xEventPrefix) = pocAPIKeyList[xID][i] + if len(xEventPrefix) > 0: + xEvent = xEventPrefix + ": " + xEvent + response = nma.pushWithAPIKey(xAPIKey, application, xEvent, msg, priority=xPriority) + checkResponse(response, xAPIKey) + except KeyError: + # nothing found + pass # end if "POC" in typ # end if usecsv == True diff --git a/service/README.md b/service/README.md index 41337a9..805ef88 100644 --- a/service/README.md +++ b/service/README.md @@ -8,10 +8,14 @@ We assume that BOSWatch is installed to /opt/boswatch! Otherwise you need to ada Enter the frequency and the decoder(s) you want to use in line 7; you can add more specific switches if you need to ### Install the service -1. Copy the file to /lib/systemd/system: sudo cp /opt/boswatch/service/boswatch.service /lib/systemd/system/ -2. Change the rights: sudo chmod 644 /lib/systemd/system/boswatch.service -3. Enable the service: sudo systemcl enable boswatch.service -4. Start the service: sudo systemcl start boswatch.service +1. Use the install-script install_service.sh as sudo: `sudo bash install_service.sh` (self explaining) + +OR + +1. Copy the file to /etc/systemd/system: sudo cp /opt/boswatch/service/boswatch.service /etc/systemd/system/ +2. Enable the service: sudo systemctl enable boswatch.service +3. Start the service: sudo systemctl start boswatch.service +4. Check the status: sudo systemctl status boswatch.service --- diff --git a/service/install_service.sh b/service/install_service.sh new file mode 100644 index 0000000..2789a35 --- /dev/null +++ b/service/install_service.sh @@ -0,0 +1,51 @@ +#!/bin/bash + +# Tiny script to install BOSWatch-service via systemctl +# Just a few simple steps are required to (un)register your service + +if [[ $EUID -ne 0 ]]; then + echo "This script must be run as root!" 1>&2 + exit 1 +fi + +read -p"Do you want to install (i) or remove (r) the service? " action + +if [ "$action" == "i" ]; then + + # 1 Check whether the right data are in the service-file + + read -p"Did you adapt the file boswatch.service (y/n)? " response + + if [ "$response" == "y" ]; then + # 2 Copy the file + cp boswatch.service /etc/systemd/system + + # 3 Enable the service and check status + systemctl enable boswatch.service + systemctl is-enabled boswatch.service + + # 4 fire it up + systemctl start boswatch.service + + # 5 post the status + systemctl status boswatch.service + elif [ "$response" == "n" ]; then + echo "Please adapt your personal boswatch.service-file" + exit 1 + else + echo "Invalid input - please try again" + exit 1 + fi +elif [ "$action" == "r" ]; then # we want to remove the service + # stop it... + systemctl stop boswatch.service + + # disable it + systemctl disable boswatch.service + + # and remove it + rm /etc/systemd/system/boswatch.service +else # error handling + echo "Invalid input - please try again" + exit 1 +fi