From 5d55090372a7f95371a40f40484b11f86c80fbde Mon Sep 17 00:00:00 2001 From: Leo Dirac Date: Tue, 9 Jan 2024 18:15:49 -0800 Subject: [PATCH 01/14] Simple RTSP scanning script --- api/rtsp_scan.sh | 49 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100755 api/rtsp_scan.sh diff --git a/api/rtsp_scan.sh b/api/rtsp_scan.sh new file mode 100755 index 0000000..d67efc2 --- /dev/null +++ b/api/rtsp_scan.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +# Function to install necessary dependencies +install_dependencies() { + echo "Installing dependencies..." + sudo apt update + sudo apt install -y nmap net-tools +} + +# Function to find subnets +find_subnets() { + # This function finds the subnets associated with your physical network interfaces + # It excludes loopback, virtual, and docker interfaces + + # List all network interfaces except loopback and docker/virtual interfaces + local interfaces=$(ip -br link | awk '$1 !~ /^lo|docker|veth|br-|virbr/ {print $1}') + + # Loop through each interface to find its subnet + for interface in $interfaces; do + # Get the IP address and subnet mask for each interface + ip -4 addr show $interface | grep -oP '(?<=inet\s)\d+(\.\d+){3}/\d+' | while read -r subnet; do + echo "$subnet" + done + done +} + + +# Function to scan a given subnet +scan_subnet() { + local subnet=$1 + echo "Scanning subnet $subnet..." + + # Run Nmap with Grepable output, then parse to list hosts with open port 554 + nmap -p 554 --open -oG - $subnet | grep '/open/' | awk '{ print $2 }' | while read -r host; do + echo "rtsp://admin:admin@$host:554" + done +} + + +# Main execution +main() { + #install_dependencies + find_subnets | while read -r subnet; do + scan_subnet "$subnet" + done +} + +main + From ceb9c59be89ed9739deadad15f77d69874b4c6e2 Mon Sep 17 00:00:00 2001 From: Leo Dirac Date: Wed, 17 Jan 2024 15:06:58 -0800 Subject: [PATCH 02/14] Limiting the scope of big RTSP scans to some heuristic likely to find things. --- api/rtsp_scan.sh | 44 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/api/rtsp_scan.sh b/api/rtsp_scan.sh index d67efc2..aa78799 100755 --- a/api/rtsp_scan.sh +++ b/api/rtsp_scan.sh @@ -1,5 +1,12 @@ #!/bin/bash +# check if the -v flag is present +if [[ $1 == "-v" ]]; then + VERBOSE=1 +else + VERBOSE=0 +fi + # Function to install necessary dependencies install_dependencies() { echo "Installing dependencies..." @@ -19,6 +26,8 @@ find_subnets() { for interface in $interfaces; do # Get the IP address and subnet mask for each interface ip -4 addr show $interface | grep -oP '(?<=inet\s)\d+(\.\d+){3}/\d+' | while read -r subnet; do + # check if the subnet is bigger than /24 first + # first echo "$subnet" done done @@ -28,10 +37,41 @@ find_subnets() { # Function to scan a given subnet scan_subnet() { local subnet=$1 - echo "Scanning subnet $subnet..." + + # parse the subnet string, which looks like "192.168.1.7/16" into base and mask + local base=$(echo "$subnet" | cut -d '/' -f 1) + local mask=$(echo "$subnet" | cut -d '/' -f 2) + + # If the mask is smaller than /24, we'll want to use a faster scan + # Otherwise, we'll use a slower but more reliable scan + if [[ $mask -lt 24 ]]; then + if [[ $mask -lt 22 ]]; then + # Limit size of scan + mask=22 + if [[ $VERBOSE -eq 1 ]]; then + echo "Limiting subnet $subnet to /$mask so scan doesn't take forever." + echo "For a full scan, run 'nmap -T4 -p 554 --open -oG - $subnet'" + fi + fi + # T5 is "insane" and super fast, but can be unreliable. (e.g. 5s for /22) + # Limiting to T4 since that finds things reliably for me. + SPEED=-T4 + else + # It's 24 or less, so use a fast but reliable scan + SPEED=-T4 + fi + # re-assamble the subnet string + subnet="$base/$mask" + if [[ $VERBOSE -eq 1 ]]; then + echo "Scanning subnet $subnet at speed $SPEED" + fi + + # T5 is "insane" and super fast, but perhaps unreliable. (e.g. 5s for /22) + # T4 is safer, but much slower. (e.g. 26s for /22) + SPEED=-T5 # Run Nmap with Grepable output, then parse to list hosts with open port 554 - nmap -p 554 --open -oG - $subnet | grep '/open/' | awk '{ print $2 }' | while read -r host; do + nmap $SPEED -p 554 --open -oG - $subnet | grep '/open/' | awk '{ print $2 }' | while read -r host; do echo "rtsp://admin:admin@$host:554" done } From 306c99803f33109c6c4f27d01b119646ae123d6d Mon Sep 17 00:00:00 2001 From: Leo Dirac Date: Wed, 31 Jan 2024 17:28:51 -0800 Subject: [PATCH 03/14] Moving the docker-compose into the root dir. --- deploy/docker-compose.yml => docker-compose.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename deploy/docker-compose.yml => docker-compose.yml (100%) diff --git a/deploy/docker-compose.yml b/docker-compose.yml similarity index 100% rename from deploy/docker-compose.yml rename to docker-compose.yml From 5e4d0fc6319cfc4941a76711b693006124d2ae51 Mon Sep 17 00:00:00 2001 From: Leo Dirac Date: Wed, 31 Jan 2024 17:29:27 -0800 Subject: [PATCH 04/14] Moving to port 80 --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 4321534..7a030dc 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,7 +2,7 @@ services: frontend: image: docker.io/groundlight/monitoring-notification-server-frontend:latest ports: - - "3000:3000" + - "3000:80" depends_on: - backend backend: From 9b61c5e701828440ae28d5cfdd02d965bcbc5e76 Mon Sep 17 00:00:00 2001 From: Leo Dirac Date: Wed, 31 Jan 2024 17:33:34 -0800 Subject: [PATCH 05/14] iter --- docker-compose.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/docker-compose.yml b/docker-compose.yml index 7a030dc..91ecb0f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,3 +1,4 @@ +version: "3" services: frontend: image: docker.io/groundlight/monitoring-notification-server-frontend:latest From 1b77d15c9418c73bb187daa254a12c42aa180f40 Mon Sep 17 00:00:00 2001 From: Leo Dirac Date: Wed, 31 Jan 2024 17:33:51 -0800 Subject: [PATCH 06/14] Version 2 --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 91ecb0f..2f7703e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,4 @@ -version: "3" +version: "2" services: frontend: image: docker.io/groundlight/monitoring-notification-server-frontend:latest From c6108dd474dcd39524df5fee3de9ca929059db9d Mon Sep 17 00:00:00 2001 From: Leo Dirac Date: Wed, 31 Jan 2024 17:35:39 -0800 Subject: [PATCH 07/14] Removing usb volume. --- docker-compose.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 2f7703e..0361f87 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,5 +16,6 @@ services: - /dev/video2:/dev/video2 - /dev/video3:/dev/video3 privileged: true - volumes: - - /dev/bus/usb:/dev/bus/usb + # Seems balena doesn't like volume mounting. + #volumes: + #- /dev/bus/usb:/dev/bus/usb From d96ae4324dac32ecae1a8dfda3c7d8a94ac9c05e Mon Sep 17 00:00:00 2001 From: Leo Dirac Date: Wed, 31 Jan 2024 17:42:22 -0800 Subject: [PATCH 08/14] Swapping 80/3000 on port mapping. --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 0361f87..b8d1e4a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,7 +3,7 @@ services: frontend: image: docker.io/groundlight/monitoring-notification-server-frontend:latest ports: - - "3000:80" + - "80:3000" depends_on: - backend backend: From fea915ef9bcc69e61c549ac27ac8479e87a70c96 Mon Sep 17 00:00:00 2001 From: Leo Dirac Date: Thu, 1 Feb 2024 11:24:45 -0800 Subject: [PATCH 09/14] WIP refactoring. --- {api => BECS/api}/gl_process.py | 0 {api => BECS/api}/index.py | 0 {api => BECS/api}/logging_config.yaml | 0 {api => BECS/api}/notifications.py | 0 {api => BECS/api}/rtsp_scan.sh | 0 {app => HFE/app}/detectors/page.tsx | 0 {app => HFE/app}/favicon.ico | Bin {app => HFE/app}/globals.css | 0 {app => HFE/app}/layout.tsx | 0 {app => HFE/app}/page.tsx | 0 {app => HFE/app}/settings/page.tsx | 0 {app => HFE/app}/sources/page.tsx | 0 README.md | 6 +++--- docker-compose.yml | 10 +++++----- 14 files changed, 8 insertions(+), 8 deletions(-) rename {api => BECS/api}/gl_process.py (100%) rename {api => BECS/api}/index.py (100%) rename {api => BECS/api}/logging_config.yaml (100%) rename {api => BECS/api}/notifications.py (100%) rename {api => BECS/api}/rtsp_scan.sh (100%) rename {app => HFE/app}/detectors/page.tsx (100%) rename {app => HFE/app}/favicon.ico (100%) rename {app => HFE/app}/globals.css (100%) rename {app => HFE/app}/layout.tsx (100%) rename {app => HFE/app}/page.tsx (100%) rename {app => HFE/app}/settings/page.tsx (100%) rename {app => HFE/app}/sources/page.tsx (100%) diff --git a/api/gl_process.py b/BECS/api/gl_process.py similarity index 100% rename from api/gl_process.py rename to BECS/api/gl_process.py diff --git a/api/index.py b/BECS/api/index.py similarity index 100% rename from api/index.py rename to BECS/api/index.py diff --git a/api/logging_config.yaml b/BECS/api/logging_config.yaml similarity index 100% rename from api/logging_config.yaml rename to BECS/api/logging_config.yaml diff --git a/api/notifications.py b/BECS/api/notifications.py similarity index 100% rename from api/notifications.py rename to BECS/api/notifications.py diff --git a/api/rtsp_scan.sh b/BECS/api/rtsp_scan.sh similarity index 100% rename from api/rtsp_scan.sh rename to BECS/api/rtsp_scan.sh diff --git a/app/detectors/page.tsx b/HFE/app/detectors/page.tsx similarity index 100% rename from app/detectors/page.tsx rename to HFE/app/detectors/page.tsx diff --git a/app/favicon.ico b/HFE/app/favicon.ico similarity index 100% rename from app/favicon.ico rename to HFE/app/favicon.ico diff --git a/app/globals.css b/HFE/app/globals.css similarity index 100% rename from app/globals.css rename to HFE/app/globals.css diff --git a/app/layout.tsx b/HFE/app/layout.tsx similarity index 100% rename from app/layout.tsx rename to HFE/app/layout.tsx diff --git a/app/page.tsx b/HFE/app/page.tsx similarity index 100% rename from app/page.tsx rename to HFE/app/page.tsx diff --git a/app/settings/page.tsx b/HFE/app/settings/page.tsx similarity index 100% rename from app/settings/page.tsx rename to HFE/app/settings/page.tsx diff --git a/app/sources/page.tsx b/HFE/app/sources/page.tsx similarity index 100% rename from app/sources/page.tsx rename to HFE/app/sources/page.tsx diff --git a/README.md b/README.md index c9726d1..f4e24fd 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,6 @@ We welcome pull requests! ### Organization of source code -- `app` is the frontend TypeScript / React application -- `api` is the backend Python / FastApi application -- `deploy` has code for deploying the system +- `HFE` is the "hub frontend". This is a Typescript / React app that serves as the frontend for the system. +- `BECS` is the "backend config server". This is an HTTP server which serves the configuration for the detectors. +- `deploy` has code for deploying the system in various environments diff --git a/docker-compose.yml b/docker-compose.yml index b8d1e4a..01ac54d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,13 +1,13 @@ version: "2" services: - frontend: - image: docker.io/groundlight/monitoring-notification-server-frontend:latest + HFE: + build: ./HFE ports: - "80:3000" depends_on: - - backend - backend: - image: docker.io/groundlight/monitoring-notification-server-backend:latest + - BECS + BECS: + build: ./BECS ports: - "8000:8000" devices: From 421f13a4afaac8ca1cc2c56fcd67b987a49c908c Mon Sep 17 00:00:00 2001 From: Leo Dirac Date: Thu, 1 Feb 2024 19:40:17 +0000 Subject: [PATCH 10/14] Lots of moving directories around. --- README.md | 4 ++-- .../Dockerfile | 0 .../Dockerfile-armv7 | 0 {BECS => backendconfigserver}/api/gl_process.py | 0 {BECS => backendconfigserver}/api/index.py | 0 .../api/logging_config.yaml | 0 {BECS => backendconfigserver}/api/notifications.py | 0 {BECS => backendconfigserver}/api/rtsp_scan.sh | 0 .../pi_requirements.txt | 0 .../requirements.txt | 0 docker-compose.yml | 10 +++++----- frontend.Dockerfile => hubfrontend/Dockerfile | 0 .../Dockerfile-arm7 | 0 {HFE => hubfrontend}/app/detectors/page.tsx | 0 {HFE => hubfrontend}/app/favicon.ico | Bin {HFE => hubfrontend}/app/globals.css | 0 {HFE => hubfrontend}/app/layout.tsx | 0 {HFE => hubfrontend}/app/page.tsx | 0 {HFE => hubfrontend}/app/settings/page.tsx | 0 {HFE => hubfrontend}/app/sources/page.tsx | 0 {components => hubfrontend/components}/Dropdown.tsx | 0 .../components}/EditDetectorOverlay.tsx | 0 .../components}/EditNotificationsOverlay.tsx | 0 {components => hubfrontend/components}/Nav.tsx | 0 .../components}/NewCameraOverlay.tsx | 0 .../components}/PushStacklightConfigButton.tsx | 0 {components => hubfrontend/components}/Spinner.tsx | 0 .../images}/Groundlight-Detector-Dashboard.png | Bin .../images}/Groundlight-Docker-Frontpage.png | Bin middleware.ts => hubfrontend/middleware.ts | 0 next.config.js => hubfrontend/next.config.js | 0 package-lock.json => hubfrontend/package-lock.json | 0 package.json => hubfrontend/package.json | 0 postcss.config.js => hubfrontend/postcss.config.js | 0 {public => hubfrontend/public}/favicon.ico | Bin .../tailwind.config.js | 0 tsconfig.json => hubfrontend/tsconfig.json | 0 {utils => hubfrontend/utils}/types.ts | 0 .../utils}/useAvailableDetectors.ts | 0 {utils => hubfrontend/utils}/useDetectors.ts | 0 {utils => hubfrontend/utils}/useEscape.tsx | 0 {utils => hubfrontend/utils}/useImageSources.ts | 0 {utils => hubfrontend/utils}/useKeypress.tsx | 0 43 files changed, 7 insertions(+), 7 deletions(-) rename backend.Dockerfile => backendconfigserver/Dockerfile (100%) rename backend-armv7.Dockerfile => backendconfigserver/Dockerfile-armv7 (100%) rename {BECS => backendconfigserver}/api/gl_process.py (100%) rename {BECS => backendconfigserver}/api/index.py (100%) rename {BECS => backendconfigserver}/api/logging_config.yaml (100%) rename {BECS => backendconfigserver}/api/notifications.py (100%) rename {BECS => backendconfigserver}/api/rtsp_scan.sh (100%) rename pi_requirements.txt => backendconfigserver/pi_requirements.txt (100%) rename requirements.txt => backendconfigserver/requirements.txt (100%) rename frontend.Dockerfile => hubfrontend/Dockerfile (100%) rename frontend-armv7.Dockerfile => hubfrontend/Dockerfile-arm7 (100%) rename {HFE => hubfrontend}/app/detectors/page.tsx (100%) rename {HFE => hubfrontend}/app/favicon.ico (100%) rename {HFE => hubfrontend}/app/globals.css (100%) rename {HFE => hubfrontend}/app/layout.tsx (100%) rename {HFE => hubfrontend}/app/page.tsx (100%) rename {HFE => hubfrontend}/app/settings/page.tsx (100%) rename {HFE => hubfrontend}/app/sources/page.tsx (100%) rename {components => hubfrontend/components}/Dropdown.tsx (100%) rename {components => hubfrontend/components}/EditDetectorOverlay.tsx (100%) rename {components => hubfrontend/components}/EditNotificationsOverlay.tsx (100%) rename {components => hubfrontend/components}/Nav.tsx (100%) rename {components => hubfrontend/components}/NewCameraOverlay.tsx (100%) rename {components => hubfrontend/components}/PushStacklightConfigButton.tsx (100%) rename {components => hubfrontend/components}/Spinner.tsx (100%) rename {images => hubfrontend/images}/Groundlight-Detector-Dashboard.png (100%) rename {images => hubfrontend/images}/Groundlight-Docker-Frontpage.png (100%) rename middleware.ts => hubfrontend/middleware.ts (100%) rename next.config.js => hubfrontend/next.config.js (100%) rename package-lock.json => hubfrontend/package-lock.json (100%) rename package.json => hubfrontend/package.json (100%) rename postcss.config.js => hubfrontend/postcss.config.js (100%) rename {public => hubfrontend/public}/favicon.ico (100%) rename tailwind.config.js => hubfrontend/tailwind.config.js (100%) rename tsconfig.json => hubfrontend/tsconfig.json (100%) rename {utils => hubfrontend/utils}/types.ts (100%) rename {utils => hubfrontend/utils}/useAvailableDetectors.ts (100%) rename {utils => hubfrontend/utils}/useDetectors.ts (100%) rename {utils => hubfrontend/utils}/useEscape.tsx (100%) rename {utils => hubfrontend/utils}/useImageSources.ts (100%) rename {utils => hubfrontend/utils}/useKeypress.tsx (100%) diff --git a/README.md b/README.md index f4e24fd..0ee97f6 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,6 @@ We welcome pull requests! ### Organization of source code -- `HFE` is the "hub frontend". This is a Typescript / React app that serves as the frontend for the system. -- `BECS` is the "backend config server". This is an HTTP server which serves the configuration for the detectors. +- `hubfrontend` is a Typescript / React app that serves as the frontend for the system. +- `backendconfigserver` is an HTTP server which serves the configuration for the detectors. - `deploy` has code for deploying the system in various environments diff --git a/backend.Dockerfile b/backendconfigserver/Dockerfile similarity index 100% rename from backend.Dockerfile rename to backendconfigserver/Dockerfile diff --git a/backend-armv7.Dockerfile b/backendconfigserver/Dockerfile-armv7 similarity index 100% rename from backend-armv7.Dockerfile rename to backendconfigserver/Dockerfile-armv7 diff --git a/BECS/api/gl_process.py b/backendconfigserver/api/gl_process.py similarity index 100% rename from BECS/api/gl_process.py rename to backendconfigserver/api/gl_process.py diff --git a/BECS/api/index.py b/backendconfigserver/api/index.py similarity index 100% rename from BECS/api/index.py rename to backendconfigserver/api/index.py diff --git a/BECS/api/logging_config.yaml b/backendconfigserver/api/logging_config.yaml similarity index 100% rename from BECS/api/logging_config.yaml rename to backendconfigserver/api/logging_config.yaml diff --git a/BECS/api/notifications.py b/backendconfigserver/api/notifications.py similarity index 100% rename from BECS/api/notifications.py rename to backendconfigserver/api/notifications.py diff --git a/BECS/api/rtsp_scan.sh b/backendconfigserver/api/rtsp_scan.sh similarity index 100% rename from BECS/api/rtsp_scan.sh rename to backendconfigserver/api/rtsp_scan.sh diff --git a/pi_requirements.txt b/backendconfigserver/pi_requirements.txt similarity index 100% rename from pi_requirements.txt rename to backendconfigserver/pi_requirements.txt diff --git a/requirements.txt b/backendconfigserver/requirements.txt similarity index 100% rename from requirements.txt rename to backendconfigserver/requirements.txt diff --git a/docker-compose.yml b/docker-compose.yml index 01ac54d..61c73b7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,13 +1,13 @@ version: "2" services: - HFE: - build: ./HFE + hubfrontend: + build: ./hubfrontend ports: - "80:3000" depends_on: - - BECS - BECS: - build: ./BECS + - backendconfigserver + backendconfigserver: + build: ./backendconfigserver ports: - "8000:8000" devices: diff --git a/frontend.Dockerfile b/hubfrontend/Dockerfile similarity index 100% rename from frontend.Dockerfile rename to hubfrontend/Dockerfile diff --git a/frontend-armv7.Dockerfile b/hubfrontend/Dockerfile-arm7 similarity index 100% rename from frontend-armv7.Dockerfile rename to hubfrontend/Dockerfile-arm7 diff --git a/HFE/app/detectors/page.tsx b/hubfrontend/app/detectors/page.tsx similarity index 100% rename from HFE/app/detectors/page.tsx rename to hubfrontend/app/detectors/page.tsx diff --git a/HFE/app/favicon.ico b/hubfrontend/app/favicon.ico similarity index 100% rename from HFE/app/favicon.ico rename to hubfrontend/app/favicon.ico diff --git a/HFE/app/globals.css b/hubfrontend/app/globals.css similarity index 100% rename from HFE/app/globals.css rename to hubfrontend/app/globals.css diff --git a/HFE/app/layout.tsx b/hubfrontend/app/layout.tsx similarity index 100% rename from HFE/app/layout.tsx rename to hubfrontend/app/layout.tsx diff --git a/HFE/app/page.tsx b/hubfrontend/app/page.tsx similarity index 100% rename from HFE/app/page.tsx rename to hubfrontend/app/page.tsx diff --git a/HFE/app/settings/page.tsx b/hubfrontend/app/settings/page.tsx similarity index 100% rename from HFE/app/settings/page.tsx rename to hubfrontend/app/settings/page.tsx diff --git a/HFE/app/sources/page.tsx b/hubfrontend/app/sources/page.tsx similarity index 100% rename from HFE/app/sources/page.tsx rename to hubfrontend/app/sources/page.tsx diff --git a/components/Dropdown.tsx b/hubfrontend/components/Dropdown.tsx similarity index 100% rename from components/Dropdown.tsx rename to hubfrontend/components/Dropdown.tsx diff --git a/components/EditDetectorOverlay.tsx b/hubfrontend/components/EditDetectorOverlay.tsx similarity index 100% rename from components/EditDetectorOverlay.tsx rename to hubfrontend/components/EditDetectorOverlay.tsx diff --git a/components/EditNotificationsOverlay.tsx b/hubfrontend/components/EditNotificationsOverlay.tsx similarity index 100% rename from components/EditNotificationsOverlay.tsx rename to hubfrontend/components/EditNotificationsOverlay.tsx diff --git a/components/Nav.tsx b/hubfrontend/components/Nav.tsx similarity index 100% rename from components/Nav.tsx rename to hubfrontend/components/Nav.tsx diff --git a/components/NewCameraOverlay.tsx b/hubfrontend/components/NewCameraOverlay.tsx similarity index 100% rename from components/NewCameraOverlay.tsx rename to hubfrontend/components/NewCameraOverlay.tsx diff --git a/components/PushStacklightConfigButton.tsx b/hubfrontend/components/PushStacklightConfigButton.tsx similarity index 100% rename from components/PushStacklightConfigButton.tsx rename to hubfrontend/components/PushStacklightConfigButton.tsx diff --git a/components/Spinner.tsx b/hubfrontend/components/Spinner.tsx similarity index 100% rename from components/Spinner.tsx rename to hubfrontend/components/Spinner.tsx diff --git a/images/Groundlight-Detector-Dashboard.png b/hubfrontend/images/Groundlight-Detector-Dashboard.png similarity index 100% rename from images/Groundlight-Detector-Dashboard.png rename to hubfrontend/images/Groundlight-Detector-Dashboard.png diff --git a/images/Groundlight-Docker-Frontpage.png b/hubfrontend/images/Groundlight-Docker-Frontpage.png similarity index 100% rename from images/Groundlight-Docker-Frontpage.png rename to hubfrontend/images/Groundlight-Docker-Frontpage.png diff --git a/middleware.ts b/hubfrontend/middleware.ts similarity index 100% rename from middleware.ts rename to hubfrontend/middleware.ts diff --git a/next.config.js b/hubfrontend/next.config.js similarity index 100% rename from next.config.js rename to hubfrontend/next.config.js diff --git a/package-lock.json b/hubfrontend/package-lock.json similarity index 100% rename from package-lock.json rename to hubfrontend/package-lock.json diff --git a/package.json b/hubfrontend/package.json similarity index 100% rename from package.json rename to hubfrontend/package.json diff --git a/postcss.config.js b/hubfrontend/postcss.config.js similarity index 100% rename from postcss.config.js rename to hubfrontend/postcss.config.js diff --git a/public/favicon.ico b/hubfrontend/public/favicon.ico similarity index 100% rename from public/favicon.ico rename to hubfrontend/public/favicon.ico diff --git a/tailwind.config.js b/hubfrontend/tailwind.config.js similarity index 100% rename from tailwind.config.js rename to hubfrontend/tailwind.config.js diff --git a/tsconfig.json b/hubfrontend/tsconfig.json similarity index 100% rename from tsconfig.json rename to hubfrontend/tsconfig.json diff --git a/utils/types.ts b/hubfrontend/utils/types.ts similarity index 100% rename from utils/types.ts rename to hubfrontend/utils/types.ts diff --git a/utils/useAvailableDetectors.ts b/hubfrontend/utils/useAvailableDetectors.ts similarity index 100% rename from utils/useAvailableDetectors.ts rename to hubfrontend/utils/useAvailableDetectors.ts diff --git a/utils/useDetectors.ts b/hubfrontend/utils/useDetectors.ts similarity index 100% rename from utils/useDetectors.ts rename to hubfrontend/utils/useDetectors.ts diff --git a/utils/useEscape.tsx b/hubfrontend/utils/useEscape.tsx similarity index 100% rename from utils/useEscape.tsx rename to hubfrontend/utils/useEscape.tsx diff --git a/utils/useImageSources.ts b/hubfrontend/utils/useImageSources.ts similarity index 100% rename from utils/useImageSources.ts rename to hubfrontend/utils/useImageSources.ts diff --git a/utils/useKeypress.tsx b/hubfrontend/utils/useKeypress.tsx similarity index 100% rename from utils/useKeypress.tsx rename to hubfrontend/utils/useKeypress.tsx From bfebe15e4fab22e7c8be8eb2a643f4735dbdbb72 Mon Sep 17 00:00:00 2001 From: Leo Dirac Date: Thu, 1 Feb 2024 19:44:52 +0000 Subject: [PATCH 11/14] Moving dockerignore. --- .dockerignore => backendconfigserver/.dockerignore | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .dockerignore => backendconfigserver/.dockerignore (100%) diff --git a/.dockerignore b/backendconfigserver/.dockerignore similarity index 100% rename from .dockerignore rename to backendconfigserver/.dockerignore From 60a893211a10f544de94b4d30b9934f5c38b3d81 Mon Sep 17 00:00:00 2001 From: Leo Dirac Date: Thu, 1 Feb 2024 19:50:21 +0000 Subject: [PATCH 12/14] Removing --link. --- .github/workflows/container_workflows.yaml | 1 + hubfrontend/Dockerfile | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/container_workflows.yaml b/.github/workflows/container_workflows.yaml index 142af70..13d7365 100644 --- a/.github/workflows/container_workflows.yaml +++ b/.github/workflows/container_workflows.yaml @@ -5,6 +5,7 @@ on: [push] jobs: build: + #TODO: this is all busted and out of date. name: Build Docker Image runs-on: ubuntu-latest strategy: diff --git a/hubfrontend/Dockerfile b/hubfrontend/Dockerfile index 31ed593..a735de2 100644 --- a/hubfrontend/Dockerfile +++ b/hubfrontend/Dockerfile @@ -8,7 +8,7 @@ FROM base AS deps WORKDIR /app # Install dependencies based on the preferred package manager -COPY --link package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./ +COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./ RUN \ if [ -f yarn.lock ]; then yarn --frozen-lockfile; \ elif [ -f package-lock.json ]; then npm ci; \ From 77f495a449a8b9f169ceabb535f3cb3f17073ed9 Mon Sep 17 00:00:00 2001 From: Leo Dirac Date: Thu, 1 Feb 2024 19:50:43 +0000 Subject: [PATCH 13/14] Removing --link everywhere. --- hubfrontend/Dockerfile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hubfrontend/Dockerfile b/hubfrontend/Dockerfile index a735de2..b9380cf 100644 --- a/hubfrontend/Dockerfile +++ b/hubfrontend/Dockerfile @@ -20,8 +20,8 @@ RUN \ # Rebuild the source code only when needed FROM base AS builder WORKDIR /app -COPY --from=deps --link /app/node_modules ./node_modules -COPY --link . . +COPY --from=deps /app/node_modules ./node_modules +COPY . . # Next.js collects completely anonymous telemetry data about general usage. # Learn more here: https://nextjs.org/telemetry @@ -45,12 +45,12 @@ RUN \ addgroup --system --gid 1001 nodejs; \ adduser --system --uid 1001 nextjs -COPY --from=builder --link /app/public ./public +COPY --from=builder /app/public ./public # Automatically leverage output traces to reduce image size # https://nextjs.org/docs/advanced-features/output-file-tracing -COPY --from=builder --link --chown=1001:1001 /app/.next/standalone ./ -COPY --from=builder --link --chown=1001:1001 /app/.next/static ./.next/static +COPY --from=builder --chown=1001:1001 /app/.next/standalone ./ +COPY --from=builder --chown=1001:1001 /app/.next/static ./.next/static USER nextjs From 842f72bbf30783fb171676284663ac40283b010d Mon Sep 17 00:00:00 2001 From: Leo Dirac Date: Fri, 2 Feb 2024 01:07:43 +0000 Subject: [PATCH 14/14] Cleaning up dockerfiles and temporarily disabling CICD. --- .github/workflows/container_workflows.yaml | 7 +++++-- backendconfigserver/Dockerfile | 9 +++++++-- backendconfigserver/Dockerfile-armv7 | 7 ++++++- backendconfigserver/api/rtsp_scan.sh | 8 ++++++-- backendconfigserver/requirements.txt | 2 +- 5 files changed, 25 insertions(+), 8 deletions(-) diff --git a/.github/workflows/container_workflows.yaml b/.github/workflows/container_workflows.yaml index 13d7365..25ec23b 100644 --- a/.github/workflows/container_workflows.yaml +++ b/.github/workflows/container_workflows.yaml @@ -1,11 +1,14 @@ # This is a workflow to build images name: Build Docker Images -on: [push] +on: + push: + branches: + - release jobs: + #TODO: redo the tests with the new arrangement build: - #TODO: this is all busted and out of date. name: Build Docker Image runs-on: ubuntu-latest strategy: diff --git a/backendconfigserver/Dockerfile b/backendconfigserver/Dockerfile index 54313e5..0200abe 100644 --- a/backendconfigserver/Dockerfile +++ b/backendconfigserver/Dockerfile @@ -1,11 +1,16 @@ -FROM python:3.9-slim-bookworm +FROM python:3.11-slim-bookworm + +RUN apt-get update && \ + apt-get install -y \ + sudo && \ + apt-get clean WORKDIR /app COPY ./requirements.txt /app/requirements.txt RUN pip3 install --no-cache-dir --upgrade -r /app/requirements.txt -RUN pip3 install opencv-python-headless==4.8.0.74 +RUN pip3 install opencv-python-headless>=4.8 RUN pip install --index-url=https://www.piwheels.org/simple --no-cache-dir -r /app/requirements.txt RUN pip install --no-deps groundlight diff --git a/backendconfigserver/Dockerfile-armv7 b/backendconfigserver/Dockerfile-armv7 index 9d57009..184aca2 100644 --- a/backendconfigserver/Dockerfile-armv7 +++ b/backendconfigserver/Dockerfile-armv7 @@ -1,4 +1,9 @@ -FROM python:3.9-slim-buster +FROM python:3.11-slim-buster + +RUN apt-get update && \ + apt-get install -y \ + sudo && \ + apt-get clean WORKDIR /app diff --git a/backendconfigserver/api/rtsp_scan.sh b/backendconfigserver/api/rtsp_scan.sh index aa78799..f1e085d 100755 --- a/backendconfigserver/api/rtsp_scan.sh +++ b/backendconfigserver/api/rtsp_scan.sh @@ -11,7 +11,7 @@ fi install_dependencies() { echo "Installing dependencies..." sudo apt update - sudo apt install -y nmap net-tools + sudo apt install -y nmap net-tools iproute2 } # Function to find subnets @@ -79,7 +79,11 @@ scan_subnet() { # Main execution main() { - #install_dependencies + # check if `ip` and `nmap` are available + if ! command -v ip &> /dev/null || ! command -v nmap &> /dev/null; then + echo "Missing dependencies. Attempting to install them" + install_dependencies + fi find_subnets | while read -r subnet; do scan_subnet "$subnet" done diff --git a/backendconfigserver/requirements.txt b/backendconfigserver/requirements.txt index f13411c..44eff91 100644 --- a/backendconfigserver/requirements.txt +++ b/backendconfigserver/requirements.txt @@ -1,7 +1,7 @@ fastapi==0.95.2 uvicorn[standard] groundlight -opencv-python==4.8.0.74 +opencv-python>=4.8 framegrab pypylon slack_sdk