Compare commits

...

12 Commits
v2.52 ... v2.55

Author SHA1 Message Date
pucherot
0e3f14dd9d v2.55 2021-01-14 12:45:11 +01:00
pucherot
dbe0a0548b v2.54 2021-01-13 12:38:51 +01:00
pucherot
e8f723d985 Bugfix #6 v2.54 2021-01-13 12:18:13 +01:00
pucherot
cc50d0f75e Update pialert.py 2021-01-13 08:30:06 +01:00
pucherot
a473845242 Merge pull request #9 from nebbywan/main
Add Python3 support at line 31 and fix case mismatch
2021-01-12 21:17:09 +01:00
Zach McDonough
bda526b202 Update pialert.py
Add support for Python3 @ line 31
Fix case mismatch @ line 1216
2021-01-12 09:26:46 -08:00
pucherot
9057e41ff8 Update INSTALL.md 2021-01-12 17:12:36 +01:00
pucherot
75bb53fdd1 Merge pull request #7 from derekpurdy/patch-1
Update INSTALL.md
2021-01-12 17:10:52 +01:00
Derek Purdy
e7ebd9bab5 Update INSTALL.md 2021-01-12 10:53:49 -05:00
pucherot
30aeab305d Tar 2021-01-11 18:17:40 +01:00
pucherot
3e6d9847be Update INSTALL.md 2021-01-11 17:17:44 +01:00
pucherot
3c34c822e7 Update INSTALL.md 2021-01-11 17:09:43 +01:00
8 changed files with 80 additions and 44 deletions

View File

@@ -1,6 +1,6 @@
VERSION = '2.52'
VERSION = '2.55'
VERSION_YEAR = '2021'
VERSION_DATE = '2021-01-11'
VERSION_DATE = '2021-01-13'
DB_PATH = '/home/pi/pialert/db/pialert.db'
LOG_PATH = '/home/pi/pialert/log'
@@ -17,6 +17,8 @@ REPORT_MAIL = False
REPORT_FROM = 'Pi.Alert <' + SMTP_USER +'>'
REPORT_TO = 'user@gmail.com'
# QUERY_MYIP_SERVER = 'https://diagnostic.opendns.com/myip'
QUERY_MYIP_SERVER = 'http://ipv4.icanhazip.com'
DDNS_ACTIVE = False
DDNS_DOMAIN = 'your_domain.freeddns.org'
DDNS_USER = 'dynu_user'

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
# Pi.Alert v2.52 / 2021-01-11
# Pi.Alert v2.55 / 2021-01-13
# Puche 2020
# GNU GPLv3
@@ -28,6 +28,9 @@ import csv
# CONFIG CONSTANTS
#===============================================================================
PIALERT_PATH = os.path.dirname(os.path.abspath(__file__))
if (sys.version_info > (3,0)):
exec(open(PIALERT_PATH + "/pialert.conf").read())
else:
execfile (PIALERT_PATH + "/pialert.conf")
@@ -156,8 +159,10 @@ def get_internet_IP ():
# dig_args = ['dig', '+short', 'myip.opendns.com',
# '@resolver1.opendns.com']
# BUGFIX #12 - Query IPv4 address (not IPv6)
# Using 'curl' instead of 'dig'
curl_args = ['curl', '-s', 'https://diagnostic.opendns.com/myip']
# curl_args = ['curl', '-s', 'https://diagnostic.opendns.com/myip']
curl_args = ['curl', '-s', QUERY_MYIP_SERVER]
curl_output = subprocess.check_output (curl_args, universal_newlines=True)
# Check result is an IP
@@ -292,9 +297,12 @@ def update_devices_MAC_vendors ():
#-------------------------------------------------------------------------------
def query_MAC_vendor (pMAC):
try :
# BUGFIX #6 - Fix pMAC parameter as numbers
pMACstr = str(pMAC)
# Check MAC parameter
mac = pMAC.replace (':','')
if len(pMAC) != 17 or len(mac) != 12 :
mac = pMACstr.replace (':','')
if len(pMACstr) != 17 or len(mac) != 12 :
return -2
# Search vendor in HW Vendors DB
@@ -447,8 +455,28 @@ def execute_arpscan (pRetries):
devices_list = [device.groupdict()
for device in re.finditer (re_pattern, arpscan_output)]
# Bugfix #5 - Delete duplicated MAC's with different IP's
# TEST - Force duplicated device
# devices_list.append(devices_list[0])
# Delete duplicate MAC
unique_mac = []
unique_devices = []
for device in devices_list :
if device['mac'] not in unique_mac:
unique_mac.append(device['mac'])
unique_devices.append(device)
# DEBUG
# print (devices_list)
# print (unique_mac)
# print (unique_devices)
# print (len(devices_list))
# print (len(unique_mac))
# print (len(unique_devices))
# return list
return devices_list
return unique_devices
#-------------------------------------------------------------------------------
def copy_pihole_network ():
@@ -1210,7 +1238,7 @@ def write_file (pPath, pText):
file.close()
else:
file = open (pPath, 'w', encoding='utf-8')
file.write (ptext)
file.write (pText)
file.close()
#-------------------------------------------------------------------------------

