From 86815d11ce47b082a5c73c2058289a99b21e68a8 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Sat, 16 May 2015 08:31:02 +0200 Subject: [PATCH 1/7] edit install script --- install.sh | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/install.sh b/install.sh index 4eb6c7a..dbcac0b 100644 --- a/install.sh +++ b/install.sh @@ -14,26 +14,26 @@ echo "" echo "Caution, script don't install a Webserver with PHP and MySQL" echo "So you have to make up manually if you want to use MySQL support" -mkdir -p ~/bos/install +mkdir -p ~/boswatch/install tput cup 13 15 echo "[ 1/10] [#---------]" tput cup 15 5 echo "-> make a apt-get update................" -apt-get update -y > ~/bos/install/setup_log.txt 2>&1 +apt-get update -y > ~/boswatch/install/setup_log.txt 2>&1 tput cup 13 15 echo "[ 2/10] [##--------]" tput cup 15 5 echo "-> download GIT an other stuff.........." -apt-get -y install git cmake build-essential libusb-1.0 qt4-qmake libpulse-dev libx11-dev sox >> ~/bos/install/setup_log.txt 2>&1 +apt-get -y install git cmake build-essential libusb-1.0 qt4-qmake libpulse-dev libx11-dev sox >> ~/boswatch/install/setup_log.txt 2>&1 tput cup 13 15 echo "[ 3/10] [###-------]" tput cup 15 5 echo "-> download rtl_fm......................" -cd ~/bos/install -git clone git://git.osmocom.org/rtl-sdr.git >> ~/bos/install/setup_log.txt 2>&1 +cd ~/boswatch/install +git clone git://git.osmocom.org/rtl-sdr.git >> ~/boswatch/install/setup_log.txt 2>&1 cd rtl-sdr/ tput cup 13 15 @@ -41,17 +41,17 @@ echo "[ 4/10] [####------]" tput cup 15 5 echo "-> compile rtl_fm......................" mkdir -p build && cd build -cmake ../ -DINSTALL_UDEV_RULES=ON >> ~/bos/install/setup_log.txt 2>&1 -make >> ~/bos/install/setup_log.txt 2>&1 -make install >> ~/bos/install/setup_log.txt 2>&1 -ldconfig >> ~/bos/install/setup_log.txt 2>&1 +cmake ../ -DINSTALL_UDEV_RULES=ON >> ~/boswatch/install/setup_log.txt 2>&1 +make >> ~/boswatch/install/setup_log.txt 2>&1 +make install >> ~/boswatch/install/setup_log.txt 2>&1 +ldconfig >> ~/boswatch/install/setup_log.txt 2>&1 tput cup 13 15 echo "[ 5/10] [#####-----]" tput cup 15 5 echo "-> download multimon-ng................" -cd ~/bos/install -git clone https://github.com/EliasOenal/multimonNG.git >> ~/bos/install/setup_log.txt 2>&1 +cd ~/boswatch/install +git clone https://github.com/EliasOenal/multimonNG.git >> ~/boswatch/install/setup_log.txt 2>&1 cd multimonNG/ tput cup 13 15 @@ -60,17 +60,17 @@ tput cup 15 5 echo "-> compile multimon-ng................." mkdir -p build cd build -qmake ../multimon-ng.pro >> ~/bos/install/setup_log.txt 2>&1 -make >> ~/bos/install/setup_log.txt 2>&1 -make install >> ~/bos/install/setup_log.txt 2>&1 +qmake ../multimon-ng.pro >> ~/boswatch/install/setup_log.txt 2>&1 +make >> ~/boswatch/install/setup_log.txt 2>&1 +make install >> ~/boswatch/install/setup_log.txt 2>&1 tput cup 13 15 echo "[ 7/10] [#######---]" tput cup 15 5 echo "-> download MySQL Connector for Python." -cd ~/bos/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 >> ~/bos/install/setup_log.txt 2>&1 -tar xfv mysql-connector.tar >> ~/bos/install/setup_log.txt 2>&1 +cd ~/boswatch/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 >> ~/boswatch/install/setup_log.txt 2>&1 +tar xfv mysql-connector.tar >> ~/boswatch/install/setup_log.txt 2>&1 cd mysql-connector-python* tput cup 13 15 @@ -78,23 +78,23 @@ echo "[ 8/10] [########--]" tput cup 15 5 echo "-> install MySQL Connector for Python.." chmod +x ./setup.py -./setup.py install >> ~/bos/install/setup_log.txt 2>&1 +./setup.py install >> ~/boswatch/install/setup_log.txt 2>&1 tput cup 13 15 echo "[ 9/10] [#########-]" tput cup 15 5 echo "-> download BOSWatch..................." -cd ~/bos -git clone https://github.com/Schrolli91/BOSWatch >> ~/bos/install/setup_log.txt 2>&1 +cd ~/boswatch +git clone https://github.com/Schrolli91/BOSWatch >> ~/boswatch/install/setup_log.txt 2>&1 tput cup 13 15 echo "[10/10] [##########]" tput cup 15 5 echo "-> configure..........................." -cd BOSWatch +cd ~/boswatch chmod +x * -echo "# 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 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 tput cup 17 1 -echo "BOSWatch are now in ~/bos/BOSWatch/" +echo "BOSWatch are now installed in ~/boswatch/" echo "Install ready!" \ No newline at end of file From 233b54484dbb887ed8763222265662ea781714d0 Mon Sep 17 00:00:00 2001 From: Schrolli91 Date: Sat, 16 May 2015 08:41:23 +0200 Subject: [PATCH 2/7] Update README.md --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 868b628..e3b169f 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ unless you are developer you can use the develop-Branch - may be unstable! - extensive filtering options - 2400 support (need RAW data from multimon-ng) - automatic Audio recording at alarm +- E-Mail Notification - Web Frontend with Overview and configuration ### Configuration @@ -80,7 +81,8 @@ You can easy install BOSWatch with the install.sh Script. - And use the script `sudo sh install.sh` Now the script downloads and compile all needed data. -At the end you can find BOSWatch in `~/bos/BOSWatch/` +At the end you can find BOSWatch in `~/boswatch/` +In case of an Error during the Installation, check the Logfile in `~/boswatch/install/setup_log.txt` 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. @@ -88,6 +90,7 @@ So you have to make up manually if you want to use MySQL support. ### Requirements - RTL_SDR (rtl_fm) - Multimon-NG +- Python Support - MySQL Connector for Python ##### optional From 3134b2d4746404b142eb3ca2dc67964fc7fcbb36 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Sat, 16 May 2015 18:15:44 +0200 Subject: [PATCH 3/7] HTTP request - seperate url for each function --- boswatch.py | 18 ++++++++++-------- config/config.ini | 4 +++- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/boswatch.py b/boswatch.py index a953454..78154c5 100644 --- a/boswatch.py +++ b/boswatch.py @@ -167,7 +167,9 @@ try: #HTTPrequest config useHTTPrequest = int(config.get("Module", "useHTTPrequest")) #use HTTPrequest support? if useHTTPrequest: #only if HTTPrequest is active - url = config.get("HTTPrequest", "url") + url_fms = config.get("HTTPrequest", "url_fms") + url_zvei = config.get("HTTPrequest", "url_zvei") + url_poc = config.get("HTTPrequest", "url_poc") except: log("cannot read config file","error") @@ -272,7 +274,7 @@ try: if useHTTPrequest: #only if HTTPrequest is active log("FMS to HTTP") try: - httprequest = httplib.HTTPConnection(url) + httprequest = httplib.HTTPConnection(url_fms) httprequest.request("HEAD", "/") httpresponse = httprequest.getresponse() if str(httpresponse.status) == "200": #Check HTTP Response an print a Log or Error @@ -318,7 +320,7 @@ try: if useHTTPrequest: #only if HTTPrequest is active log("ZVEI to HTTP") try: - httprequest = httplib.HTTPConnection(url) + httprequest = httplib.HTTPConnection(url_zvei) httprequest.request("HEAD", "/") httpresponse = httprequest.getresponse() if str(httpresponse.status) == "200": #Check HTTP Response an print a Log or Error @@ -330,7 +332,7 @@ try: else: log("No valid ZVEI: "+zvei_id) - + #POCSAG512 Decoder Section #check POCSAG512: -> validate -> check double alarm -> log -> (MySQL) #POCSAG512: Address: 1234567 Function: 1 Alpha: XXMSG MEfeweffsjh @@ -371,7 +373,7 @@ try: if useHTTPrequest: #only if HTTPrequest is active log("POC512 to HTTP") try: - httprequest = httplib.HTTPConnection(url) + httprequest = httplib.HTTPConnection(url_poc) httprequest.request("HEAD", "/") httpresponse = httprequest.getresponse() if str(httpresponse.status) == "200": #Check HTTP Response an print a Log or Error @@ -386,8 +388,8 @@ try: log("POCSAG512: "+poc_id+" out of filter range") else: log("No valid POCSAG512: "+poc_id) - - + + #POCSAG1200 Decoder Section #check POCSAG1200: -> validate -> check double alarm -> log -> (MySQL) #POCSAG1200: Address: 1234567 Function: 1 Alpha: XXMSG MEfeweffsjh @@ -428,7 +430,7 @@ try: if useHTTPrequest: #only if HTTPrequest is active log("POC1200 to HTTP") try: - httprequest = httplib.HTTPConnection(url) + httprequest = httplib.HTTPConnection(url_poc) httprequest.request("HEAD", "/") httpresponse = httprequest.getresponse() if str(httpresponse.status) == "200": #Check HTTP Response an print a Log or Error diff --git a/config/config.ini b/config/config.ini index 81c8343..9b1a80d 100644 --- a/config/config.ini +++ b/config/config.ini @@ -35,4 +35,6 @@ tablePOC = bos_pocsag [HTTPrequest] #url without http:// ! -url = www.google.de +url_fms = www.google.de +url_zvei = www.google.de +url_poc = www.google.de From d741cf4a8f65991bd6072e4fbbb18ef0e56541d9 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Sat, 16 May 2015 18:19:18 +0200 Subject: [PATCH 4/7] update readme --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index e3b169f..03949f5 100644 --- a/README.md +++ b/README.md @@ -13,21 +13,21 @@ unless you are developer you can use the develop-Branch - may be unstable! ### Features ##### Implemented Features: -- FMS and ZVEI decoding and Displaying +- FMS, ZVEI and POCSAG decoding and Displaying - Filtering double alarms with adjustable time -- FMS and ZVEI validation (plausibility test) -- MySQL Database Support for FMS and ZVEI +- Data validation (plausibility test) +- MySQL Database Support - simple HTTP request at alarm to URL you want - All configurations in seperate config File - simple Web Frontend with Data Parsing - Logfiles for better Troubleshooting - verbose/quiet Mode for more/none information - POCSAG1200 and POCSAG512 support -- Filtering of POCSAG512 and POCSAG1200 RIC´s (adjustment at config) +- Filtering of POCSAG RIC´s (adjustment at config) ##### Features for the Future: - extensive filtering options -- 2400 support (need RAW data from multimon-ng) +- POCSAG 2400 support (need RAW data from multimon-ng) - automatic Audio recording at alarm - E-Mail Notification - Web Frontend with Overview and configuration From 3c851b54783ff0e7be2c0c75baa076339cefd563 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Sun, 17 May 2015 11:22:16 +0200 Subject: [PATCH 5/7] prepare for plugin system --- modul/__init__.py | 0 modul/http/__init__.py | 0 modul/mysql/__init__.py | 0 3 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 modul/__init__.py create mode 100644 modul/http/__init__.py create mode 100644 modul/mysql/__init__.py diff --git a/modul/__init__.py b/modul/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/modul/http/__init__.py b/modul/http/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/modul/mysql/__init__.py b/modul/mysql/__init__.py new file mode 100644 index 0000000..e69de29 From 0b80ff95a36923478267f43a4070db617bd62391 Mon Sep 17 00:00:00 2001 From: Schrolli Date: Mon, 18 May 2015 08:03:59 +0200 Subject: [PATCH 6/7] prepare for plugin system --- {modul => plugin}/__init__.py | 0 {modul => plugin}/http/__init__.py | 0 modul/mysql/__init__.py => plugin/manager.py | 0 plugin/mysql/__init__.py | 0 plugin/template/__init__.py | 0 plugin/template/template.py | 0 plugin_test.py | 5 +++++ 7 files changed, 5 insertions(+) rename {modul => plugin}/__init__.py (100%) rename {modul => plugin}/http/__init__.py (100%) rename modul/mysql/__init__.py => plugin/manager.py (100%) create mode 100644 plugin/mysql/__init__.py create mode 100644 plugin/template/__init__.py create mode 100644 plugin/template/template.py create mode 100644 plugin_test.py diff --git a/modul/__init__.py b/plugin/__init__.py similarity index 100% rename from modul/__init__.py rename to plugin/__init__.py diff --git a/modul/http/__init__.py b/plugin/http/__init__.py similarity index 100% rename from modul/http/__init__.py rename to plugin/http/__init__.py diff --git a/modul/mysql/__init__.py b/plugin/manager.py similarity index 100% rename from modul/mysql/__init__.py rename to plugin/manager.py diff --git a/plugin/mysql/__init__.py b/plugin/mysql/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/plugin/template/__init__.py b/plugin/template/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/plugin/template/template.py b/plugin/template/template.py new file mode 100644 index 0000000..e69de29 diff --git a/plugin_test.py b/plugin_test.py new file mode 100644 index 0000000..0323673 --- /dev/null +++ b/plugin_test.py @@ -0,0 +1,5 @@ +#!/usr/bin/python +# -*- coding: cp1252 -*- + +import plugin + From 466e017cfbe34ff15a5ae59e352033a42dd3fa72 Mon Sep 17 00:00:00 2001 From: Schrolli Date: Mon, 18 May 2015 09:04:16 +0200 Subject: [PATCH 7/7] simple Plugin System --- plugin/__init__.py | 0 plugin/http/__init__.py | 0 plugin/manager.py | 0 plugin/mysql/__init__.py | 0 plugin/template/__init__.py | 0 plugin/template/template.py | 0 plugin_test.py | 5 ----- plugin_test/plugin_test.py | 13 +++++++++++++ plugin_test/pluginloader.py | 22 ++++++++++++++++++++++ plugin_test/plugins/http/__init__.py | 2 ++ plugin_test/plugins/mysql/__init__.py | 2 ++ plugin_test/plugins/template/__init__.py | 2 ++ 12 files changed, 41 insertions(+), 5 deletions(-) delete mode 100644 plugin/__init__.py delete mode 100644 plugin/http/__init__.py delete mode 100644 plugin/manager.py delete mode 100644 plugin/mysql/__init__.py delete mode 100644 plugin/template/__init__.py delete mode 100644 plugin/template/template.py delete mode 100644 plugin_test.py create mode 100644 plugin_test/plugin_test.py create mode 100644 plugin_test/pluginloader.py create mode 100644 plugin_test/plugins/http/__init__.py create mode 100644 plugin_test/plugins/mysql/__init__.py create mode 100644 plugin_test/plugins/template/__init__.py diff --git a/plugin/__init__.py b/plugin/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/plugin/http/__init__.py b/plugin/http/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/plugin/manager.py b/plugin/manager.py deleted file mode 100644 index e69de29..0000000 diff --git a/plugin/mysql/__init__.py b/plugin/mysql/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/plugin/template/__init__.py b/plugin/template/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/plugin/template/template.py b/plugin/template/template.py deleted file mode 100644 index e69de29..0000000 diff --git a/plugin_test.py b/plugin_test.py deleted file mode 100644 index 0323673..0000000 --- a/plugin_test.py +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/python -# -*- coding: cp1252 -*- - -import plugin - diff --git a/plugin_test/plugin_test.py b/plugin_test/plugin_test.py new file mode 100644 index 0000000..daff263 --- /dev/null +++ b/plugin_test/plugin_test.py @@ -0,0 +1,13 @@ +#!/usr/bin/python +# -*- coding: cp1252 -*- + +import time +import pluginloader + +while True: + time.sleep(1) + print ("Alarm!") + for i in pluginloader.getPlugins(): + print("Loading plugin " + i["name"]) + plugin = pluginloader.loadPlugin(i) + plugin.run() \ No newline at end of file diff --git a/plugin_test/pluginloader.py b/plugin_test/pluginloader.py new file mode 100644 index 0000000..346d5d6 --- /dev/null +++ b/plugin_test/pluginloader.py @@ -0,0 +1,22 @@ +#!/usr/bin/python +# -*- coding: cp1252 -*- + +import imp +import os + +PluginFolder = "./plugins" +MainModule = "__init__" + +def getPlugins(): + plugins = [] + possibleplugins = os.listdir(PluginFolder) + for i in possibleplugins: + location = os.path.join(PluginFolder, i) + if not os.path.isdir(location) or not MainModule + ".py" in os.listdir(location): + continue + info = imp.find_module(MainModule, [location]) + plugins.append({"name": i, "info": info}) + return plugins + +def loadPlugin(plugin): + return imp.load_module(MainModule, *plugin["info"]) \ No newline at end of file diff --git a/plugin_test/plugins/http/__init__.py b/plugin_test/plugins/http/__init__.py new file mode 100644 index 0000000..5f1887e --- /dev/null +++ b/plugin_test/plugins/http/__init__.py @@ -0,0 +1,2 @@ +def run(): + print("throw HTTP Plugin") \ No newline at end of file diff --git a/plugin_test/plugins/mysql/__init__.py b/plugin_test/plugins/mysql/__init__.py new file mode 100644 index 0000000..c61db52 --- /dev/null +++ b/plugin_test/plugins/mysql/__init__.py @@ -0,0 +1,2 @@ +def run(): + print("Throw MySql Plugin") \ No newline at end of file diff --git a/plugin_test/plugins/template/__init__.py b/plugin_test/plugins/template/__init__.py new file mode 100644 index 0000000..1f27ab2 --- /dev/null +++ b/plugin_test/plugins/template/__init__.py @@ -0,0 +1,2 @@ +def run(): + print("Throw template Plugin") \ No newline at end of file