diff --git a/back/pialert.py b/back/pialert.py index 80611dfa..781b1032 100644 --- a/back/pialert.py +++ b/back/pialert.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # #------------------------------------------------------------------------------- -# Pi.Alert v2.61 / 2021-01-25 +# Pi.Alert v2.70 / 2021-02-01 # Open Source Network Guard / WIFI & LAN intrusion detector # # pialert.py - Back module. Network scanner @@ -398,6 +398,10 @@ def scan_network (): print (' Updating Devices Info...') update_devices_data_from_scan () + # Resolve devices names + print_log (' Resolve devices names...') + update_devices_names() + # Void false connection - disconnections print (' Voiding false (ghost) disconnections...') void_ghost_disconnections () @@ -905,6 +909,78 @@ def update_devices_data_from_scan (): print_log ('Update devices end') +#------------------------------------------------------------------------------- +# Feature #43 - Resoltion name for unknown devices +def update_devices_names (): + # Initialize variables + recordsToUpdate = [] + ignored = 0 + notFound = 0 + + # Devices without name + print (' Trying to resolve devices without name...', end='') + for device in sql.execute ("SELECT * FROM Devices WHERE dev_Name IN ('(unknown)','') ") : + # Resolve device name + newName = resolve_device_name (device['dev_MAC'], device['dev_LastIP']) + + if newName == -1 : + notFound += 1 + elif newName == -2 : + ignored += 1 + else : + recordsToUpdate.append ([newName, device['dev_MAC']]) + # progress bar + print ('.', end='') + sys.stdout.flush() + + # Print log + print ('') + print (" Names updated: ", len(recordsToUpdate) ) + # DEBUG - print list of record to update + # print (recordsToUpdate) + + # update devices + sql.executemany ("UPDATE Devices SET dev_Name = ? WHERE dev_MAC = ? ", recordsToUpdate ) + + # DEBUG - print number of rows updated + # print (sql.rowcount) + +#------------------------------------------------------------------------------- +def resolve_device_name (pMAC, pIP): + try : + pMACstr = str(pMAC) + + # Check MAC parameter + mac = pMACstr.replace (':','') + if len(pMACstr) != 17 or len(mac) != 12 : + return -2 + + # Resolve name with DIG + dig_args = ['dig', '+short', '-x', pIP] + newName = subprocess.check_output (dig_args, universal_newlines=True) + + # Check if Eliminate local domain + newName = newName.strip() + if len(newName) == 0 : + return -2 + + # Eliminate local domain + if newName.endswith('.') : + newName = newName[:-1] + if newName.endswith('.lan') : + newName = newName[:-4] + if newName.endswith('.local') : + newName = newName[:-6] + if newName.endswith('.home') : + newName = newName[:-5] + + # Return newName + return newName + + # not Found + except subprocess.CalledProcessError : + return -1 + #------------------------------------------------------------------------------- def void_ghost_disconnections (): # Void connect ghost events (disconnect event exists in last X min.) diff --git a/back/update_vendors.sh b/back/update_vendors.sh index 2044705f..9d93574b 100644 --- a/back/update_vendors.sh +++ b/back/update_vendors.sh @@ -3,7 +3,7 @@ # Pi.Alert # Open Source Network Guard / WIFI & LAN intrusion detector # -# vendors_db_update.sh - Back module. IEEE Vendors db update +# update_vendors.sh - Back module. IEEE Vendors db update # ------------------------------------------------------------------------------ # Puche 2021 pi.alert.application@gmail.com GNU GPLv3 # ------------------------------------------------------------------------------ diff --git a/config/version.conf b/config/version.conf index e95ea5b7..7fc3c716 100644 --- a/config/version.conf +++ b/config/version.conf @@ -1,3 +1,3 @@ -VERSION = '2.61' +VERSION = '2.70' VERSION_YEAR = '2021' -VERSION_DATE = '2021-01-25' +VERSION_DATE = '2021-02-01' diff --git a/docs/VERSIONS_HISTORY.md b/docs/VERSIONS_HISTORY.md index 18332ec5..115a2338 100644 --- a/docs/VERSIONS_HISTORY.md +++ b/docs/VERSIONS_HISTORY.md @@ -3,6 +3,8 @@ | Version | Description | | ------- | --------------------------------------------------------------- | + | v2.70 | New features & Usability improvements in the web prontal | + | v2.61 | Bug fixing | | v2.60 | Improved the compability of installation process (Ubuntu) | | v2.56 | Bug fixing | | v2.55 | Bug fixing | @@ -11,6 +13,21 @@ | v2.50 | First public release | +## Pi.Alert v2.70 + + - Added Client names resolution #43 + - Added Check to mark devices as "known" #16 + - Remember "Show XXX entries" dropdown value #16 #26 + - Remember "sorting" in devices #16 + - Remember "Device panel " in device detail #16 + - Added "All" option to "Show x Entries" option #16 + - Added optional Location field (Door, Basement, etc.) to devices #16 + - "Device updated successfully" message now is not modal #16 + - Now is possible to delete Devices #16 + - Added Device Type Singleboard Computer (SBC) #16 + - Allowed to use " in device name #42 + + ## Pi.Alert v2.60 - `pialert.conf` moved from `back` to `config` folder diff --git a/front/css/pialert.css b/front/css/pialert.css index 75e68839..43378ec9 100644 --- a/front/css/pialert.css +++ b/front/css/pialert.css @@ -1,6 +1,11 @@ -/******************************************************************************* -* Pi.alert CSS -*******************************************************************************/ +/* ----------------------------------------------------------------------------- +# Pi.Alert +# Open Source Network Guard / WIFI & LAN intrusion detector +# +# pialert.css - Front module. CSS styles +#------------------------------------------------------------------------------- +# Puche 2021 pi.alert.application@gmail.com GNU GPLv3 +----------------------------------------------------------------------------- */ /* ----------------------------------------------------------------------------- Global Variables @@ -371,3 +376,28 @@ z-index: 100; } +/* ----------------------------------------------------------------------------- + Notification float banner +----------------------------------------------------------------------------- */ +.pa_alert_notification { + text-align: center; + font-size: large; + font-weight: bold; + color: #258744; + + background-color: #d4edda; + border-color: #c3e6cb; + border-radius: 5px; + + max-width: 1000px; /* 80% wrapper 1250px */ + width: 80%; + z-index: 9999; + + position: fixed; + top: 30px; + margin: auto; + transform: translate(0,0); + + display: none; +} + diff --git a/front/deviceDetails.php b/front/deviceDetails.php index f15bf508..e452bfcd 100644 --- a/front/deviceDetails.php +++ b/front/deviceDetails.php @@ -1,4 +1,12 @@ - + + @@ -8,15 +16,15 @@
+ +

 Quering device info...

- - Sessions, Presence & Alerts period: - - @@ -24,92 +32,73 @@ -
-
+ +
- - + - + - + @@ -117,32 +106,33 @@
-
- +
+ +
- @@ -154,10 +116,13 @@
+ +

Events

- + +
@@ -179,6 +144,7 @@
+
@@ -208,86 +174,113 @@ diff --git a/front/index.php b/front/index.php index 58937cdc..1d3ecead 100644 --- a/front/index.php +++ b/front/index.php @@ -1,4 +1,12 @@ - + + @@ -11,102 +19,73 @@

Devices

- - - - New Devices period: - - -
+ +
- - + - + - + @@ -118,12 +97,15 @@
+ +

Devices

