mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-06-01 05:14:04 +02:00
Align netalertx addon with test repository
This commit is contained in:
@@ -1,5 +1,3 @@
|
|||||||
## 25.10.1-2 (18-12-2025)
|
|
||||||
- Minor bugs fixed
|
|
||||||
## 25.10.1-4 (01-12-2025)
|
## 25.10.1-4 (01-12-2025)
|
||||||
- Minor bugs fixed
|
- Minor bugs fixed
|
||||||
## 25.10.1-3 (29-11-2025)
|
## 25.10.1-3 (29-11-2025)
|
||||||
|
|||||||
@@ -10,38 +10,111 @@
|
|||||||
# /`
|
# /`
|
||||||
#=== Home Assistant Addon ===#
|
#=== Home Assistant Addon ===#
|
||||||
|
|
||||||
#################
|
############################
|
||||||
# 1 Build Image #
|
# 0) Tools stage (apk OK) #
|
||||||
#################
|
############################
|
||||||
|
# We build a tiny payload in /out containing:
|
||||||
|
# - jq + its shared libs (libjq, libonig, etc.)
|
||||||
|
# - gosu + its shared libs
|
||||||
|
# IMPORTANT: we do NOT bring sudo to avoid breaking NetAlertX hardened behavior.
|
||||||
|
FROM alpine:3.22 AS ha_tools
|
||||||
|
|
||||||
|
RUN apk add --no-cache \
|
||||||
|
gosu \
|
||||||
|
pax-utils
|
||||||
|
|
||||||
|
RUN set -eux; \
|
||||||
|
mkdir -p /out; \
|
||||||
|
for bin in /usr/bin/gosu; do \
|
||||||
|
mkdir -p "/out$(dirname "$bin")"; \
|
||||||
|
cp -a "$bin" "/out$bin"; \
|
||||||
|
# Copy runtime deps. Skip musl loader to avoid clobbering base image libc/loader.
|
||||||
|
lddtree -l "$bin" | while read -r dep; do \
|
||||||
|
case "$dep" in \
|
||||||
|
/lib/ld-musl-*.so.1) \
|
||||||
|
continue ;; \
|
||||||
|
/*) \
|
||||||
|
mkdir -p "/out$(dirname "$dep")"; \
|
||||||
|
cp -a "$dep" "/out$(dirname "$dep")/"; \
|
||||||
|
;; \
|
||||||
|
esac; \
|
||||||
|
done; \
|
||||||
|
done
|
||||||
|
|
||||||
|
##################
|
||||||
|
# 1) Final image #
|
||||||
|
##################
|
||||||
ARG BUILD_FROM
|
ARG BUILD_FROM
|
||||||
ARG BUILD_VERSION
|
FROM ghcr.io/jokob-sk/netalertx:latest
|
||||||
FROM ${BUILD_FROM}
|
|
||||||
|
|
||||||
##################
|
# S6 settings (keep yours)
|
||||||
# 2 Modify Image #
|
ENV S6_CMD_WAIT_FOR_SERVICES=1 \
|
||||||
##################
|
S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0 \
|
||||||
|
S6_SERVICES_GRACETIME=0
|
||||||
|
|
||||||
ENV NETALERTX_DATA=/config
|
USER 0
|
||||||
ENV READ_WRITE_FOLDERS="$READ_WRITE_FOLDERS $NETALERTX_DATA"
|
|
||||||
|
|
||||||
##################
|
|
||||||
# 3 Install apps #
|
|
||||||
##################
|
|
||||||
|
|
||||||
# Add rootfs
|
# Add rootfs
|
||||||
COPY --chown=102:102 rootfs/ /
|
COPY rootfs/ /
|
||||||
|
|
||||||
|
# Bring in jq + gosu (and their libs). NO apk in final stage.
|
||||||
|
COPY --from=ha_tools /out/ /
|
||||||
|
|
||||||
RUN BASHIO_VERSION="0.14.3" && \
|
RUN BASHIO_VERSION="0.14.3" && \
|
||||||
mkdir -p /tmp/bashio && \
|
mkdir -p /tmp/bashio && \
|
||||||
curl -f -L -s -S "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" | tar -xzf - --strip 1 -C /tmp/bashio
|
curl -f -L -s -S "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" | tar -xzf - --strip 1 -C /tmp/bashio && \
|
||||||
#mv /tmp/bashio/lib /usr/lib/bashio && \
|
mv /tmp/bashio/lib /usr/lib/bashio && \
|
||||||
#ln -s /usr/lib/bashio/bashio /usr/bin/bashio && \
|
ln -s /usr/lib/bashio/bashio /usr/bin/bashio && \
|
||||||
#rm -rf /tmp/
|
rm -rf /tmp/bashio
|
||||||
|
|
||||||
|
ARG TARGETARCH
|
||||||
|
RUN curl -L -o /usr/local/bin/jq "https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-linux-$TARGETARCH" && \
|
||||||
|
chmod +x /usr/local/bin/jq
|
||||||
|
|
||||||
|
###########
|
||||||
|
# Modules #
|
||||||
|
###########
|
||||||
|
ARG MODULES="00-banner.sh"
|
||||||
|
|
||||||
|
# Automatic modules download
|
||||||
|
ADD "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/ha_automodules.sh" "/ha_automodules.sh"
|
||||||
|
RUN chmod 744 /ha_automodules.sh \
|
||||||
|
&& /ha_automodules.sh "$MODULES" \
|
||||||
|
&& rm /ha_automodules.sh
|
||||||
|
|
||||||
|
#################
|
||||||
|
# Manual apps #
|
||||||
|
#################
|
||||||
|
ENV PACKAGES=""
|
||||||
|
|
||||||
|
# Automatic apps & bashio
|
||||||
|
ADD "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/ha_autoapps.sh" "/ha_autoapps.sh"
|
||||||
|
RUN chmod 744 /ha_autoapps.sh \
|
||||||
|
&& /ha_autoapps.sh "$PACKAGES" \
|
||||||
|
&& rm /ha_autoapps.sh
|
||||||
|
|
||||||
|
################
|
||||||
|
# 4 Entrypoint #
|
||||||
|
################
|
||||||
|
ENV S6_STAGE2_HOOK=/ha_entrypoint.sh
|
||||||
|
ADD "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/ha_entrypoint.sh" "/ha_entrypoint.sh"
|
||||||
|
|
||||||
|
# Entrypoint modifications
|
||||||
|
ADD "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/ha_entrypoint_modif.sh" "/ha_entrypoint_modif.sh"
|
||||||
|
RUN chmod 777 /ha_entrypoint.sh /ha_entrypoint_modif.sh \
|
||||||
|
&& /ha_entrypoint_modif.sh \
|
||||||
|
&& rm /ha_entrypoint_modif.sh
|
||||||
|
|
||||||
|
#WORKDIR /
|
||||||
|
ENTRYPOINT [ "/usr/bin/env" ]
|
||||||
|
CMD [ "/ha_entrypoint.sh" ]
|
||||||
|
|
||||||
|
# Your preferred shell
|
||||||
|
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
||||||
|
|
||||||
############
|
############
|
||||||
# 5 Labels #
|
# 5 Labels #
|
||||||
############
|
############
|
||||||
|
|
||||||
ARG BUILD_ARCH
|
ARG BUILD_ARCH
|
||||||
ARG BUILD_DATE
|
ARG BUILD_DATE
|
||||||
ARG BUILD_DESCRIPTION
|
ARG BUILD_DESCRIPTION
|
||||||
@@ -68,12 +141,3 @@ LABEL \
|
|||||||
org.opencontainers.image.created=${BUILD_DATE} \
|
org.opencontainers.image.created=${BUILD_DATE} \
|
||||||
org.opencontainers.image.revision=${BUILD_REF} \
|
org.opencontainers.image.revision=${BUILD_REF} \
|
||||||
org.opencontainers.image.version=${BUILD_VERSION}
|
org.opencontainers.image.version=${BUILD_VERSION}
|
||||||
|
|
||||||
####################
|
|
||||||
# 6 HealthcheckNOT #
|
|
||||||
####################
|
|
||||||
# # In the dockerfile Changing hard links if possible
|
|
||||||
# RUN for folder in config db; do \
|
|
||||||
# echo "Adapting hard links" && \
|
|
||||||
# grep -rl "/app/$folder" / 2>/dev/null | xargs sed -i "s|/app/$folder|/config/$folder|g"; \
|
|
||||||
# done
|
|
||||||
|
|||||||
@@ -3,14 +3,16 @@ arch:
|
|||||||
- amd64
|
- amd64
|
||||||
description: "\U0001F5A7\U0001F50D WIFI / LAN scanner, intruder, and presence detector"
|
description: "\U0001F5A7\U0001F50D WIFI / LAN scanner, intruder, and presence detector"
|
||||||
environment:
|
environment:
|
||||||
PGID: "102"
|
PGID: "20211"
|
||||||
PORT: "20211"
|
PORT: "20211"
|
||||||
PUID: "102"
|
PUID: "20211"
|
||||||
TZ: Europe/Berlin
|
TZ: Europe/Berlin
|
||||||
SKIP_STARTUP_CHECKS: "true"
|
NETALERTX_DATA: /config
|
||||||
|
NETALERTX_CONFIG: /config/config
|
||||||
|
NETALERTX_DB: /config/db
|
||||||
|
TMP_DIR: /tmp/tmp
|
||||||
hassio_api: true
|
hassio_api: true
|
||||||
host_network: true
|
host_network: true
|
||||||
image: ghcr.io/alexbelgium/netalertx-{arch}
|
|
||||||
ingress: true
|
ingress: true
|
||||||
ingress_port: 0
|
ingress_port: 0
|
||||||
ingress_stream: true
|
ingress_stream: true
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/with-contenv /tmp/bashio/lib/bashio
|
#!/usr/bin/with-contenv bashio
|
||||||
# shellcheck shell=bash
|
# shellcheck shell=bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
|||||||
118
netalertx/rootfs/etc/cont-init.d/91-configure.sh
Executable file
118
netalertx/rootfs/etc/cont-init.d/91-configure.sh
Executable file
@@ -0,0 +1,118 @@
|
|||||||
|
#!/usr/bin/with-contenv bashio
|
||||||
|
# shellcheck shell=bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
####################
|
||||||
|
# Update structure #
|
||||||
|
####################
|
||||||
|
|
||||||
|
APP_UID=20211
|
||||||
|
|
||||||
|
# 1. Fix the directories
|
||||||
|
for folder in /tmp/run/tmp /tmp/api /tmp/log /tmp/run /tmp/nginx/active-config "$TMP_DIR" "$NETALERTX_DATA" "$NETALERTX_DB" "$NETALERTX_CONFIG"; do
|
||||||
|
if [ -n "$folder" ]; then
|
||||||
|
mkdir -p "$folder"
|
||||||
|
chown -R $APP_UID:$APP_UID "$folder"
|
||||||
|
chmod 755 "$folder"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# 2. Fix /tmp and Standard Streams (CRITICAL)
|
||||||
|
chmod -R 1777 /tmp
|
||||||
|
# This allows the non-root user to write to the container logs
|
||||||
|
chmod 666 /dev/stdout /dev/stderr
|
||||||
|
|
||||||
|
# 3. Pre-create and chown log files
|
||||||
|
touch /tmp/log/app.php_errors.log /tmp/log/cron.log /tmp/log/stdout.log /tmp/log/stderr.log
|
||||||
|
chown $APP_UID:$APP_UID /tmp/log/*.log
|
||||||
|
|
||||||
|
# 4. Create Symlinks
|
||||||
|
for item in db config; do
|
||||||
|
rm -rf "/data/$item"
|
||||||
|
ln -sf "/config/$item" "/data/$item"
|
||||||
|
chown -R $APP_UID:$APP_UID "/data/$item"
|
||||||
|
chmod -R 755 "/data/$item"
|
||||||
|
done
|
||||||
|
|
||||||
|
# Fix php
|
||||||
|
sed -i 's|>>"\?/tmp/log/app\.php_errors\.log"\? 2>/dev/stderr|>>"/tmp/log/app.php_errors.log"|g' /services/start-php-fpm.sh
|
||||||
|
sed -i 's|TEMP_CONFIG_FILE=$(mktemp "${TMP_DIR}/netalertx\.conf\.XXXXXX")|TEMP_CONFIG_FILE=$(mktemp -p "${TMP_DIR:-/tmp}" netalertx.conf.XXXXXX)|' /services/start-php-fpm.sh
|
||||||
|
sed -i "/default_type/a include /etc/nginx/http.d/ingress.conf;" "${SYSTEM_NGINX_CONFIG_TEMPLATE}"
|
||||||
|
|
||||||
|
#####################
|
||||||
|
# Configure network #
|
||||||
|
#####################
|
||||||
|
|
||||||
|
# Configuration file path
|
||||||
|
config_file="/config/config/app.conf"
|
||||||
|
|
||||||
|
if [ -f /config/db/app.db ]; then
|
||||||
|
chmod a+rwx /config/db/app.db
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Function to execute the main logic
|
||||||
|
execute_main_logic() {
|
||||||
|
bashio::log.info "Initiating scan of Home Assistant network configuration..."
|
||||||
|
|
||||||
|
# Get the local IPv4 address
|
||||||
|
local_ip="$(bashio::network.ipv4_address)"
|
||||||
|
local_ip="${local_ip%/*}" # Remove CIDR notation
|
||||||
|
echo "... Detected local IP: $local_ip"
|
||||||
|
echo "... Scanning network for changes"
|
||||||
|
|
||||||
|
# Ensure arp-scan is installed
|
||||||
|
if ! command -v arp-scan &> /dev/null; then
|
||||||
|
bashio::log.error "arp-scan command not found. Please install arp-scan to proceed."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Get current settings
|
||||||
|
if ! grep -q "^SCAN_SUBNETS" "$config_file"; then
|
||||||
|
bashio::log.fatal "SCAN_SUBNETS is not found in your $config_file, please correct your file first"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Iterate over network interfaces
|
||||||
|
for interface in $(bashio::network.interfaces); do
|
||||||
|
echo "Scanning interface: $interface"
|
||||||
|
|
||||||
|
# Check if the interface is already configured
|
||||||
|
if grep -q "$interface" "$config_file"; then
|
||||||
|
echo "... $interface is already configured in app.conf"
|
||||||
|
else
|
||||||
|
# Update SCAN_SUBNETS in app.conf
|
||||||
|
SCAN_SUBNETS="$(grep "^SCAN_SUBNETS" "$config_file" | head -1)"
|
||||||
|
if [[ "$SCAN_SUBNETS" != *"$local_ip"*"$interface"* ]]; then
|
||||||
|
# Add to the app.conf
|
||||||
|
NEW_SCAN_SUBNETS="${SCAN_SUBNETS%]}, '${local_ip}/24 --interface=${interface}']"
|
||||||
|
sed -i "/^SCAN_SUBNETS/c\\$NEW_SCAN_SUBNETS" "$config_file"
|
||||||
|
# Check availability of hosts
|
||||||
|
VALUE="$(arp-scan --interface="$interface" "${local_ip}/24" 2> /dev/null \
|
||||||
|
| grep "responded" \
|
||||||
|
| awk -F'.' '{print $NF}' \
|
||||||
|
| awk '{print $1}' || true)"
|
||||||
|
echo "... $interface is available in Home Assistant (with $VALUE devices), added to app.conf"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
bashio::log.info "Network scan completed."
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to wait for the config file
|
||||||
|
wait_for_config_file() {
|
||||||
|
echo "Waiting for $config_file to become available..."
|
||||||
|
while [ ! -f "$config_file" ]; do
|
||||||
|
sleep 5 # Wait for 5 seconds before checking again
|
||||||
|
done
|
||||||
|
echo "$config_file is now available. Starting the script."
|
||||||
|
execute_main_logic
|
||||||
|
}
|
||||||
|
|
||||||
|
# Main script logic
|
||||||
|
if [ -f "$config_file" ]; then
|
||||||
|
execute_main_logic
|
||||||
|
else
|
||||||
|
wait_for_config_file &
|
||||||
|
true
|
||||||
|
fi
|
||||||
@@ -2,102 +2,5 @@
|
|||||||
# shellcheck shell=bash
|
# shellcheck shell=bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
####################
|
bashio::log.info "Starting upstream app"
|
||||||
# Update structure #
|
gosu netalertx /entrypoint.sh
|
||||||
####################
|
|
||||||
|
|
||||||
bashio::log.info "Update structure"
|
|
||||||
|
|
||||||
# In the addon script, make symlinks on the fly
|
|
||||||
echo "Creating symlinks"
|
|
||||||
for folder in config db; do
|
|
||||||
echo "Creating for $folder"
|
|
||||||
# Create symlinks
|
|
||||||
mkdir -p /config/"$folder"
|
|
||||||
if [ -d /app/"$folder" ] && [ "$(ls -A /app/"$folder")" ]; then
|
|
||||||
cp -rn /app/"$folder"/* /config/"$folder"/
|
|
||||||
fi
|
|
||||||
rm -r /app/"$folder"
|
|
||||||
ln -sf /config/"$folder" /app/"$folder"
|
|
||||||
done
|
|
||||||
|
|
||||||
sudo chown -R nginx:www-data /config/db/
|
|
||||||
sudo chown -R nginx:www-data /config/config/
|
|
||||||
if [ -f /config/db/app.db ]; then
|
|
||||||
chmod a+rwx /config/db/app.db
|
|
||||||
fi
|
|
||||||
|
|
||||||
#####################
|
|
||||||
# Configure network #
|
|
||||||
#####################
|
|
||||||
|
|
||||||
# Configuration file path
|
|
||||||
config_file="/config/config/app.conf"
|
|
||||||
|
|
||||||
# Function to execute the main logic
|
|
||||||
execute_main_logic() {
|
|
||||||
bashio::log.info "Initiating scan of Home Assistant network configuration..."
|
|
||||||
|
|
||||||
# Get the local IPv4 address
|
|
||||||
local_ip="$(bashio::network.ipv4_address)"
|
|
||||||
local_ip="${local_ip%/*}" # Remove CIDR notation
|
|
||||||
echo "... Detected local IP: $local_ip"
|
|
||||||
echo "... Scanning network for changes"
|
|
||||||
|
|
||||||
# Ensure arp-scan is installed
|
|
||||||
if ! command -v arp-scan &> /dev/null; then
|
|
||||||
bashio::log.error "arp-scan command not found. Please install arp-scan to proceed."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Get current settings
|
|
||||||
if ! grep -q "^SCAN_SUBNETS" "$config_file"; then
|
|
||||||
bashio::log.fatal "SCAN_SUBNETS is not found in your $config_file, please correct your file first"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Iterate over network interfaces
|
|
||||||
for interface in $(bashio::network.interfaces); do
|
|
||||||
echo "Scanning interface: $interface"
|
|
||||||
|
|
||||||
# Check if the interface is already configured
|
|
||||||
if grep -q "$interface" "$config_file"; then
|
|
||||||
echo "... $interface is already configured in app.conf"
|
|
||||||
else
|
|
||||||
# Update SCAN_SUBNETS in app.conf
|
|
||||||
SCAN_SUBNETS="$(grep "^SCAN_SUBNETS" "$config_file" | head -1)"
|
|
||||||
if [[ "$SCAN_SUBNETS" != *"$local_ip"*"$interface"* ]]; then
|
|
||||||
# Add to the app.conf
|
|
||||||
NEW_SCAN_SUBNETS="${SCAN_SUBNETS%]}, '${local_ip}/24 --interface=${interface}']"
|
|
||||||
sed -i "/^SCAN_SUBNETS/c\\$NEW_SCAN_SUBNETS" "$config_file"
|
|
||||||
# Check availability of hosts
|
|
||||||
VALUE="$(arp-scan --interface="$interface" "${local_ip}/24" 2> /dev/null \
|
|
||||||
| grep "responded" \
|
|
||||||
| awk -F'.' '{print $NF}' \
|
|
||||||
| awk '{print $1}' || true)"
|
|
||||||
echo "... $interface is available in Home Assistant (with $VALUE devices), added to app.conf"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
bashio::log.info "Network scan completed."
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to wait for the config file
|
|
||||||
wait_for_config_file() {
|
|
||||||
echo "Waiting for $config_file to become available..."
|
|
||||||
while [ ! -f "$config_file" ]; do
|
|
||||||
sleep 5 # Wait for 5 seconds before checking again
|
|
||||||
done
|
|
||||||
echo "$config_file is now available. Starting the script."
|
|
||||||
execute_main_logic
|
|
||||||
}
|
|
||||||
|
|
||||||
# Main script logic
|
|
||||||
if [ -f "$config_file" ]; then
|
|
||||||
execute_main_logic
|
|
||||||
else
|
|
||||||
wait_for_config_file &
|
|
||||||
true
|
|
||||||
fi
|
|
||||||
|
|
||||||
sudo -u "#${PUID}" -g "#${PGID}" /bin/sh /entrypoint.sh
|
|
||||||
|
|||||||
@@ -1,3 +1,8 @@
|
|||||||
|
map $http_upgrade $connection_upgrade {
|
||||||
|
default upgrade;
|
||||||
|
'' close;
|
||||||
|
}
|
||||||
|
|
||||||
server {
|
server {
|
||||||
listen %%interface%%:%%port%% default_server;
|
listen %%interface%%:%%port%% default_server;
|
||||||
server_name netalertx;
|
server_name netalertx;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
"repository": "alexbelgium/hassio-addons",
|
"repository": "alexbelgium/hassio-addons",
|
||||||
"slug": "netalertx",
|
"slug": "netalertx",
|
||||||
"source": "github",
|
"source": "github",
|
||||||
|
"paused": true,
|
||||||
"upstream_repo": "jokob-sk/NetAlertX",
|
"upstream_repo": "jokob-sk/NetAlertX",
|
||||||
"upstream_version": "25.11.29"
|
"upstream_version": "25.5.24"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user