Binary file not shown.

View File

@@ -3,7 +3,7 @@
Initially designed to run on a Raspberry PI, probably it can run on many other
Linux distributions.
Stimated time: 20'
Estimated time: 20'
### Dependencies
| Dependency | Comments |
@@ -34,7 +34,7 @@ Stimated time: 20'
password: raspberry
```
5 - Change de default password of pi user
5 - Change the default password of pi user
```
passwd
```
@@ -115,7 +115,7 @@ Stimated time: 20'
## Pi.Alert
<!--- --------------------------------------------------------------------- --->
1- Download Pi.Alert and uncmompress
1- Download Pi.Alert and uncompress
```
curl -LO https://github.com/pucherot/Pi.Alert/raw/main/install/pialert_latest.tar
tar xvf pialert_latest.tar
@@ -127,7 +127,7 @@ Stimated time: 20'
sudo ln -s /home/pi/pialert/front /var/www/html/pialert
```
3 - Update lighttp config
3 - Update lighttpd config
```
sudo sh -c "printf '\n\n\$HTTP[\"host\"] == \"pi.alert\" {\n server.document-root = \"/var/www/html/pialert/\"\n}\n' >> /etc/lighttpd/external.conf"
sudo /etc/init.d/lighttpd restart
@@ -144,7 +144,7 @@ Stimated time: 20'
```
nano ~/pialert/back/pialert.conf
```
- if you want to use email reporting, configure this parameters
- If you want to use email reporting, configure this parameters
```
REPORT_MAIL = True
SMTP_USER = 'user@gmail.com'
@@ -152,7 +152,7 @@ Stimated time: 20'
REPORT_TO = 'user@gmail.com'
```
- if you want to update yout Dynamic DNS, configure this parameters
- If you want to update your Dynamic DNS, configure this parameters
```
DDNS_ACTIVE = True
DDNS_DOMAIN = 'your_domain.freeddns.org'
@@ -161,7 +161,7 @@ Stimated time: 20'
DDNS_UPDATE_URL = 'https://api.dynu.com/nic/update?'
```
- if you have installed Pi.hole and DHCP, activate this parameters
- If you have installed Pi.hole and DHCP, activate this parameters
```
PIHOLE_ACTIVE = True
DHCP_ACTIVE = True
@@ -183,7 +183,13 @@ Stimated time: 20'
(crontab -l 2>/dev/null; cat ~/pialert/back/pialert.cron) | crontab -
```
9 - Use admin panel to configure the devices
9 - Add DB permissions to the web-server user
```
sudo chgrp -R www-data ~/pialert/db
chmod -R 770 ~/pialert/db
```
10 - Use admin panel to configure the devices
- http://pi.alert/

View File

@@ -4,7 +4,7 @@
&copy; 2021 Puche
<!-- To the right -->
<div class="pull-right no-hidden-xs">
Pi.alert&nbsp&nbsp2.52&nbsp&nbsp<small>(2021-01-11)</small>
Pi.alert&nbsp&nbsp2.55&nbsp&nbsp<small>(2021-01-13)</small>
</div>
</footer>

View File

@@ -1,15 +1,15 @@
#
PIALERT_VERSION=2.52
PIALERT_VERSION=2.55
PIALERT_DEV_PATH=/media/WD_4TB/dev
cd $PIALERT_DEV_PATH
tar tvf pialert/install/pialert_$PIALERT_VERSION.tar | wc -l
rm pialert/install/pialert_$PIALERT_VERSION.tar
tar tvf pialert/install/pialert_latest.tar | wc -l
rm pialert/install/pialert_*.tar
tar cvf pialert/install/pialert_$PIALERT_VERSION.tar --exclude="pialert/install" --exclude="pialert/.git" pialert | wc -l
rm pialert/install/pialert_latest.tar
# rm pialert/install/pialert_latest.tar
ln -s pialert_$PIALERT_VERSION.tar pialert/install/pialert_latest.tar

Binary file not shown.