- + +
- +
@@ -142,6 +124,7 @@
Name
+
@@ -171,169 +154,165 @@ diff --git a/front/js/pialert_common.js b/front/js/pialert_common.js index 5778f71f..84408340 100644 --- a/front/js/pialert_common.js +++ b/front/js/pialert_common.js @@ -1,9 +1,89 @@ /* ----------------------------------------------------------------------------- - Pi.Alert Common Javascript functions +* Pi.Alert +* Open Source Network Guard / WIFI & LAN intrusion detector +* +* pialert_common.js - Front module. Common Javascript functions +*------------------------------------------------------------------------------- +* Puche 2021 pi.alert.application@gmail.com GNU GPLv3 ----------------------------------------------------------------------------- */ // ----------------------------------------------------------------------------- var timerRefreshData = '' +var modalCallbackFunction = ''; + + +// ----------------------------------------------------------------------------- +function showModal (title, message, btnCancel, btnOK, callbackFunction) { + // set captions + $('#modal-title').html (title); + $('#modal-message').html (message); + $('#modal-cancel').html (btnCancel); + $('#modal-OK').html (btnOK); + modalCallbackFunction = callbackFunction; + + // Show modal + $('#modal-warning').modal('show'); +} + +// ----------------------------------------------------------------------------- +function modalOK () { + // Hide modal + $('#modal-warning').modal('hide'); + + // timer to execute function + window.setTimeout( function() { + window[modalCallbackFunction](); + }, 100); +} + +// ----------------------------------------------------------------------------- +function showMessage (textMessage="") { + if (textMessage.toLowerCase().includes("error") ) { + // show error + alert (textMessage); + } else { + // show temporal notification + $("#alert-message").html (textMessage); + $("#notification").fadeIn(1, function () { + window.setTimeout( function() { + $("#notification").fadeOut(500) + }, 3000); + } ); + } +} + + +// ----------------------------------------------------------------------------- +function setParameter (parameter, value) { + // Retry + $.get('php/server/parameters.php?action=set¶meter=' + parameter + + '&value='+ value, + function(data) { + if (data != "OK") { + // Retry + sleep (200); + $.get('php/server/parameters.php?action=set¶meter=' + parameter + + '&value='+ value, + function(data) { + if (data != "OK") { + // alert (data); + } else { + // alert ("OK. Second attempt"); + }; + } ); + }; + } ); +} + + +// ----------------------------------------------------------------------------- +function sleep(milliseconds) { + const date = Date.now(); + let currentDate = null; + do { + currentDate = Date.now(); + } while (currentDate - date < milliseconds); +} // ----------------------------------------------------------------------------- @@ -35,5 +115,7 @@ function newTimerRefreshData (refeshFunction) { // ----------------------------------------------------------------------------- function debugTimer () { - document.getElementById ('pageTitle').innerHTML = (new Date().getSeconds()); + $('#pageTitle').html (new Date().getSeconds()); } + + diff --git a/front/php/server/db.php b/front/php/server/db.php index f4ffd6ef..8e3e7706 100644 --- a/front/php/server/db.php +++ b/front/php/server/db.php @@ -1,32 +1,40 @@ diff --git a/front/php/server/devices.php b/front/php/server/devices.php index aa76c287..1765a473 100644 --- a/front/php/server/devices.php +++ b/front/php/server/devices.php @@ -1,14 +1,25 @@ query($sql); + $row = $result -> fetchArray (SQLITE3_ASSOC); + $deviceData = $row; + + $deviceData['dev_FirstConnection'] = formatDate ($row['dev_FirstConnection']); // Date formated + $deviceData['dev_LastConnection'] = formatDate ($row['dev_LastConnection']); // Date formated + + // Count Totals + $condition = ' WHERE eve_MAC="'. $mac .'" AND eve_DateTime >= '. $periodDate; + + // Connections + $sql = 'SELECT COUNT(*) FROM Sessions + WHERE ses_MAC="'. $mac .'" + AND ( ses_DateTimeConnection >= '. $periodDate .' + OR ses_DateTimeDisconnection >= '. $periodDate .' + OR ses_StillConnected = 1 )'; + $result = $db->query($sql); + $row = $result -> fetchArray (SQLITE3_NUM); + $deviceData['dev_Sessions'] = $row[0]; + + // Events + $sql = 'SELECT COUNT(*) FROM Events '. $condition .' AND eve_EventType <> "Connected" AND eve_EventType <> "Disconnected" '; + $result = $db->query($sql); + $row = $result -> fetchArray (SQLITE3_NUM); + $deviceData['dev_Events'] = $row[0]; + + // Donw Alerts + $sql = 'SELECT COUNT(*) FROM Events '. $condition .' AND eve_EventType = "Device Down"'; + $result = $db->query($sql); + $row = $result -> fetchArray (SQLITE3_NUM); + $deviceData['dev_DownAlerts'] = $row[0]; + + // Presence hours + $sql = 'SELECT SUM (julianday (IFNULL (ses_DateTimeDisconnection, DATETIME("now"))) + - julianday (CASE WHEN ses_DateTimeConnection < '. $periodDate .' THEN '. $periodDate .' + ELSE ses_DateTimeConnection END)) *24 + FROM Sessions + WHERE ses_MAC="'. $mac .'" + AND ses_DateTimeConnection IS NOT NULL + AND (ses_DateTimeDisconnection IS NOT NULL OR ses_StillConnected = 1 ) + AND ( ses_DateTimeConnection >= '. $periodDate .' + OR ses_DateTimeDisconnection >= '. $periodDate .' + OR ses_StillConnected = 1 )'; + $result = $db->query($sql); + $row = $result -> fetchArray (SQLITE3_NUM); + $deviceData['dev_PresenceHours'] = round ($row[0]); + + // Return json + echo (json_encode ($deviceData)); +} + + +//------------------------------------------------------------------------------ +// Update Device Data +//------------------------------------------------------------------------------ +function setDeviceData() { + global $db; + + // sql + $sql = 'UPDATE Devices SET + dev_Name = "'. quotes($_REQUEST['name']) .'", + dev_Owner = "'. quotes($_REQUEST['owner']) .'", + dev_DeviceType = "'. quotes($_REQUEST['type']) .'", + dev_Vendor = "'. quotes($_REQUEST['vendor']) .'", + dev_Favorite = "'. quotes($_REQUEST['favorite']) .'", + dev_Group = "'. quotes($_REQUEST['group']) .'", + dev_Location = "'. quotes($_REQUEST['location']) .'", + dev_Comments = "'. quotes($_REQUEST['comments']) .'", + dev_StaticIP = "'. quotes($_REQUEST['staticIP']) .'", + dev_ScanCycle = "'. quotes($_REQUEST['scancycle']) .'", + dev_AlertEvents = "'. quotes($_REQUEST['alertevents']) .'", + dev_AlertDeviceDown = "'. quotes($_REQUEST['alertdown']) .'", + dev_SkipRepeated = "'. quotes($_REQUEST['skiprepeated']) .'", + dev_NewDevice = "'. quotes($_REQUEST['newdevice']) .'" + WHERE dev_MAC="' . $_REQUEST['mac'] .'"'; + // update Data + $result = $db->query($sql); + + // check result + if ($result == TRUE) { + echo "Device updated successfully"; + } else { + echo "Error updating device\n\n$sql \n\n". $db->lastErrorMsg(); + } +} + + +//------------------------------------------------------------------------------ +// Delete Device +//------------------------------------------------------------------------------ +function deleteDevice() { + global $db; + + // sql + $sql = 'DELETE FROM Devices WHERE dev_MAC="' . $_REQUEST['mac'] .'"'; + // execute sql + $result = $db->query($sql); + + // check result + if ($result == TRUE) { + echo "Device deleted successfully"; + } else { + echo "Error deleting device\n\n$sql \n\n". $db->lastErrorMsg(); + } +} + + //------------------------------------------------------------------------------ // Query total numbers of Devices by status //------------------------------------------------------------------------------ -function queryTotals() { +function getDevicesTotals() { global $db; // All @@ -42,43 +182,42 @@ function queryTotals() { $devices = $row[0]; // Connected - $result = $db->query('SELECT COUNT(*) FROM Devices ' . getDeviceCondition ('connected') ); + $result = $db->query('SELECT COUNT(*) FROM Devices '. getDeviceCondition ('connected') ); $row = $result -> fetchArray (SQLITE3_NUM); $connected = $row[0]; // New - $result = $db->query('SELECT COUNT(*) FROM Devices ' . getDeviceCondition ('new') ); + $result = $db->query('SELECT COUNT(*) FROM Devices '. getDeviceCondition ('new') ); $row = $result -> fetchArray (SQLITE3_NUM); $newDevices = $row[0]; // Down Alerts - $result = $db->query('SELECT COUNT(*) FROM Devices ' . getDeviceCondition ('down')); + $result = $db->query('SELECT COUNT(*) FROM Devices '. getDeviceCondition ('down')); $row = $result -> fetchArray (SQLITE3_NUM); $devicesDownAlert = $row[0]; - echo (json_encode (array ($devices, $connected, $newDevices, $devicesDownAlert))); + echo (json_encode (array ($devices, $connected, $newDevices, + $devicesDownAlert))); } //------------------------------------------------------------------------------ // Query the List of devices in a determined Status //------------------------------------------------------------------------------ -function queryList() { +function getDevicesList() { global $db; - // Request Parameters - $periodDate = getDateFromPeriod(); - // SQL $condition = getDeviceCondition ($_REQUEST['status']); - $result = $db->query('SELECT *, - CASE WHEN dev_AlertDeviceDown=1 AND dev_PresentLastScan=0 THEN "Down" - WHEN dev_FirstConnection >= ' . $periodDate . ' THEN "New" - WHEN dev_PresentLastScan=1 THEN "On-line" - ELSE "Off-line" - END AS dev_Status - FROM Devices ' . $condition); + $sql = 'SELECT *, CASE + WHEN dev_AlertDeviceDown=1 AND dev_PresentLastScan=0 THEN "Down" + WHEN dev_NewDevice=1 THEN "New" + WHEN dev_PresentLastScan=1 THEN "On-line" + ELSE "Off-line" + END AS dev_Status + FROM Devices '. $condition; + $result = $db->query($sql); // arrays of rows $tableData = array(); @@ -94,7 +233,7 @@ function queryList() { $row['dev_Status'], $row['dev_MAC'], // MAC (hidden) formatIPlong ($row['dev_LastIP']) // IP orderable - ); + ); } // Control no rows @@ -106,130 +245,13 @@ function queryList() { echo (json_encode ($tableData)); } -//------------------------------------------------------------------------------ -// Query the List of Owners -//------------------------------------------------------------------------------ -function queryOwners() { - global $db; - - // SQL - $result = $db->query('SELECT DISTINCT 1 as dev_Order, dev_Owner - FROM Devices - WHERE dev_Owner <> "(unknown)" AND dev_Owner <> "" - AND dev_Favorite = 1 - UNION - SELECT DISTINCT 2 as dev_Order, dev_Owner - FROM Devices - WHERE dev_Owner <> "(unknown)" AND dev_Owner <> "" - AND dev_Favorite = 0 - AND dev_Owner NOT IN (SELECT dev_Owner FROM Devices WHERE dev_Favorite = 1) - ORDER BY 1,2 '); - - // arrays of rows - $tableData = array(); - while ($row = $result -> fetchArray (SQLITE3_ASSOC)) { - $tableData[] = array ('order' => $row['dev_Order'], - 'name' => $row['dev_Owner']); - } - - // Return json - echo (json_encode ($tableData)); -} - - -//------------------------------------------------------------------------------ -// Query the List of types -//------------------------------------------------------------------------------ -function queryDeviceTypes() { - global $db; - - // SQL - $result = $db->query('SELECT DISTINCT 9 as dev_Order, dev_DeviceType - FROM Devices - WHERE dev_DeviceType NOT IN ("", - "Smartphone", "Tablet", - "Laptop", "Mini PC", "PC", "Printer", "Server", - "Game Console", "SmartTV", "TV Decoder", "Virtual Assistance", - "Clock", "House Appliance", "Phone", "Radio", - "AP", "NAS", "PLC", "Router") - - UNION SELECT 1 as dev_Order, "Smartphone" - UNION SELECT 1 as dev_Order, "Tablet" - - UNION SELECT 2 as dev_Order, "Laptop" - UNION SELECT 2 as dev_Order, "Mini PC" - UNION SELECT 2 as dev_Order, "PC" - UNION SELECT 2 as dev_Order, "Printer" - UNION SELECT 2 as dev_Order, "Server" - - UNION SELECT 3 as dev_Order, "Game Console" - UNION SELECT 3 as dev_Order, "SmartTV" - UNION SELECT 3 as dev_Order, "TV Decoder" - UNION SELECT 3 as dev_Order, "Virtual Assistance" - - UNION SELECT 4 as dev_Order, "Clock" - UNION SELECT 4 as dev_Order, "House Appliance" - UNION SELECT 4 as dev_Order, "Phone" - UNION SELECT 4 as dev_Order, "Radio" - - UNION SELECT 5 as dev_Order, "AP" - UNION SELECT 5 as dev_Order, "NAS" - UNION SELECT 5 as dev_Order, "PLC" - UNION SELECT 5 as dev_Order, "Router" - - UNION SELECT 10 as dev_Order, "Other" - - ORDER BY 1,2 '); - - // arrays of rows - $tableData = array(); - while ($row = $result -> fetchArray (SQLITE3_ASSOC)) { - $tableData[] = array ('order' => $row['dev_Order'], - 'name' => $row['dev_DeviceType']); - } - - // Return json - echo (json_encode ($tableData)); -} - - -//------------------------------------------------------------------------------ -// Query the List of groups -//------------------------------------------------------------------------------ -function queryGroups() { - global $db; - - // SQL - $result = $db->query('SELECT DISTINCT 1 as dev_Order, dev_Group - FROM Devices - WHERE dev_Group <> "(unknown)" AND dev_Group <> "Others" AND dev_Group <> "" - UNION SELECT 1 as dev_Order, "Always on" - UNION SELECT 1 as dev_Order, "Friends" - UNION SELECT 1 as dev_Order, "Personal" - UNION SELECT 2 as dev_Order, "Others" - ORDER BY 1,2 '); - - // arrays of rows - $tableData = array(); - while ($row = $result -> fetchArray (SQLITE3_ASSOC)) { - $tableData[] = array ('order' => $row['dev_Order'], - 'name' => $row['dev_Group']); - } - - // Return json - echo (json_encode ($tableData)); -} - //------------------------------------------------------------------------------ // Query the List of devices for calendar //------------------------------------------------------------------------------ -function queryCalendarList() { +function getDevicesListCalendar() { global $db; - // Request Parameters - $periodDate = getDateFromPeriod(); - // SQL $condition = getDeviceCondition ($_REQUEST['status']); $result = $db->query('SELECT * FROM Devices ' . $condition); @@ -252,67 +274,175 @@ function queryCalendarList() { //------------------------------------------------------------------------------ -// Query Device Data +// Query the List of Owners //------------------------------------------------------------------------------ -function queryDeviceData() { +function getOwners() { global $db; - // Request Parameters - $periodDate = getDateFromPeriod(); - $mac = $_REQUEST['mac']; - - // Device Data - $result = $db->query('SELECT *, - CASE WHEN dev_AlertDeviceDown=1 AND dev_PresentLastScan=0 THEN "Down" - WHEN dev_PresentLastScan=1 THEN "On-line" - ELSE "Off-line" END as dev_Status - FROM Devices - WHERE dev_MAC="' . $mac .'"'); - - $row = $result -> fetchArray (SQLITE3_ASSOC); - $deviceData = $row; - $deviceData['dev_FirstConnection'] = formatDate ($row['dev_FirstConnection']); // Date formated - $deviceData['dev_LastConnection'] = formatDate ($row['dev_LastConnection']); // Date formated - - // Count Totals - $condicion = ' WHERE eve_MAC="' . $mac .'" AND eve_DateTime >= ' . $periodDate; - - // Connections - $result = $db->query('SELECT COUNT(*) FROM Sessions - WHERE ses_MAC="' . $mac .'" - AND ( ses_DateTimeConnection >= ' . $periodDate . ' - OR ses_DateTimeDisconnection >= ' . $periodDate . ' - OR ses_StillConnected = 1 ) '); - $row = $result -> fetchArray (SQLITE3_NUM); - $deviceData['dev_Sessions'] = $row[0]; - - // Events - $result = $db->query('SELECT COUNT(*) FROM Events ' . $condicion . ' AND eve_EventType <> "Connected" AND eve_EventType <> "Disconnected" '); - $row = $result -> fetchArray (SQLITE3_NUM); - $deviceData['dev_Events'] = $row[0]; - - // Donw Alerts - $result = $db->query('SELECT COUNT(*) FROM Events ' . $condicion . ' AND eve_EventType = "Device Down"'); - $row = $result -> fetchArray (SQLITE3_NUM); - $deviceData['dev_DownAlerts'] = $row[0]; - - // Presence hours - $result = $db->query('SELECT SUM (julianday (IFNULL (ses_DateTimeDisconnection, DATETIME("now"))) - - julianday (CASE WHEN ses_DateTimeConnection < ' . $periodDate . ' THEN ' . $periodDate . ' - ELSE ses_DateTimeConnection END)) *24 - FROM Sessions - WHERE ses_MAC="' . $mac .'" - AND ses_DateTimeConnection IS NOT NULL - AND (ses_DateTimeDisconnection IS NOT NULL OR ses_StillConnected = 1 ) - AND ( ses_DateTimeConnection >= ' . $periodDate . ' - OR ses_DateTimeDisconnection >= ' . $periodDate . ' - OR ses_StillConnected = 1 ) '); - $row = $result -> fetchArray (SQLITE3_NUM); - $deviceData['dev_PresenceHours'] = round ($row[0]); + // SQL + $sql = 'SELECT DISTINCT 1 as dev_Order, dev_Owner + FROM Devices + WHERE dev_Owner <> "(unknown)" AND dev_Owner <> "" + AND dev_Favorite = 1 + UNION + SELECT DISTINCT 2 as dev_Order, dev_Owner + FROM Devices + WHERE dev_Owner <> "(unknown)" AND dev_Owner <> "" + AND dev_Favorite = 0 + AND dev_Owner NOT IN + (SELECT dev_Owner FROM Devices WHERE dev_Favorite = 1) + ORDER BY 1,2 '; + $result = $db->query($sql); + // arrays of rows + $tableData = array(); + while ($row = $result -> fetchArray (SQLITE3_ASSOC)) { + $tableData[] = array ('order' => $row['dev_Order'], + 'name' => $row['dev_Owner']); + } // Return json - echo (json_encode ($deviceData)); + echo (json_encode ($tableData)); +} + + +//------------------------------------------------------------------------------ +// Query the List of types +//------------------------------------------------------------------------------ +function getDeviceTypes() { + global $db; + + // SQL + $sql = 'SELECT DISTINCT 9 as dev_Order, dev_DeviceType + FROM Devices + WHERE dev_DeviceType NOT IN ("", + "Smartphone", "Tablet", + "Laptop", "Mini PC", "PC", "Printer", "Server", "Singleboard Computer (SBC)", + "Game Console", "SmartTV", "TV Decoder", "Virtual Assistance", + "Clock", "House Appliance", "Phone", "Radio", + "AP", "NAS", "PLC", "Router") + + UNION SELECT 1 as dev_Order, "Smartphone" + UNION SELECT 1 as dev_Order, "Tablet" + + UNION SELECT 2 as dev_Order, "Laptop" + UNION SELECT 2 as dev_Order, "Mini PC" + UNION SELECT 2 as dev_Order, "PC" + UNION SELECT 2 as dev_Order, "Printer" + UNION SELECT 2 as dev_Order, "Server" + UNION SELECT 2 as dev_Order, "Singleboard Computer (SBC)" + + UNION SELECT 3 as dev_Order, "Game Console" + UNION SELECT 3 as dev_Order, "SmartTV" + UNION SELECT 3 as dev_Order, "TV Decoder" + UNION SELECT 3 as dev_Order, "Virtual Assistance" + + UNION SELECT 4 as dev_Order, "Clock" + UNION SELECT 4 as dev_Order, "House Appliance" + UNION SELECT 4 as dev_Order, "Phone" + UNION SELECT 4 as dev_Order, "Radio" + + UNION SELECT 5 as dev_Order, "AP" + UNION SELECT 5 as dev_Order, "NAS" + UNION SELECT 5 as dev_Order, "PLC" + UNION SELECT 5 as dev_Order, "Router" + + UNION SELECT 10 as dev_Order, "Other" + + ORDER BY 1,2'; + $result = $db->query($sql); + + // arrays of rows + $tableData = array(); + while ($row = $result -> fetchArray (SQLITE3_ASSOC)) { + $tableData[] = array ('order' => $row['dev_Order'], + 'name' => $row['dev_DeviceType']); + } + + // Return json + echo (json_encode ($tableData)); +} + + +//------------------------------------------------------------------------------ +// Query the List of groups +//------------------------------------------------------------------------------ +function getGroups() { + global $db; + + // SQL + $sql = 'SELECT DISTINCT 1 as dev_Order, dev_Group + FROM Devices + WHERE dev_Group NOT IN ("(unknown)", "Others") AND dev_Group <> "" + UNION SELECT 1 as dev_Order, "Always on" + UNION SELECT 1 as dev_Order, "Friends" + UNION SELECT 1 as dev_Order, "Personal" + UNION SELECT 2 as dev_Order, "Others" + ORDER BY 1,2 '; + $result = $db->query($sql); + + // arrays of rows + $tableData = array(); + while ($row = $result -> fetchArray (SQLITE3_ASSOC)) { + $tableData[] = array ('order' => $row['dev_Order'], + 'name' => $row['dev_Group']); + } + + // Return json + echo (json_encode ($tableData)); +} + + +//------------------------------------------------------------------------------ +// Query the List of locations +//------------------------------------------------------------------------------ +function getLocations() { + global $db; + + // SQL + $sql = 'SELECT DISTINCT 9 as dev_Order, dev_Location + FROM Devices + WHERE dev_Location <> "" + AND dev_Location NOT IN ( + "Bathroom", "Bedroom", "Dining room", "Hallway", + "Kitchen", "Laundry", "Living room", "Study", + "Attic", "Basement", "Garage", + "Back yard", "Garden", "Terrace", + "Other") + + UNION SELECT 1 as dev_Order, "Bathroom" + UNION SELECT 1 as dev_Order, "Bedroom" + UNION SELECT 1 as dev_Order, "Dining room" + UNION SELECT 1 as dev_Order, "Hall" + UNION SELECT 1 as dev_Order, "Kitchen" + UNION SELECT 1 as dev_Order, "Laundry" + UNION SELECT 1 as dev_Order, "Living room" + UNION SELECT 1 as dev_Order, "Study" + + UNION SELECT 2 as dev_Order, "Attic" + UNION SELECT 2 as dev_Order, "Basement" + UNION SELECT 2 as dev_Order, "Garage" + + UNION SELECT 3 as dev_Order, "Back yard" + UNION SELECT 3 as dev_Order, "Garden" + UNION SELECT 3 as dev_Order, "Terrace" + + UNION SELECT 10 as dev_Order, "Other" + ORDER BY 1,2 '; + + + + $result = $db->query($sql); + + // arrays of rows + $tableData = array(); + while ($row = $result -> fetchArray (SQLITE3_ASSOC)) { + $tableData[] = array ('order' => $row['dev_Order'], + 'name' => $row['dev_Location']); + } + + // Return json + echo (json_encode ($tableData)); } @@ -320,58 +450,14 @@ function queryDeviceData() { // Status Where conditions //------------------------------------------------------------------------------ function getDeviceCondition ($deviceStatus) { - // Request Parameters - $periodDate = getDateFromPeriod(); - switch ($deviceStatus) { - case 'all': - return ''; - case 'connected': - return 'WHERE dev_PresentLastScan=1'; - case 'new': - return 'WHERE dev_FirstConnection >= ' . $periodDate; - case 'down': - return 'WHERE dev_AlertDeviceDown=1 AND dev_PresentLastScan=0'; - case 'favorites': - return 'WHERE dev_Favorite=1'; - default: - return 'WHERE 1=0'; + case 'all': return ''; break; + case 'connected': return 'WHERE dev_PresentLastScan=1'; break; + case 'new': return 'WHERE dev_NewDevice=1'; break; + case 'down': return 'WHERE dev_AlertDeviceDown=1 AND dev_PresentLastScan=0'; break; + case 'favorites': return 'WHERE dev_Favorite=1'; break; + default: return 'WHERE 1=0'; break; } } - -//------------------------------------------------------------------------------ -// Update Device Data -//------------------------------------------------------------------------------ -function updateDeviceData() { - global $db; - - // sql - $sql = 'UPDATE Devices SET - dev_Name = "'. $_REQUEST['name'] .'", - dev_Owner = "'. $_REQUEST['owner'] .'", - dev_DeviceType = "'. $_REQUEST['type'] .'", - dev_Vendor = "'. $_REQUEST['vendor'] .'", - dev_Favorite = "'. $_REQUEST['favorite'] .'", - dev_Group = "'. $_REQUEST['group'] .'", - dev_Comments = "'. $_REQUEST['comments'] .'", - dev_StaticIP = "'. $_REQUEST['staticIP'] .'", - dev_ScanCycle = "'. $_REQUEST['scancycle'] .'", - dev_AlertEvents = "'. $_REQUEST['alertevents'] .'", - dev_AlertDeviceDown = "'. $_REQUEST['alertdown'] .'", - dev_SkipRepeated = "'. $_REQUEST['skiprepeated'] .'" - WHERE dev_MAC="' . $_REQUEST['mac'] .'"'; - // update Data - $result = $db->query($sql); - - // check result - if ($result == TRUE) { - echo "Device updated successfully"; - } else { - echo "Error updating device\n\n". $sql .'\n\n' . $db->lastErrorMsg(); - } - -} - - ?> diff --git a/front/php/server/events.php b/front/php/server/events.php index 8e073973..1d0fa228 100644 --- a/front/php/server/events.php +++ b/front/php/server/events.php @@ -1,9 +1,20 @@ = '. $periodDate .' - OR ses_DateTimeDisconnection >= '. $periodDate .' - OR ses_StillConnected = 1 ) '; + $SQL = $SQL2 . ' WHERE ( ses_DateTimeConnection >= '. $periodDate .' OR ses_DateTimeDisconnection >= '. $periodDate .' OR ses_StillConnected = 1 ) '; break; case 'missing': $SQL = $SQL2 . ' WHERE (ses_DateTimeConnection IS NULL AND ses_DateTimeDisconnection >= '. $periodDate .' ) OR (ses_DateTimeDisconnection IS NULL AND ses_StillConnected = 0 AND ses_DateTimeConnection >= '. $periodDate .' )'; break; - case 'voided': - $SQL = $SQL1 .' AND eve_EventType LIKE "VOIDED%" '; - break; - case 'new': - $SQL = $SQL1 .' AND eve_EventType = "New Device" '; - break; - case 'down': - $SQL = $SQL1 .' AND eve_EventType = "Device Down" '; - break; - default: - $SQL = $SQL1 .' AND 1==0 '; - break; + case 'voided': $SQL = $SQL1 .' AND eve_EventType LIKE "VOIDED%" '; break; + case 'new': $SQL = $SQL1 .' AND eve_EventType = "New Device" '; break; + case 'down': $SQL = $SQL1 .' AND eve_EventType = "Device Down" '; break; + default: $SQL = $SQL1 .' AND 1==0 '; break; } // Query @@ -187,7 +186,7 @@ function queryList() { //------------------------------------------------------------------------------ // Query Device Sessions //------------------------------------------------------------------------------ -function queryDeviceSessions() { +function getDeviceSessions() { global $db; // Request Parameters @@ -195,16 +194,17 @@ function queryDeviceSessions() { $periodDate = getDateFromPeriod(); // SQL - $result = $db->query('SELECT IFNULL (ses_DateTimeConnection, ses_DateTimeDisconnection) ses_DateTimeOrder, - ses_EventTypeConnection, ses_DateTimeConnection, - ses_EventTypeDisconnection, ses_DateTimeDisconnection, ses_StillConnected, - ses_IP, ses_AdditionalInfo - FROM Sessions - WHERE ses_MAC="' . $mac .'" - AND ( ses_DateTimeConnection >= '. $periodDate .' - OR ses_DateTimeDisconnection >= '. $periodDate .' - OR ses_StillConnected = 1 ) '); - + $SQL = 'SELECT IFNULL (ses_DateTimeConnection, ses_DateTimeDisconnection) ses_DateTimeOrder, + ses_EventTypeConnection, ses_DateTimeConnection, + ses_EventTypeDisconnection, ses_DateTimeDisconnection, ses_StillConnected, + ses_IP, ses_AdditionalInfo + FROM Sessions + WHERE ses_MAC="' . $mac .'" + AND ( ses_DateTimeConnection >= '. $periodDate .' + OR ses_DateTimeDisconnection >= '. $periodDate .' + OR ses_StillConnected = 1 ) '; + $result = $db->query($SQL); + // arrays of rows $tableData = array(); while ($row = $result -> fetchArray (SQLITE3_ASSOC)) { @@ -228,7 +228,7 @@ function queryDeviceSessions() { if ($row['ses_EventTypeConnection'] == '' || $row['ses_EventTypeDisconnection'] == '') { $dur = '...'; } elseif ($row['ses_StillConnected'] == true) { - $dur = formatDateDiff ($row['ses_DateTimeConnection'], ''); //******************************************************************************************* + $dur = formatDateDiff ($row['ses_DateTimeConnection'], ''); //*********** } else { $dur = formatDateDiff ($row['ses_DateTimeConnection'], $row['ses_DateTimeDisconnection']); } @@ -256,7 +256,7 @@ function queryDeviceSessions() { //------------------------------------------------------------------------------ // Query Device Presence Calendar //------------------------------------------------------------------------------ -function queryDevicePresence() { +function getDevicePresence() { global $db; // Request Parameters @@ -266,24 +266,26 @@ function queryDevicePresence() { $endDate = '"'. formatDateISO ($_REQUEST ['end']) .'"'; // SQL - $result = $db->query('SELECT ses_EventTypeConnection, ses_DateTimeConnection, - ses_EventTypeDisconnection, ses_DateTimeDisconnection, ses_IP, ses_AdditionalInfo, - - CASE WHEN ses_EventTypeConnection = "" THEN - IFNULL ((SELECT MAX(ses_DateTimeDisconnection) FROM Sessions AS SES2 WHERE SES2.ses_MAC = SES1.ses_MAC AND SES2.ses_DateTimeDisconnection < SES1.ses_DateTimeDisconnection), DATETIME(ses_DateTimeDisconnection, "-1 hour")) - ELSE ses_DateTimeConnection - END AS ses_DateTimeConnectionCorrected, + $SQL = 'SELECT ses_EventTypeConnection, ses_DateTimeConnection, + ses_EventTypeDisconnection, ses_DateTimeDisconnection, ses_IP, ses_AdditionalInfo, + + CASE + WHEN ses_EventTypeConnection = "" THEN + IFNULL ((SELECT MAX(ses_DateTimeDisconnection) FROM Sessions AS SES2 WHERE SES2.ses_MAC = SES1.ses_MAC AND SES2.ses_DateTimeDisconnection < SES1.ses_DateTimeDisconnection), DATETIME(ses_DateTimeDisconnection, "-1 hour")) + ELSE ses_DateTimeConnection + END AS ses_DateTimeConnectionCorrected, - CASE WHEN ses_EventTypeDisconnection = "" THEN - (SELECT MIN(ses_DateTimeConnection) FROM Sessions AS SES2 WHERE SES2.ses_MAC = SES1.ses_MAC AND SES2.ses_DateTimeConnection > SES1.ses_DateTimeConnection) - ELSE ses_DateTimeDisconnection - END AS ses_DateTimeDisconnectionCorrected + CASE + WHEN ses_EventTypeDisconnection = "" THEN + (SELECT MIN(ses_DateTimeConnection) FROM Sessions AS SES2 WHERE SES2.ses_MAC = SES1.ses_MAC AND SES2.ses_DateTimeConnection > SES1.ses_DateTimeConnection) + ELSE ses_DateTimeDisconnection + END AS ses_DateTimeDisconnectionCorrected - FROM Sessions AS SES1 - WHERE ses_MAC="' . $mac .'" - AND (ses_DateTimeConnectionCorrected <= date('. $endDate .') - AND (ses_DateTimeDisconnectionCorrected >= date('. $startDate .') OR ses_StillConnected = 1 )) - '); + FROM Sessions AS SES1 + WHERE ses_MAC="' . $mac .'" + AND (ses_DateTimeConnectionCorrected <= date('. $endDate .') + AND (ses_DateTimeDisconnectionCorrected >= date('. $startDate .') OR ses_StillConnected = 1 )) '; + $result = $db->query($SQL); // arrays of rows while ($row = $result -> fetchArray (SQLITE3_ASSOC)) { @@ -300,10 +302,6 @@ function queryDevicePresence() { 'IP: ' . $row['ses_IP']; // Save row data -// 'start' => formatDateISO ($row['ses_DateTimeConnectionCorrected']), -// 'end' => formatDateISO ($row['ses_DateTimeDisconnectionCorrected']), -// 'start' => $row['ses_DateTimeConnectionCorrected'], -// 'end' => $row['ses_DateTimeDisconnectionCorrected'], $tableData[] = array( 'title' => '', 'start' => formatDateISO ($row['ses_DateTimeConnectionCorrected']), @@ -326,32 +324,33 @@ function queryDevicePresence() { //------------------------------------------------------------------------------ // Query Presence Calendar for all Devices //------------------------------------------------------------------------------ -function queryCalendarPresence() { +function getEventsCalendar() { global $db; // Request Parameters - $periodDate = getDateFromPeriod(); $startDate = '"'. $_REQUEST ['start'] .'"'; $endDate = '"'. $_REQUEST ['end'] .'"'; // SQL - $result = $db->query('SELECT ses_MAC, ses_EventTypeConnection, ses_DateTimeConnection, - ses_EventTypeDisconnection, ses_DateTimeDisconnection, ses_IP, ses_AdditionalInfo, - - CASE WHEN ses_EventTypeConnection = "" THEN - IFNULL ((SELECT MAX(ses_DateTimeDisconnection) FROM Sessions AS SES2 WHERE SES2.ses_MAC = SES1.ses_MAC AND SES2.ses_DateTimeDisconnection < SES1.ses_DateTimeDisconnection), DATETIME(ses_DateTimeDisconnection, "-1 hour")) - ELSE ses_DateTimeConnection - END AS ses_DateTimeConnectionCorrected, + $SQL = 'SELECT ses_MAC, ses_EventTypeConnection, ses_DateTimeConnection, + ses_EventTypeDisconnection, ses_DateTimeDisconnection, ses_IP, ses_AdditionalInfo, + + CASE + WHEN ses_EventTypeConnection = "" THEN + IFNULL ((SELECT MAX(ses_DateTimeDisconnection) FROM Sessions AS SES2 WHERE SES2.ses_MAC = SES1.ses_MAC AND SES2.ses_DateTimeDisconnection < SES1.ses_DateTimeDisconnection), DATETIME(ses_DateTimeDisconnection, "-1 hour")) + ELSE ses_DateTimeConnection + END AS ses_DateTimeConnectionCorrected, - CASE WHEN ses_EventTypeDisconnection = "" THEN - (SELECT MIN(ses_DateTimeConnection) FROM Sessions AS SES2 WHERE SES2.ses_MAC = SES1.ses_MAC AND SES2.ses_DateTimeConnection > SES1.ses_DateTimeConnection) - ELSE ses_DateTimeDisconnection - END AS ses_DateTimeDisconnectionCorrected + CASE + WHEN ses_EventTypeDisconnection = "" THEN + (SELECT MIN(ses_DateTimeConnection) FROM Sessions AS SES2 WHERE SES2.ses_MAC = SES1.ses_MAC AND SES2.ses_DateTimeConnection > SES1.ses_DateTimeConnection) + ELSE ses_DateTimeDisconnection + END AS ses_DateTimeDisconnectionCorrected - FROM Sessions AS SES1 - WHERE ( ses_DateTimeConnectionCorrected <= Date('. $endDate .') - AND (ses_DateTimeDisconnectionCorrected >= Date('. $startDate .') OR ses_StillConnected = 1 )) - '); + FROM Sessions AS SES1 + WHERE ( ses_DateTimeConnectionCorrected <= Date('. $endDate .') + AND (ses_DateTimeDisconnectionCorrected >= Date('. $startDate .') OR ses_StillConnected = 1 )) '; + $result = $db->query($SQL); // arrays of rows while ($row = $result -> fetchArray (SQLITE3_ASSOC)) { @@ -392,7 +391,7 @@ function queryCalendarPresence() { //------------------------------------------------------------------------------ // Query Device events //------------------------------------------------------------------------------ -function queryDeviceEvents() { +function getDeviceEvents() { global $db; // Request Parameters @@ -401,13 +400,13 @@ function queryDeviceEvents() { $hideConnections = $_REQUEST ['hideConnections']; // SQL - $result = $db->query('SELECT eve_DateTime, eve_EventType, eve_IP, eve_AdditionalInfo - FROM Events - WHERE eve_MAC="'. $mac .'" AND eve_DateTime >= '. $periodDate .' - AND ( (eve_EventType <> "Connected" AND eve_EventType <> "Disconnected" AND - eve_EventType <> "VOIDED - Connected" AND eve_EventType <> "VOIDED - Disconnected") - OR "'. $hideConnections .'" = "false" ) - '); + $SQL = 'SELECT eve_DateTime, eve_EventType, eve_IP, eve_AdditionalInfo + FROM Events + WHERE eve_MAC="'. $mac .'" AND eve_DateTime >= '. $periodDate .' + AND ( (eve_EventType <> "Connected" AND eve_EventType <> "Disconnected" AND + eve_EventType <> "VOIDED - Connected" AND eve_EventType <> "VOIDED - Disconnected") + OR "'. $hideConnections .'" = "false" ) '; + $result = $db->query($SQL); // arrays of rows $tableData = array(); @@ -425,5 +424,4 @@ function queryDeviceEvents() { echo (json_encode ($tableData)); } - ?> diff --git a/front/php/server/parameters.php b/front/php/server/parameters.php new file mode 100644 index 00000000..6c0a7cd6 --- /dev/null +++ b/front/php/server/parameters.php @@ -0,0 +1,88 @@ +query($sql); + $row = $result -> fetchArray (SQLITE3_NUM); + $value = $row[0]; + + echo (json_encode ($value)); +} + + +//------------------------------------------------------------------------------ +// Set Parameter Value +//------------------------------------------------------------------------------ +function setParameter() { + global $db; + + // Update value + $sql = 'UPDATE Parameters SET par_Value="'. quotes ($_REQUEST['value']) .'" + WHERE par_ID="'. quotes($_REQUEST['parameter']) .'"'; + $result = $db->query($sql); + + if (! $result == TRUE) { + echo "Error updating parameter\n\n$sql \n\n". $db->lastErrorMsg(); + return; + } + + $changes = $db->changes(); + if ($changes == 0) { + // Insert new value + $sql = 'INSERT INTO Parameters (par_ID, par_Value) + VALUES ("'. quotes($_REQUEST['parameter']) .'", + "'. quotes($_REQUEST['value']) .'")'; + $result = $db->query($sql); + + if (! $result == TRUE) { + echo "Error creating parameter\n\n$sql \n\n". $db->lastErrorMsg(); + return; + } + } + + echo 'OK'; +} + +?> diff --git a/front/php/server/util.php b/front/php/server/util.php index 30a6d6d3..a4f345f3 100644 --- a/front/php/server/util.php +++ b/front/php/server/util.php @@ -1,4 +1,13 @@ diff --git a/front/php/templates/footer.php b/front/php/templates/footer.php index 1ef34db2..a5cdd03d 100644 --- a/front/php/templates/footer.php +++ b/front/php/templates/footer.php @@ -2,7 +2,7 @@ # Pi.Alert # Open Source Network Guard / WIFI & LAN intrusion detector # -# footer.php - Front module. Common footer to all the front pages +# footer.php - Front module. Common footer to all the web pages #------------------------------------------------------------------------------- # Puche 2021 pi.alert.application@gmail.com GNU GPLv3 #--------------------------------------------------------------------------- --> @@ -11,9 +11,7 @@
- +
- +
+ - +
+ - + + - + + - + - + - + - - + - diff --git a/front/php/templates/header.php b/front/php/templates/header.php index d1cbee52..69a26ea1 100644 --- a/front/php/templates/header.php +++ b/front/php/templates/header.php @@ -2,52 +2,58 @@ # Pi.Alert # Open Source Network Guard / WIFI & LAN intrusion detector # -# header.php - Front module. Common header to all the front pages +# header.php - Front module. Common header to all the web pages #------------------------------------------------------------------------------- # Puche 2021 pi.alert.application@gmail.com GNU GPLv3 #--------------------------------------------------------------------------- --> + + Pi.Alert + + + + + - - + + @@ -56,6 +62,7 @@
+ +
+ +
- - +
+ +
- - + - + - + @@ -118,20 +98,27 @@
+ +

