Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP - Not ready for Merge - Consolidate spread Pi.Alert work #1

Closed
wants to merge 30 commits into from

Conversation

fosspill
Copy link

@fosspill fosspill commented Mar 30, 2022

This PR adds a variety of changes.
Since the development of features for Pi.Alert has been so spread I've tried my best to consolidate it all into one single package.

The dockerfile will likely need some work for both nmap support and for curl to properly pull the device lists

Remaining:

  • Some cleanup
  • Install script updates
  • Ensuring new config file options can be migrated properly
  • Ensuring proper credit to all authors
  • Dockerfile changes and tests

radarjd and others added 29 commits January 28, 2021 22:10
causes lighttpd to match any subdomain of pi.alert (e.g. www.pi.alert) to this virtual server

this addresses issue pucherot#54
Corrected folder path for linking conf-available to conf-enabled.
Fork is focused on my own need at the moment, but PRs and other maintainers are very welcome
Add: Webhook and NTFY support
Change: Reorganize options
Pull changes from jokob-sk
@fosspill fosspill changed the title WIP - Not ready for Merge - Multiple changes WIP - Not ready for Merge - Consolidate spread Pi.Alert work Mar 30, 2022
@fosspill
Copy link
Author

@jokob-sk I'd gladly split this across multiple PRs when it's ready for merging

@jokob-sk
Copy link
Owner

jokob-sk commented Apr 3, 2022

Thanks a lot for the work on this! Happy to merge it once you think it's ready to do so.

@jokob-sk
Copy link
Owner

jokob-sk commented Apr 4, 2022

I've tried to build a docker image with your fork (https://github.com/fosspill/Pi.Alert). I had to update the dockerfile a bit (see below). But afterwards, it's building fine however, I'm getting an error for the NMAP scan option:

    arpscan_devices = execute_nmap (NMAP_OPTIONS, arpscan_devices)                                                                 
  File "/home/pi/pialert/back/pialert.py", line 526, in execute_nmap                                                               
    nmap_output = subprocess.check_output (nmap_args, universal_newlines=True)                                                     
  File "/usr/lib/python2.7/subprocess.py", line 216, in check_output                                                               
    process = Popen(stdout=PIPE, *popenargs, **kwargs)                                                                             
  File "/usr/lib/python2.7/subprocess.py", line 394, in __init__                                                                   
    errread, errwrite)                                                                                                             
  File "/usr/lib/python2.7/subprocess.py", line 1047, in _execute_child                                                            
    raise child_exception                                                                                                          
OSError: [Errno 2] No such file or directory 

I've also pushed the containers into a separate image if you'd like to check/test them yourself: https://hub.docker.com/r/jokobsk/pialert_merge_test

Updated Docker file:

(download this and overwrite the content of the docker file with the below)

FROM debian:buster-slim

ARG myinstall="install --no-install-recommends"

#Update and reduce image size
RUN apt update \
    && apt $myinstall -y \
    && apt $myinstall apt-utils -y \
    && apt $myinstall cron -y \
    && apt install git -y \
    && apt $myinstall sudo -y

#add the pi user
RUN useradd -ms /bin/bash pi 
WORKDIR /home/pi
# Lighttpd & PHP
RUN apt $myinstall lighttpd -y \
    && mv /var/www/html/index.lighttpd.html /var/www/html/index.lighttpd.html.old \
    && ln -s ~/pialert/install/index.html /var/www/html/index.html \
    && apt $myinstall php php-cgi php-fpm php-sqlite3 -y \
    && lighttpd-enable-mod fastcgi-php \
    && apt $myinstall sqlite3 -y

# arp-scan, Python, ip tools
RUN apt install arp-scan -y \
    && apt $myinstall dnsutils net-tools -y \
    && apt $myinstall python -y 
RUN  apt install python-pip -y \
    && pip install --upgrade pip  \
    && pip install requests \
    && apt $myinstall iproute2 -y

# Pi.Alert
RUN apt clean \
    # && git clone https://github.com/jokob-sk/Pi.Alert.git pialert     \ 
    && git clone https://github.com/fosspill/Pi.Alert pialert     \ 
    # delete .git specific files to make the image smaller
    && rm -r /home/pi/pialert/.git \
    && ln -s /home/pi/pialert/front /var/www/html/pialert  \
    && python /home/pi/pialert/back/pialert.py update_vendors \    
    && (crontab -l 2>/dev/null; cat /home/pi/pialert/install/pialert.cron) | crontab - \
    && chgrp -R www-data /home/pi/pialert/db \
    && chmod -R 770 /home/pi/pialert/db \
    # changing the default port number 80 to something random, here 20211
    && sed -ie 's/= 80/= 20211/g' /etc/lighttpd/lighttpd.conf \
    && service lighttpd restart 

# Expose the below port
EXPOSE 20211

# Set up startup script to run two commands, cron and the lighttpd server
ADD start.sh /home/pi
RUN chmod +x /home/pi/start.sh

CMD ["/home/pi/start.sh"]

@ghost
Copy link

ghost commented Apr 24, 2022

I’ve forked cjd’s branch and fixed the errors which were present during the building of the Docker image.

There are some other commits which fix minor issues but mainly they modify the webui.

https://github.com/0x09F911029D74E35BD84156C5635688C0/docker.pi-alert/commits/develop

@jokob-sk
Copy link
Owner

Hi @0x09F911029D74E35BD84156C5635688C0 !

Thanks for that! However, this doesn't run properly either. Getting this error:

Pi.Alert 3.02 (2021-04-24)
---------------------------------------------------------
Scan Devices
    ScanCycle: 1
    Timestamp: 2022-04-25 19:51:00

Scanning...
    arp-scan Method...
    nmap Method...
Traceback (most recent call last):
  File "pialert.py", line 1548, in <module>
    sys.exit(main())
  File "pialert.py", line 86, in main
    res = scan_network()
  File "pialert.py", line 371, in scan_network
    arpscan_devices = execute_nmap (NMAP_OPTIONS, arpscan_devices)
  File "pialert.py", line 523, in execute_nmap
    nmap_output = subprocess.check_output (nmap_args, universal_newlines=True)
  File "/usr/lib/python2.7/subprocess.py", line 216, in check_output
    process = Popen(stdout=PIPE, *popenargs, **kwargs)
  File "/usr/lib/python2.7/subprocess.py", line 394, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1047, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

Also, your build seems to have some issues with the crontab file. I'd recommend starting form my fork (https://github.com/jokob-sk/Pi.Alert) and trying to merge the remaining forks.

Feel free to check the image I've built for you: https://registry.hub.docker.com/r/jokobsk/pialert_merge_test

The docker file is the same as in my above comment, only replaced this line to point to your fork:

&& git clone https://github.com/fosspill/Pi.Alert pialert

Thanks in advance for helping!

@ghost
Copy link

ghost commented Apr 25, 2022

Apologies, I was working on merging fosspill:main into the branch, which introduced the error.

The current branch is now experimental

jokob-sk pushed a commit that referenced this pull request Jul 16, 2022
@jokob-sk jokob-sk deleted the branch jokob-sk:old-main-16-07-2022 July 17, 2022 00:00
@jokob-sk jokob-sk closed this Jul 17, 2022
jokob-sk pushed a commit that referenced this pull request Jul 17, 2022
jokob-sk pushed a commit that referenced this pull request Jul 26, 2022
Update From jokob-sk/Pi.Alert
jokob-sk pushed a commit that referenced this pull request Jan 31, 2023
@systemik systemik mentioned this pull request Sep 25, 2024
2 tasks
jokob-sk pushed a commit that referenced this pull request Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

nmap support
7 participants