From 078b23085c63af32a3def70039c692588e1f7e0b Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Mon, 20 Feb 2017 09:51:33 +0100 Subject: [PATCH 1/9] test issue template --- .github/ISSUE_TEMPLATE.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE.md diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..f96c01f --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,6 @@ +Falls ein Bug vorliegt, bitte unten angeführte Felder ausfüllen. + +- **BOSWatch Version** +- **Genutzter Branch** +- **Kurze Fehlerbeschreibung** +- **Logfile** From f3ba034420d19e5eea7c36d5f9e729349691b844 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Mon, 20 Feb 2017 09:59:30 +0100 Subject: [PATCH 2/9] edit Issue template --- .github/ISSUE_TEMPLATE.md | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index f96c01f..0c5fe05 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,6 +1,11 @@ -Falls ein Bug vorliegt, bitte unten angeführte Felder ausfüllen. +Bei Fragen und Problemen zu BOSWatch oder Plugins bitte unten gennante Informationen angeben: -- **BOSWatch Version** -- **Genutzter Branch** -- **Kurze Fehlerbeschreibung** -- **Logfile** +- **BOSWatch Version + Branch** + +- **genutzte Plugins** + +- **Fehlerbeschreibung** + +- **Logfile (Auszug)** + +- **ggf. Config File (Auszug)** From 751711b702c53d44727941bd789dd7803b8b4a6e Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Mon, 20 Feb 2017 21:17:55 +0100 Subject: [PATCH 3/9] cherrypick travis-ci files to master --- .travis.yml | 28 ++ README.md | 8 +- citest/config.httpRequest.ini | 463 ++++++++++++++++++++++++++++++ citest/config.mysql.ini | 463 ++++++++++++++++++++++++++++++ citest/test.sh | 78 +++++ install.sh | 9 +- plugins/MySQL/boswatch-update.sql | 5 + plugins/MySQL/boswatch.sql | 4 +- 8 files changed, 1049 insertions(+), 9 deletions(-) create mode 100644 .travis.yml create mode 100644 citest/config.httpRequest.ini create mode 100644 citest/config.mysql.ini create mode 100644 citest/test.sh create mode 100644 plugins/MySQL/boswatch-update.sql diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..2a7b632 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,28 @@ +language: bash + +sudo: required + +branches: + only: + - master + - develop + +before_script: + - sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu trusty universe" + - 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 + - chmod +x install.sh + - cat /etc/os-release + - echo ${TRAVIS_BRANCH} + - sudo ./install.sh -b ${TRAVIS_BRANCH} -r no + +env: + - module=bash + - module=mysql + - module=httpRequest + +script: + - sudo /bin/bash citest/test.sh diff --git a/README.md b/README.md index 6fd9ff4..cdc2172 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ **Codacy - static code analysis:** -|branch|quality| -|---|---| -|master-branch|[![Codacy Badge](https://img.shields.io/codacy/grade/d512976554354a199555bd34ed179bb1/master.svg)](https://www.codacy.com/app/Schrolli91/BOSWatch/dashboard?bid=3763821)| -|develop-branch|[![Codacy Badge](https://img.shields.io/codacy/grade/d512976554354a199555bd34ed179bb1/develop.svg)](https://www.codacy.com/app/Schrolli91/BOSWatch/dashboard?bid=3763820)| +|branch|quality|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)| **Achtung:** Die readme ist veraltet - Neue Informationen werden im Laufe der Zeit in das Github Wiki integriert! diff --git a/citest/config.httpRequest.ini b/citest/config.httpRequest.ini new file mode 100644 index 0000000..bfa08ec --- /dev/null +++ b/citest/config.httpRequest.ini @@ -0,0 +1,463 @@ +######################## +# 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 = 1 +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 = root +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/citest/config.mysql.ini b/citest/config.mysql.ini new file mode 100644 index 0000000..7766f77 --- /dev/null +++ b/citest/config.mysql.ini @@ -0,0 +1,463 @@ +######################## +# 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 = 1 +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/citest/test.sh b/citest/test.sh new file mode 100644 index 0000000..2e3d21e --- /dev/null +++ b/citest/test.sh @@ -0,0 +1,78 @@ +#!/bin/bash +bospath=/opt/boswatch/ +echo $module +# ---------------------------------------------------------------------------------------------------------------------------------- +# base Tests +# ---------------------------------------------------------------------------------------------------------------------------------- +if [ $module == "base" ]; then + cp $bospath/config/config.template.ini $bospath/config/config.ini + sudo /usr/bin/python $bospath/boswatch.py -f 1 -d 0 -e 10 -a POC512 POC1200 POC2400 -v -t + + sudo chmod 777 $bospath/log/boswatch.log + if grep -Fxq '\[ERROR' "$bospath/log/boswatch.log" + then + echo "Found Error in boswatch.log" + exit 1 + fi + + +# ---------------------------------------------------------------------------------------------------------------------------------- +# mysql Tests +# ---------------------------------------------------------------------------------------------------------------------------------- +elif [ $module == "mysql" ]; then + sudo cp citest/config.mysql.ini $bospath/config/config.ini + export DEBIAN_FRONTEND=noninteractive + sudo -E apt-get -q -y install mysql-server + sudo service mysql start + + sudo mysql -e "create database boswatch;" + sudo mysql -e "\. plugins/MySQL/boswatch.sql" + #sudo mysql boswatch < plugins/MySQL/boswatch.sql + + sudo /usr/bin/python $bospath/boswatch.py -f 1 -d 0 -e 10 -a POC512 POC1200 POC2400 -v -t + sudo chmod 777 $bospath/log/boswatch.log + + if grep -Fxq '\[ERROR' "$bospath/log/boswatch.log" + then + echo "Found Error in boswatch.log" + exit 1 + fi + + fms=$(mysql -s -N -u boswatch -proot boswatch -e "SELECT COUNT(*) FROM bos_fms;") + mysql -s -N -u boswatch -proot boswatch -e "SELECT COUNT(*) FROM bos_fms;" + if [ "$fms" == "0" ]; then + echo "FMS Table emtpy" + exit 1 + fi + + + zvei=$(mysql -s -N -u boswatch -proot boswatch -e "SELECT COUNT(*) FROM bos_zvei;") + mysql -s -N -u boswatch -proot boswatch -e "SELECT COUNT(*) FROM bos_zvei;" + if [ "$zvei" == "0" ]; then + echo "ZVEI Table emtpy" + exit 1 + fi + + + pocsag=$(mysql -s -N -u boswatch -proot boswatch -e "SELECT COUNT(*) FROM bos_pocsag;") + mysql -s -N -u boswatch -proot boswatch -e "SELECT COUNT(*) FROM bos_pocsag;" + if [ "$pocsag" == "0" ]; then + echo "POCSAG Table emtpy" + exit 1 + fi + + +# ---------------------------------------------------------------------------------------------------------------------------------- +# httpRequest Tests +# ---------------------------------------------------------------------------------------------------------------------------------- +elif [ $module == "httpRequest" ]; then + sudo cp citest/config.httpRequest.ini $bospath/config/config.ini + sudo /usr/bin/python $bospath/boswatch.py -f 1 -d 0 -e 10 -a POC512 POC1200 POC2400 -v -t + + sudo chmod 777 $bospath/log/boswatch.log + if grep -Fxq '\[ERROR' "$bospath/log/boswatch.log" + then + echo "Found Error in boswatch.log" + exit 1 + fi +fi diff --git a/install.sh b/install.sh index f233d78..d3650a1 100644 --- a/install.sh +++ b/install.sh @@ -33,7 +33,7 @@ for (( i=1; i<=$#; i=$i+2 )); do -b|--branch) case $arg2 in - dev) echo " !!! WARNING: you are using the DEV BRANCH !!! "; branch=dev ;; + dev|develop) echo " !!! WARNING: you are using the DEV BRANCH !!! "; branch=dev ;; *) branch=master ;; esac ;; @@ -116,8 +116,11 @@ echo "-> download BOSWatch..................." cd $boswatchpath/ case $branch in - dev) git clone -b develop https://github.com/Schrolli91/BOSWatch >> $boswatchpath/install/setup_log.txt 2>&1 ;; - *) git clone -b master https://github.com/Schrolli91/BOSWatch >> $boswatchpath/install/setup_log.txt 2>&1 ;; + "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 ;; + *) git clone -b master https://github.com/Schrolli91/BOSWatch >> $boswatchpath/install/setup_log.txt 2>&1 && \ + exitcodefunction $? git-clone BOSWatch ;; esac tput cup 13 15 diff --git a/plugins/MySQL/boswatch-update.sql b/plugins/MySQL/boswatch-update.sql new file mode 100644 index 0000000..68a3dd7 --- /dev/null +++ b/plugins/MySQL/boswatch-update.sql @@ -0,0 +1,5 @@ +USE boswatch; + +-- rename old columns including little error-prevention +ALTER IGNORE TABLE `bos_pocsag` change `funktion` `function` INT(1); +ALTER IGNORE TABLE `bos_pocsag` change `funktionChar` `functionChar` TEXT(1); diff --git a/plugins/MySQL/boswatch.sql b/plugins/MySQL/boswatch.sql index 78e30eb..8a88c68 100644 --- a/plugins/MySQL/boswatch.sql +++ b/plugins/MySQL/boswatch.sql @@ -74,8 +74,8 @@ CREATE TABLE IF NOT EXISTS `bos_pocsag` ( ) ENGINE=MYISAM DEFAULT CHARSET=UTF8 AUTO_INCREMENT=1; -- rename old columns including little error-prevention -ALTER IGNORE TABLE `bos_pocsag` change `funktion` `function` INT(1); -ALTER IGNORE TABLE `bos_pocsag` change `funktionChar` `functionChar` TEXT(1); +#ALTER IGNORE TABLE `bos_pocsag` change `funktion` `function` INT(1); +#ALTER IGNORE TABLE `bos_pocsag` change `funktionChar` `functionChar` TEXT(1); -- -------------------------------------------------------- From ce3f7beabaf734a1100dbcc9ddabad7e775f6e12 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Mon, 20 Feb 2017 21:44:19 +0100 Subject: [PATCH 4/9] update install in master error in travis install --- install.sh | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 67 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index d3650a1..d0ae3c6 100644 --- a/install.sh +++ b/install.sh @@ -1,4 +1,20 @@ #!/bin/bash + +function exitcodefunction { + errorcode=$1 + action=$2 + module=$3 + + if [ $errorcode -ne "0" ]; then + echo "Action: $action on $module failed." + echo "Exitcode: $errorcode" + exit 1 + else + echo "Action: $action on $module ok." + fi + } + + tput clear tput civis echo " ____ ____ ______ __ __ __ " @@ -9,7 +25,14 @@ echo " /_____/\____//____/ |__/|__/\__,_/\__/\___/_/ /_/ " echo " German BOS Information Script " echo " by Bastian Schroll " echo "" -echo "This may take a several minutes... Don't panic!" + +# Make sure only root can run our script +if [[ $EUID -ne 0 ]]; then + echo "This script must be run as root!" 1>&2 + exit 1 +fi + +echo "This may take several minutes... Don't panic!" echo "" 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" @@ -56,13 +79,15 @@ echo "[ 2/10] [##--------]" tput cup 15 5 echo "-> download GIT and other stuff.........." apt-get -y install git cmake build-essential libusb-1.0 qt4-qmake qt4-default libpulse-dev libx11-dev sox >> $boswatchpath/install/setup_log.txt 2>&1 +exitcodefunction $? download stuff tput cup 13 15 echo "[ 3/10] [###-------]" tput cup 15 5 echo "-> download rtl_fm......................" cd $boswatchpath/install -git clone git://git.osmocom.org/rtl-sdr.git >> $boswatchpath/install/setup_log.txt 2>&1 +git clone https://github.com/Schrolli91/rtl-sdr.git >> $boswatchpath/install/setup_log.txt 2>&1 +exitcodefunction $? git-clone rtl-sdr cd rtl-sdr/ tput cup 13 15 @@ -71,16 +96,28 @@ tput cup 15 5 echo "-> compile rtl_fm......................" mkdir -p build && cd build cmake ../ -DINSTALL_UDEV_RULES=ON >> $boswatchpath/install/setup_log.txt 2>&1 +exitcodefunction $? cmake rtl-sdr + make >> $boswatchpath/install/setup_log.txt 2>&1 +exitcodefunction $? make rtl-sdr + make install >> $boswatchpath/install/setup_log.txt 2>&1 +exitcodefunction $? make-install rtl-sdr + ldconfig >> $boswatchpath/install/setup_log.txt 2>&1 +exitcodefunction $? ldconfig rtl-sdr + + tput cup 13 15 echo "[ 5/10] [#####-----]" tput cup 15 5 echo "-> download multimon-ng................" cd $boswatchpath/install -git clone https://github.com/EliasOenal/multimonNG.git >> $boswatchpath/install/setup_log.txt 2>&1 +git clone https://github.com/Schrolli91/multimon-ng.git multimonNG >> $boswatchpath/install/setup_log.txt 2>&1 +exitcodefunction $? git-clone multimonNG + + cd $boswatchpath/install/multimonNG/ tput cup 13 15 @@ -90,8 +127,15 @@ echo "-> compile multimon-ng................." mkdir -p build cd build qmake ../multimon-ng.pro >> $boswatchpath/install/setup_log.txt 2>&1 +exitcodefunction $? qmake multimonNG + make >> $boswatchpath/install/setup_log.txt 2>&1 +exitcodefunction $? make multimonNG + + make install >> $boswatchpath/install/setup_log.txt 2>&1 +exitcodefunction $? qmakeinstall multimonNG + tput cup 13 15 echo "[ 7/10] [#######---]" @@ -99,7 +143,11 @@ tput cup 15 5 echo "-> download MySQL connector for Python." cd $boswatchpath/install wget "http://dev.mysql.com/get/Downloads/Connector-Python/mysql-connector-python-1.0.9.tar.gz/from/http://cdn.mysql.com/" -O mysql-connector.tar >> $boswatchpath/install/setup_log.txt 2>&1 +exitcodefunction $? download mysql-connector + tar xfv mysql-connector.tar >> $boswatchpath/install/setup_log.txt 2>&1 +exitcodefunction $? untar mysql-connector + cd $boswatchpath/install/mysql-connector-python* tput cup 13 15 @@ -108,6 +156,8 @@ tput cup 15 5 echo "-> install MySQL connector for Python.." chmod +x ./setup.py ./setup.py install >> $boswatchpath/install/setup_log.txt 2>&1 +exitcodefunction $? setup mysql-connector + tput cup 13 15 echo "[ 9/10] [#########-]" @@ -134,9 +184,23 @@ echo $'# BOSWatch - blacklist the DVB drivers to avoid conflict with the SDR dri 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 "and modify the config as you need. This step is optional if you are upgrading an old version of BOSWatch. " tput cnorm +# cleanup +mkdir $boswatchpath/log/install -p +mv $boswatchpath/install/setup_log.txt $boswatchpath/log/install/ +rm $boswatchpath/install/ -R + +mv $boswatchpath/BOSWatch/* $boswatchpath/ +rm $boswatchpath/BOSWatch -R + if [ $reboot = "true" ]; then /sbin/reboot fi From 20f9d4215c7c592214afa7a8b5c818c204e83ffb Mon Sep 17 00:00:00 2001 From: Florian Date: Thu, 22 Dec 2016 22:37:06 +0100 Subject: [PATCH 5/9] MySQL.py Adapting to global net-identifiers --- plugins/MySQL/MySQL.py | 274 ++++++++++++++++++++--------------------- 1 file changed, 137 insertions(+), 137 deletions(-) diff --git a/plugins/MySQL/MySQL.py b/plugins/MySQL/MySQL.py index 4afac03..02be083 100644 --- a/plugins/MySQL/MySQL.py +++ b/plugins/MySQL/MySQL.py @@ -1,137 +1,137 @@ -#!/usr/bin/python -# -*- coding: UTF-8 -*- - -""" -MySQL-Plugin to dispatch FMS-, ZVEI- and POCSAG - messages to a MySQL database - -@author: Jens Herrmann -@author: Bastian Schroll - -@requires: MySQL-Configuration has to be set in the config.ini -@requires: Created Database/Tables, see boswatch.sql -""" - -import logging # Global logger - -import mysql -import mysql.connector - -from includes import globalVars # Global variables - -from includes.helper import configHandler - -def isSignal(poc_id): - """ - @type poc_id: string - @param poc_id: POCSAG Ric - - @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("MySQL", "signal_ric"): - if poc_id in globalVars.config.get("MySQL", "signal_ric"): - logging.info("RIC %s is signal", poc_id) - return True - else: - logging.info("RIC %s is not signal", poc_id) - return False - - -## -# -# onLoad (init) function of plugin -# will be called one time by the pluginLoader on start -# -def onLoad(): - """ - While loading the plugins by pluginLoader.loadPlugins() - this onLoad() routine is called one time for initialize the plugin - - @requires: nothing - - @return: nothing - """ - # nothing to do for this plugin - return - - -## -# -# Main function of MySQL-plugin -# will be called by the alarmHandler -# -def run(typ,freq,data): - """ - This function is the implementation of the MySQL-Plugin. - It will store the data to an MySQL database - - The configuration for the MySQL-Connection is set in the config.ini. - For DB- and tablestructure see boswatch.sql - - @type typ: string (FMS|ZVEI|POC) - @param typ: Typ of the dataset for sending to BosMon - @type data: map of data (structure see readme.md in plugin folder) - @param data: Contains the parameter for dispatch to BosMon. - @type freq: string - @keyword freq: frequency is not used in this plugin - - @requires: MySQL-Configuration has to be set in the config.ini - @requires: Created Database/Tables, see boswatch.sql - - @return: nothing - """ - try: - if configHandler.checkConfig("MySQL"): #read and debug the config - - try: - # - # Connect to MySQL - # - logging.debug("connect to MySQL") - connection = mysql.connector.connect(host = globalVars.config.get("MySQL","dbserver"), user = globalVars.config.get("MySQL","dbuser"), passwd = globalVars.config.get("MySQL","dbpassword"), db = globalVars.config.get("MySQL","database"), charset='utf8') - cursor = connection.cursor() - except: - logging.error("cannot connect to MySQL") - logging.debug("cannot connect to MySQL", exc_info=True) - else: # Without connection, plugin couldn't work - try: - # - # Create and execute SQL-statement - # - logging.debug("Insert %s", typ) - - if typ == "FMS": - cursor.execute("INSERT INTO "+globalVars.config.get("MySQL","tableFMS")+" (time, fms, status, direction, directionText, tsi, description) VALUES (FROM_UNIXTIME(%s),%s,%s,%s,%s,%s,%s)", (data["timestamp"], data["fms"], data["status"], data["direction"], data["directionText"], data["tsi"], data["description"])) - - elif typ == "ZVEI": - cursor.execute("INSERT INTO "+globalVars.config.get("MySQL","tableZVEI")+" (time, zvei, description) VALUES (FROM_UNIXTIME(%s),%s,%s)", (data["timestamp"], data["zvei"], data["description"])) - - elif typ == "POC": - if isSignal(data["ric"]): - cursor.execute("UPDATE "+globalVars.config.get("MySQL","tableSIG")+" SET time = NOW() WHERE ric = "+data["ric"]) - if cursor.rowcount == 0: - cursor.execute("INSERT INTO "+globalVars.config.get("MySQL","tableSIG")+" (time,ric) VALUES (NOW(),"+data["ric"]+")") - else: - cursor.execute("INSERT INTO "+globalVars.config.get("MySQL","tablePOC")+" (time, ric, function, functionChar, msg, bitrate, description) VALUES (FROM_UNIXTIME(%s),%s,%s,%s,%s,%s,%s)", (data["timestamp"], data["ric"], data["function"], data["functionChar"], data["msg"], data["bitrate"], data["description"])) - - else: - logging.warning("Invalid Typ: %s", typ) - except: - logging.error("cannot Insert %s", typ) - logging.debug("cannot Insert %s", typ, exc_info=True) - return - - finally: - logging.debug("close MySQL") - try: - cursor.close() - connection.close() #Close connection in every case - except: - pass - - except: - logging.error("unknown error") - logging.debug("unknown error", exc_info=True) +#!/usr/bin/python +# -*- coding: UTF-8 -*- + +""" +MySQL-Plugin to dispatch FMS-, ZVEI- and POCSAG - messages to a MySQL database + +@author: Jens Herrmann +@author: Bastian Schroll + +@requires: MySQL-Configuration has to be set in the config.ini +@requires: Created Database/Tables, see boswatch.sql +""" + +import logging # Global logger + +import mysql +import mysql.connector + +from includes import globalVars # Global variables + +from includes.helper import configHandler + +def isSignal(poc_id): + """ + @type poc_id: string + @param poc_id: POCSAG Ric + + @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 + + +## +# +# onLoad (init) function of plugin +# will be called one time by the pluginLoader on start +# +def onLoad(): + """ + While loading the plugins by pluginLoader.loadPlugins() + this onLoad() routine is called one time for initialize the plugin + + @requires: nothing + + @return: nothing + """ + # nothing to do for this plugin + return + + +## +# +# Main function of MySQL-plugin +# will be called by the alarmHandler +# +def run(typ,freq,data): + """ + This function is the implementation of the MySQL-Plugin. + It will store the data to an MySQL database + + The configuration for the MySQL-Connection is set in the config.ini. + For DB- and tablestructure see boswatch.sql + + @type typ: string (FMS|ZVEI|POC) + @param typ: Typ of the dataset for sending to BosMon + @type data: map of data (structure see readme.md in plugin folder) + @param data: Contains the parameter for dispatch to BosMon. + @type freq: string + @keyword freq: frequency is not used in this plugin + + @requires: MySQL-Configuration has to be set in the config.ini + @requires: Created Database/Tables, see boswatch.sql + + @return: nothing + """ + try: + if configHandler.checkConfig("MySQL"): #read and debug the config + + try: + # + # Connect to MySQL + # + logging.debug("connect to MySQL") + connection = mysql.connector.connect(host = globalVars.config.get("MySQL","dbserver"), user = globalVars.config.get("MySQL","dbuser"), passwd = globalVars.config.get("MySQL","dbpassword"), db = globalVars.config.get("MySQL","database"), charset='utf8') + cursor = connection.cursor() + except: + logging.error("cannot connect to MySQL") + logging.debug("cannot connect to MySQL", exc_info=True) + else: # Without connection, plugin couldn't work + try: + # + # Create and execute SQL-statement + # + logging.debug("Insert %s", typ) + + if typ == "FMS": + cursor.execute("INSERT INTO "+globalVars.config.get("MySQL","tableFMS")+" (time, fms, status, direction, directionText, tsi, description) VALUES (FROM_UNIXTIME(%s),%s,%s,%s,%s,%s,%s)", (data["timestamp"], data["fms"], data["status"], data["direction"], data["directionText"], data["tsi"], data["description"])) + + elif typ == "ZVEI": + cursor.execute("INSERT INTO "+globalVars.config.get("MySQL","tableZVEI")+" (time, zvei, description) VALUES (FROM_UNIXTIME(%s),%s,%s)", (data["timestamp"], data["zvei"], data["description"])) + + elif typ == "POC": + if isSignal(data["ric"]): + cursor.execute("UPDATE "+globalVars.config.get("MySQL","tableSIG")+" SET time = NOW() WHERE ric = "+data["ric"]) + if cursor.rowcount == 0: + cursor.execute("INSERT INTO "+globalVars.config.get("MySQL","tableSIG")+" (time,ric) VALUES (NOW(),"+data["ric"]+")") + else: + cursor.execute("INSERT INTO "+globalVars.config.get("MySQL","tablePOC")+" (time, ric, function, functionChar, msg, bitrate, description) VALUES (FROM_UNIXTIME(%s),%s,%s,%s,%s,%s,%s)", (data["timestamp"], data["ric"], data["function"], data["functionChar"], data["msg"], data["bitrate"], data["description"])) + + else: + logging.warning("Invalid Typ: %s", typ) + except: + logging.error("cannot Insert %s", typ) + logging.debug("cannot Insert %s", typ, exc_info=True) + return + + finally: + logging.debug("close MySQL") + try: + cursor.close() + connection.close() #Close connection in every case + except: + pass + + except: + logging.error("unknown error") + logging.debug("unknown error", exc_info=True) From 3ef489c75958132d485d690bc418fb7d3c4b97b1 Mon Sep 17 00:00:00 2001 From: Florian Date: Tue, 21 Feb 2017 00:09:37 +0100 Subject: [PATCH 6/9] Update README.md Call for help due to encrypted messages --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cdc2172..d12a810 100644 --- a/README.md +++ b/README.md @@ -5,10 +5,12 @@ |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)| -**Achtung:** Die readme ist veraltet - Neue Informationen werden im Laufe der Zeit in das Github Wiki integriert! +**Unterstützung gesucht** -**Attention:** This readme is outdated - New informations will be integrated in the Github Wiki! +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! ![# BOSWatch](/boswatch.png) From a5b4d96be72de1bcddcbfa8045c8788f22a35980 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Tue, 21 Feb 2017 16:45:45 +0100 Subject: [PATCH 7/9] installer - error handling into logfile --- install.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index d0ae3c6..5e8092b 100644 --- a/install.sh +++ b/install.sh @@ -6,11 +6,13 @@ function exitcodefunction { module=$3 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 "Action: $action on $module failed." echo "Exitcode: $errorcode" exit 1 else - echo "Action: $action on $module ok." + echo "Action: $action on $module ok." >> $boswatchpath/install/setup_log.txt fi } From 9adb5b42b78322b1bb3da7a4389c8802c7c37a09 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Thu, 23 Feb 2017 10:54:35 +0100 Subject: [PATCH 8/9] Added 'sudo systemctl daemon-reload' Before doing that, the system always complains a 'file not found' for the boswatch.sh, although it's present. --- service/README.md | 1 + 1 file changed, 1 insertion(+) 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`. From 3427673199ad4613f26f953f7c5c5a0339ddb534 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Thu, 23 Feb 2017 10:56:14 +0100 Subject: [PATCH 9/9] Changed DIR-variable... ...to default path used by install.sh --- service/boswatch.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/service/boswatch.sh b/service/boswatch.sh index bbfacba..1779e1b 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/BOSWatch DAEMON=$DIR/boswatch.py DAEMON_NAME=boswatch