Devices

- +
+ +
@@ -156,15 +143,6 @@ - - - - - - - - - @@ -178,23 +156,19 @@ diff --git a/install/pialert_install.sh b/install/pialert_install.sh index 61ee30d0..97bbaf18 100644 --- a/install/pialert_install.sh +++ b/install/pialert_install.sh @@ -8,50 +8,49 @@ # Puche 2021 pi.alert.application@gmail.com GNU GPLv3 # ------------------------------------------------------------------------------ - # ------------------------------------------------------------------------------ # Variables # ------------------------------------------------------------------------------ -COLS=70 -ROWS=12 - -INSTALL_DIR=~ -PIALERT_HOME="$INSTALL_DIR/pialert" - -LIGHTTPD_CONF_DIR="/etc/lighttpd" -WEBROOT="/var/www/html" -PIALERT_DEFAULT_PAGE=false - -LOG="pialert_install_`date +"%Y-%m-%d_%H-%M"`.log" - -MAIN_IP=`ip -o route get 1 | sed -n 's/.*src \([0-9.]\+\).*/\1/p'` - -PIHOLE_INSTALL=false -PIHOLE_ACTIVE=false -DHCP_ACTIVATE=false -DHCP_ACTIVE=false - -DHCP_RANGE_START="192.168.1.200" -DHCP_RANGE_END="192.168.1.251" -DHCP_ROUTER="192.168.1.1" -DHCP_LEASE="1" -DHCP_DOMAIN="local" - -USE_PYTHON_VERSION=0 -PYTHON_BIN=python - -REPORT_MAIL=False -REPORT_TO=user@gmail.com -SMTP_SERVER=smtp.gmail.com -SMTP_PORT=587 -SMTP_USER=user@gmail.com -SMTP_PASS=password - -DDNS_ACTIVE=False -DDNS_DOMAIN='your_domain.freeddns.org' -DDNS_USER='dynu_user' -DDNS_PASSWORD='A0000000B0000000C0000000D0000000' -DDNS_UPDATE_URL='https://api.dynu.com/nic/update?' + COLS=70 + ROWS=12 + + INSTALL_DIR=~ + PIALERT_HOME="$INSTALL_DIR/pialert" + + LIGHTTPD_CONF_DIR="/etc/lighttpd" + WEBROOT="/var/www/html" + PIALERT_DEFAULT_PAGE=false + + LOG="pialert_install_`date +"%Y-%m-%d_%H-%M"`.log" + + MAIN_IP=`ip -o route get 1 | sed -n 's/.*src \([0-9.]\+\).*/\1/p'` + + PIHOLE_INSTALL=false + PIHOLE_ACTIVE=false + DHCP_ACTIVATE=false + DHCP_ACTIVE=false + + DHCP_RANGE_START="192.168.1.200" + DHCP_RANGE_END="192.168.1.251" + DHCP_ROUTER="192.168.1.1" + DHCP_LEASE="1" + DHCP_DOMAIN="local" + + USE_PYTHON_VERSION=0 + PYTHON_BIN=python + + REPORT_MAIL=False + REPORT_TO=user@gmail.com + SMTP_SERVER=smtp.gmail.com + SMTP_PORT=587 + SMTP_USER=user@gmail.com + SMTP_PASS=password + + DDNS_ACTIVE=False + DDNS_DOMAIN='your_domain.freeddns.org' + DDNS_USER='dynu_user' + DDNS_PASSWORD='A0000000B0000000C0000000D0000000' + DDNS_UPDATE_URL='https://api.dynu.com/nic/update?' # ------------------------------------------------------------------------------ @@ -84,13 +83,14 @@ main() { move_logfile } + # ------------------------------------------------------------------------------ # Ask config questions # ------------------------------------------------------------------------------ ask_config() { # Ask installation ask_yesno "This script will install Pi.Alert in this system using this path:\n$PIALERT_HOME" \ - "Do you want to continue ?" + "Do you want to continue ?" if ! $ANSWER ; then exit 1 fi @@ -107,11 +107,11 @@ ask_config() { "Perfect: Pi-hole Installation not necessary" else ask_yesno "Pi-hole is not installed." \ - "Do you want to install Pi-hole before installing Pi.Alert ?" "YES" + "Do you want to install Pi-hole before installing Pi.Alert ?" "YES" if $ANSWER ; then PIHOLE_INSTALL=true msgbox "In the installation wizard of Pi-hole, select this options" \ - "'Install web admin interface' & 'Install web server lighttpd'" + "'Install web admin interface' & 'Install web server lighttpd'" fi fi @@ -119,21 +119,20 @@ ask_config() { DHCP_ACTIVE=false DHCP_ACTIVATE=false if $PIHOLE_ACTIVE ; then - DHCP_ACTIVE=`sudo grep DHCP_ACTIVE /etc/pihole/setupVars.conf | - awk -F= '/./{print $2}'` + DHCP_ACTIVE=`sudo grep DHCP_ACTIVE /etc/pihole/setupVars.conf | awk -F= '/./{print $2}'` if [ "$DHCP_ACTIVE" = "" ] ; then DHCP_ACTIVE=false; fi if ! $DHCP_ACTIVE ; then ask_yesno "Pi-hole DHCP server is not active." \ - "Do you want to activate Pi-hole DHCP server ?" - if $ANSWER ; then - DHCP_ACTIVATE=true - fi + "Do you want to activate Pi-hole DHCP server ?" + if $ANSWER ; then + DHCP_ACTIVATE=true + fi fi elif $PIHOLE_INSTALL ; then ask_yesno "Pi-hole installation." \ - "Do you want to activate Pi-hole DHCP server ?" + "Do you want to activate Pi-hole DHCP server ?" if $ANSWER ; then DHCP_ACTIVATE=true fi @@ -150,7 +149,7 @@ ask_config() { PIALERT_DEFAULT_PAGE=false if ! $PIHOLE_ACTIVE && ! $PIHOLE_INSTALL; then ask_yesno "As Pi-hole is not going to be available in this system," \ - "Do you want to use Pi.Alert as default web server page ?" "YES" + "Do you want to use Pi.Alert as default web server page ?" "YES" if $ANSWER ; then PIALERT_DEFAULT_PAGE=true fi @@ -158,10 +157,10 @@ ask_config() { # Ask Python version ask_option "What Python version do you want to use ?" \ - 3 \ - 0 " - Use Python already installed in the system (DEFAULT)" \ - 2 " - Use Python 2" \ - 3 " - Use Python 3" + 3 \ + 0 " - Use Python already installed in the system (DEFAULT)" \ + 2 " - Use Python 2" \ + 3 " - Use Python 3" if [ "$ANSWER" = "" ] ; then USE_PYTHON_VERSION=0 else @@ -171,10 +170,10 @@ ask_config() { # Ask e-mail notification config MAIL_REPORT=false ask_yesno "Pi.Alert can notify you by e-mail when a network event occurs" \ - "Do you want to activate this feature ?" + "Do you want to activate this feature ?" if $ANSWER ; then ask_yesno "e-mail notification needs a SMTP server (i.e. smtp.gmail.com)" \ - "Do you want to continue activating this feature ?" + "Do you want to continue activating this feature ?" MAIL_REPORT=$ANSWER fi @@ -195,10 +194,10 @@ ask_config() { # Ask Dynamic DNS config DDNS_ACTIVE=false ask_yesno "Pi.Alert can update your Dynamic DNS IP (i.e with www.dynu.net)" \ - "Do you want to activate this feature ?" + "Do you want to activate this feature ?" if $ANSWER ; then ask_yesno "Dynamics DNS updater needs a DNS with IP Update Protocol" \ - "(i.e with www.dynu.net). Do you want to continue ?" + "(i.e with www.dynu.net). Do you want to continue ?" DDNS_ACTIVE=$ANSWER fi @@ -218,11 +217,12 @@ ask_config() { # Final config message msgbox "Configuration finished. To updete the configuration, edit file:" \ - "$PIALERT_HOME/config/pialert.conf" + "$PIALERT_HOME/config/pialert.conf" msgbox "" "The installation will start now" } + # ------------------------------------------------------------------------------ # Install Pi-hole # ------------------------------------------------------------------------------ @@ -250,6 +250,7 @@ install_pihole() { PIHOLE_ACTIVE=true } + # ------------------------------------------------------------------------------ # Activate DHCP # ------------------------------------------------------------------------------ @@ -264,8 +265,7 @@ activate_DHCP() { print_msg "- Checking if DHCP is active..." if [ -e /etc/pihole ]; then - DHCP_ACTIVE= \ - `grep DHCP_ACTIVE /etc/pihole/setupVars.conf | awk -F= '/./{print $2}'` + DHCP_ACTIVE= `grep DHCP_ACTIVE /etc/pihole/setupVars.conf | awk -F= '/./{print $2}'` fi if $DHCP_ACTIVE ; then @@ -273,11 +273,11 @@ activate_DHCP() { fi print_msg "- Activating DHCP..." - sudo pihole -a enabledhcp "$DHCP_RANGE_START" "$DHCP_RANGE_END" \ - "$DHCP_ROUTER" "$DHCP_LEASE" "$DHCP_DOMAIN" 2>&1 >> "$LOG" + sudo pihole -a enabledhcp "$DHCP_RANGE_START" "$DHCP_RANGE_END" "$DHCP_ROUTER" "$DHCP_LEASE" "$DHCP_DOMAIN" 2>&1 >> "$LOG" DHCP_ACTIVE=true } + # ------------------------------------------------------------------------------ # Add Pi.Alert DNS # ------------------------------------------------------------------------------ @@ -322,6 +322,7 @@ install_lighttpd() { sudo /etc/init.d/lighttpd restart 2>&1 >> "$LOG" } + # ------------------------------------------------------------------------------ # Install arp-scan & dnsutils # ------------------------------------------------------------------------------ @@ -384,6 +385,7 @@ install_python() { fi } + # ------------------------------------------------------------------------------ # Check Python versions available # ------------------------------------------------------------------------------ @@ -426,6 +428,7 @@ install_pialert() { set_pialert_default_page } + # ------------------------------------------------------------------------------ # Download and uncompress Pi.Alert # ------------------------------------------------------------------------------ @@ -436,19 +439,18 @@ download_pialert() { fi print_msg "- Downloading installation tar file..." - curl -Lo "$INSTALL_DIR/pialert_latest.tar" \ - https://github.com/pucherot/Pi.Alert/raw/main/tar/pialert_latest.tar + curl -Lo "$INSTALL_DIR/pialert_latest.tar" https://github.com/pucherot/Pi.Alert/raw/main/tar/pialert_latest.tar echo "" print_msg "- Uncompressing tar file" - tar xf "$INSTALL_DIR/pialert_latest.tar" -C "$INSTALL_DIR" \ - --checkpoint=100 --checkpoint-action="ttyout=." 2>&1 >> "$LOG" + tar xf "$INSTALL_DIR/pialert_latest.tar" -C "$INSTALL_DIR" --checkpoint=100 --checkpoint-action="ttyout=." 2>&1 >> "$LOG" echo "" print_msg "- Deleting downloaded tar file..." rm -r "$INSTALL_DIR/pialert_latest.tar" } + # ------------------------------------------------------------------------------ # Configure Pi.Alert parameters # ------------------------------------------------------------------------------ @@ -474,6 +476,7 @@ configure_pialert() { set_pialert_parameter DHCP_ACTIVE "$DHCP_ACTIVE" } + # ------------------------------------------------------------------------------ # Set Pi.Alert parameter # ------------------------------------------------------------------------------ @@ -486,8 +489,7 @@ set_pialert_parameter() { VALUE="$2" fi - sed -i "/^$1.*=/s|=.*|= $VALUE|" $PIALERT_HOME/config/pialert.conf \ - 2>&1 >> "$LOG" + sed -i "/^$1.*=/s|=.*|= $VALUE|" $PIALERT_HOME/config/pialert.conf 2>&1 >> "$LOG" } @@ -497,20 +499,16 @@ set_pialert_parameter() { test_pialert() { print_msg "- Testing Pi.Alert HW vendors database update process..." print_msg "*** PLEASE WAIT A COUPLE OF MINUTES..." - stdbuf -i0 -o0 -e0 \ - $PYTHON_BIN $PIALERT_HOME/back/pialert.py update_vendors_silent 2>&1 \ - | tee -ai "$LOG" + stdbuf -i0 -o0 -e0 $PYTHON_BIN $PIALERT_HOME/back/pialert.py update_vendors_silent 2>&1 | tee -ai "$LOG" echo "" print_msg "- Testing Pi.Alert Internet IP Lookup..." - stdbuf -i0 -o0 -e0 \ - $PYTHON_BIN $PIALERT_HOME/back/pialert.py internet_IP 2>&1 | tee -ai "$LOG" + stdbuf -i0 -o0 -e0 $PYTHON_BIN $PIALERT_HOME/back/pialert.py internet_IP 2>&1 | tee -ai "$LOG" echo "" print_msg "- Testing Pi.Alert Network scan..." print_msg "*** PLEASE WAIT A COUPLE OF MINUTES..." - stdbuf -i0 -o0 -e0 \ - $PYTHON_BIN $PIALERT_HOME/back/pialert.py 1 2>&1 | tee -ai "$LOG" + stdbuf -i0 -o0 -e0 $PYTHON_BIN $PIALERT_HOME/back/pialert.py 1 2>&1 | tee -ai "$LOG" } # ------------------------------------------------------------------------------ @@ -528,8 +526,7 @@ add_jobs_to_crontab() { sed -i "s/\/$PYTHON_BIN/g" $PIALERT_HOME/install/pialert.cron fi - (crontab -l 2>/dev/null || : ; cat $PIALERT_HOME/install/pialert.cron) | \ - crontab - + (crontab -l 2>/dev/null || : ; cat $PIALERT_HOME/install/pialert.cron) | crontab - } # ------------------------------------------------------------------------------ @@ -551,20 +548,16 @@ publish_pialert() { print_msg "- Configuring http://pi.alert/ redirection..." if [ -e "$LIGHTTPD_CONF_DIR/conf-available/pialert_front.conf" ] ; then - sudo rm -r "$LIGHTTPD_CONF_DIR/conf-available/pialert_front.conf" \ - 2>&1 >> "$LOG" + sudo rm -r "$LIGHTTPD_CONF_DIR/conf-available/pialert_front.conf" 2>&1 >> "$LOG" fi - sudo cp "$PIALERT_HOME/install/pialert_front.conf" \ - "$LIGHTTPD_CONF_DIR/conf-available" 2>&1 >> "$LOG" + sudo cp "$PIALERT_HOME/install/pialert_front.conf" "$LIGHTTPD_CONF_DIR/conf-available" 2>&1 >> "$LOG" if [ -e "$LIGHTTPD_CONF_DIR/conf-enabled/pialert_front.conf" ] || \ [ -L "$LIGHTTPD_CONF_DIR/conf-enabled/pialert_front.conf" ] ; then - sudo rm -r "$LIGHTTPD_CONF_DIR/conf-enabled/pialert_front.conf" \ - 2>&1 >> "$LOG" + sudo rm -r "$LIGHTTPD_CONF_DIR/conf-enabled/pialert_front.conf" 2>&1 >> "$LOG" fi - sudo ln -s ../conf-available/pialert_front.conf \ - "$LIGHTTPD_CONF_DIR/conf-enabled/pialert_front.conf" 2>&1 >> "$LOG" + sudo ln -s ../conf-available/pialert_front.conf "$LIGHTTPD_CONF_DIR/conf-enabled/pialert_front.conf" 2>&1 >> "$LOG" print_msg "- Restarting lighttpd..." sudo /etc/init.d/lighttpd restart 2>&1 >> "$LOG" @@ -584,8 +577,7 @@ set_pialert_default_page() { if [ -e "$WEBROOT/index.lighttpd.html.orig" ] ; then sudo rm "$WEBROOT/index.lighttpd.html" 2>&1 >> "$LOG" else - sudo mv "$WEBROOT/index.lighttpd.html" \ - "$WEBROOT/index.lighttpd.html.orig" 2>&1 >> "$LOG" + sudo mv "$WEBROOT/index.lighttpd.html" "$WEBROOT/index.lighttpd.html.orig" 2>&1 >> "$LOG" fi fi @@ -638,8 +630,7 @@ msgbox() { END_DIALOG=false while ! $END_DIALOG ; do - whiptail --title "Pi.Alert Installation" --msgbox "$LINE1\\n\\n$LINE2" \ - $ROWS $COLS + whiptail --title "Pi.Alert Installation" --msgbox "$LINE1\\n\\n$LINE2" $ROWS $COLS BUTTON=$? ask_cancel ANSWER=true @@ -658,8 +649,7 @@ ask_yesno() { END_DIALOG=false while ! $END_DIALOG ; do - whiptail --title "Pi.Alert Installation" --yesno $DEF_BUTTON \ - "$LINE1\\n\\n$LINE2" $ROWS $COLS + whiptail --title "Pi.Alert Installation" --yesno $DEF_BUTTON "$LINE1\\n\\n$LINE2" $ROWS $COLS BUTTON=$? ask_cancel done @@ -677,8 +667,7 @@ ask_option() { END_DIALOG=false while ! $END_DIALOG ; do - ANSWER=$(whiptail --title "Pi.Alert Installation" --menu "$1" $ROWS $COLS \ - "${MENU_ARGS[@]}" 3>&2 2>&1 1>&3 ) + ANSWER=$(whiptail --title "Pi.Alert Installation" --menu "$1" $ROWS $COLS "${MENU_ARGS[@]}" 3>&2 2>&1 1>&3 ) BUTTON=$? ask_cancel CANCEL done @@ -690,8 +679,7 @@ ask_input() { END_DIALOG=false while ! $END_DIALOG ; do - ANSWER=$(whiptail --title "Pi.Alert Installation" --inputbox \ - "$LINE1\\n\\n$LINE2" $ROWS $COLS "$3" 3>&2 2>&1 1>&3 ) + ANSWER=$(whiptail --title "Pi.Alert Installation" --inputbox "$LINE1\\n\\n$LINE2" $ROWS $COLS "$3" 3>&2 2>&1 1>&3 ) BUTTON=$? ask_cancel CANCEL @@ -709,8 +697,7 @@ ask_cancel() { if [ "$BUTTON" = "1" ] && [ "$1" = "CANCEL" ] ; then BUTTON="255"; fi if [ "$BUTTON" = "255" ] ; then - whiptail --title "Pi.Alert Installation" --yesno --defaultno "$LINE0" \ - $ROWS $COLS + whiptail --title "Pi.Alert Installation" --yesno --defaultno "$LINE0" $ROWS $COLS if [ "$?" = "0" ] ; then process_error "Installation Aborted by User" diff --git a/install/pialert_update.sh b/install/pialert_update.sh index 03aabf96..024314d5 100644 --- a/install/pialert_update.sh +++ b/install/pialert_update.sh @@ -8,7 +8,6 @@ # Puche 2021 pi.alert.application@gmail.com GNU GPLv3 # ------------------------------------------------------------------------------ - # ------------------------------------------------------------------------------ # Variables # ------------------------------------------------------------------------------ @@ -57,8 +56,7 @@ create_backup() { print_msg "- Creating new Pi.Alert backup..." cd "$INSTALL_DIR" - tar cvf "$INSTALL_DIR"/pialert_update_backup_`date +"%Y-%m-%d_%H-%M"`.tar \ - pialert --checkpoint=100 --checkpoint-action="ttyout=." 2>&1 >> "$LOG" + tar cvf "$INSTALL_DIR"/pialert_update_backup_`date +"%Y-%m-%d_%H-%M"`.tar pialert --checkpoint=100 --checkpoint-action="ttyout=." 2>&1 >> "$LOG" echo "" } @@ -97,13 +95,13 @@ download_pialert() { fi print_msg "- Downloading update file..." - curl -Lo "$INSTALL_DIR/pialert_latest.tar" \ - https://github.com/pucherot/Pi.Alert/raw/main/tar/pialert_latest.tar + curl -Lo "$INSTALL_DIR/pialert_latest.tar" https://github.com/pucherot/Pi.Alert/raw/main/tar/pialert_latest.tar echo "" print_msg "- Uncompressing tar file" tar xf "$INSTALL_DIR/pialert_latest.tar" -C "$INSTALL_DIR" \ - --exclude='pialert/config/pialert.conf' --exclude='pialert/db/pialert.db' \ + --exclude='pialert/config/pialert.conf' \ + --exclude='pialert/db/pialert.db' \ --exclude='pialert/log/*' \ --checkpoint=100 --checkpoint-action="ttyout=." 2>&1 >> "$LOG" echo "" @@ -117,32 +115,47 @@ download_pialert() { # ------------------------------------------------------------------------------ update_config() { print_msg "- Config backup..." - cp "$PIALERT_HOME/config/pialert.conf" \ - "$PIALERT_HOME/config/pialert.conf.back" 2>&1 >> "$LOG" + cp "$PIALERT_HOME/config/pialert.conf" "$PIALERT_HOME/config/pialert.conf.back" 2>&1 >> "$LOG" print_msg "- Updating config file..." - sed -i '/VERSION/d' "$PIALERT_HOME/config/pialert.conf" 2>&1 >> "$LOG" - sed -i 's/PA_FRONT_URL/REPORT_DEVICE_URL/g' \ - "$PIALERT_HOME/config/pialert.conf" 2>&1 >> "$LOG" + sed -i '/VERSION/d' "$PIALERT_HOME/config/pialert.conf" 2>&1 >> "$LOG" + sed -i 's/PA_FRONT_URL/REPORT_DEVICE_URL/g' "$PIALERT_HOME/config/pialert.conf" 2>&1 >> "$LOG" if ! grep -Fq PIALERT_PATH "$PIALERT_HOME/config/pialert.conf" ; then - echo "PIALERT_PATH = '$PIALERT_HOME'" >> \ - "$PIALERT_HOME/config/pialert.conf" + echo "PIALERT_PATH = '$PIALERT_HOME'" >> "$PIALERT_HOME/config/pialert.conf" fi if ! grep -Fq QUERY_MYIP_SERVER "$PIALERT_HOME/config/pialert.conf" ; then - echo "QUERY_MYIP_SERVER = 'http://ipv4.icanhazip.com'" >> \ - "$PIALERT_HOME/config/pialert.conf" + echo "QUERY_MYIP_SERVER = 'http://ipv4.icanhazip.com'" >> "$PIALERT_HOME/config/pialert.conf" fi } # ------------------------------------------------------------------------------ -# +# DB DDL # ------------------------------------------------------------------------------ update_db() { print_msg "- Updating DB permissions..." sudo chgrp -R www-data $PIALERT_HOME/db 2>&1 >> "$LOG" chmod -R 770 $PIALERT_HOME/db 2>&1 >> "$LOG" + + print_msg "- Checking Parameters table..." + TAB=`sqlite3 $PIALERT_HOME/db/pialert.db "SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='Parameters' COLLATE NOCASE;"` 2>&1 >> "$LOG" + if [ "TAB" == "0" ] ; then + print_msg " - Checking Parameters table..." + sqlite3 $PIALERT_HOME/db/pialert.db "CREATE TABLE Parameters (par_ID STRING (50) PRIMARY KEY NOT NULL COLLATE NOCASE, par_Value STRING (250));" 2>&1 >> "$LOG" + sqlite3 $PIALERT_HOME/db/pialert.db "CREATE INDEX IDX_par_ID ON Parameters (par_ID COLLATE NOCASE);" 2>&1 >> "$LOG" + fi + + print_msg "- Checking Devices new columns..." + COL=`sqlite3 pialert.db "SELECT COUNT(*) FROM PRAGMA_TABLE_INFO ('Devices') WHERE name='dev_NewDevice' COLLATE NOCASE";` 2>&1 >> "$LOG" + if [ "TAB" == "0" ] ; then + sqlite3 $PIALERT_HOME/db/pialert.db "ALTER TABLE Devices ADD COLUMN dev_NewDevice BOOLEAN NOT NULL DEFAULT (1) CHECK (dev_NewDevice IN (0, 1) );" 2>&1 >> "$LOG" + sqlite3 $PIALERT_HOME/db/pialert.db "CREATE INDEX IDX_dev_NewDevice ON Devices (dev_NewDevice);" + + COL=`sqlite3 pialert.db "SELECT COUNT(*) FROM PRAGMA_TABLE_INFO ('Devices') WHERE name='dev_Location' COLLATE NOCASE";` 2>&1 >> "$LOG" + if [ "TAB" == "0" ] ; then + sqlite3 $PIALERT_HOME/db/pialert.db "ALTER TABLE Devices ADD COLUMN dev_Location STRING(250) COLLATE NOCASE);" 2>&1 >> "$LOG" + fi } # ------------------------------------------------------------------------------ @@ -151,20 +164,16 @@ update_db() { test_pialert() { print_msg "- Testing Pi.Alert HW vendors database update process..." print_msg "*** PLEASE WAIT A COUPLE OF MINUTES..." - stdbuf -i0 -o0 -e0 \ - $PYTHON_BIN $PIALERT_HOME/back/pialert.py update_vendors_silent 2>&1 \ - | tee -ai "$LOG" + stdbuf -i0 -o0 -e0 $PYTHON_BIN $PIALERT_HOME/back/pialert.py update_vendors_silent 2>&1 | tee -ai "$LOG" echo "" print_msg "- Testing Pi.Alert Internet IP Lookup..." - stdbuf -i0 -o0 -e0 \ - $PYTHON_BIN $PIALERT_HOME/back/pialert.py internet_IP 2>&1 | tee -ai "$LOG" + stdbuf -i0 -o0 -e0 $PYTHON_BIN $PIALERT_HOME/back/pialert.py internet_IP 2>&1 | tee -ai "$LOG" echo "" print_msg "- Testing Pi.Alert Network scan..." print_msg "*** PLEASE WAIT A COUPLE OF MINUTES..." - stdbuf -i0 -o0 -e0 \ - $PYTHON_BIN $PIALERT_HOME/back/pialert.py 1 2>&1 | tee -ai "$LOG" + stdbuf -i0 -o0 -e0 $PYTHON_BIN $PIALERT_HOME/back/pialert.py 1 2>&1 | tee -ai "$LOG" } # ------------------------------------------------------------------------------ diff --git a/tar/create_tar.sh b/tar/create_tar.sh index a943c122..aecfd4fb 100644 --- a/tar/create_tar.sh +++ b/tar/create_tar.sh @@ -25,4 +25,3 @@ tar cvf pialert/tar/pialert_$PIALERT_VERSION.tar --exclude="pialert/tar" --exclu ln -s pialert_$PIALERT_VERSION.tar pialert/tar/pialert_latest.tar ls -l pialert/tar/pialert*.tar - diff --git a/tar/pialert_2.61.tar b/tar/pialert_2.70.tar similarity index 99% rename from tar/pialert_2.61.tar rename to tar/pialert_2.70.tar index ef7019c0..c3dbb34d 100644 Binary files a/tar/pialert_2.61.tar and b/tar/pialert_2.70.tar differ diff --git a/tar/pialert_latest.tar b/tar/pialert_latest.tar index ef7019c0..c3dbb34d 100644 Binary files a/tar/pialert_latest.tar and b/tar/pialert_latest.tar differ