initial commit

This commit is contained in:
jokob-sk
2025-01-05 13:04:36 +11:00
parent 8964123c75
commit c6247fb7fb
13 changed files with 423 additions and 0 deletions

3
netalertx/CHANGELOG.md Normal file
View File

@@ -0,0 +1,3 @@
## 0.0.1
- Initial commit

118
netalertx/Dockerfile Normal file
View File

@@ -0,0 +1,118 @@
#============================#
# ALEXBELGIUM'S DOCKERFILE #
#============================#
# _.------.
# _.-` ('>.-`"""-.
# '.--'` _'` _ .--.)
# -' '-.-';` `
# ' - _.' ``'--.
# '---` .-'""`
# /`
#=== Home Assistant Addon ===#
#################
# 1 Build Image #
#################
ARG BUILD_FROM
ARG BUILD_VERSION
FROM ${BUILD_FROM}
##################
# 2 Modify Image #
##################
# Set S6 wait time
ENV S6_CMD_WAIT_FOR_SERVICES=1 \
S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0 \
S6_SERVICES_GRACETIME=0
# Global LSIO modifications
ADD "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/ha_lsio.sh" "/ha_lsio.sh"
ARG CONFIGLOCATION="/config/addons_config/netalertx"
RUN chmod 744 /ha_lsio.sh && if grep -qr "lsio" /etc; then /ha_lsio.sh "$CONFIGLOCATION"; fi && rm /ha_lsio.sh
##################
# 3 Install apps #
##################
# Add rootfs
COPY rootfs/ /
# Uses /bin for compatibility purposes
# hadolint ignore=DL4005
RUN if [ ! -f /bin/sh ] && [ -f /usr/bin/sh ]; then ln -s /usr/bin/sh /bin/sh; fi && \
if [ ! -f /bin/bash ] && [ -f /usr/bin/bash ]; then ln -s /usr/bin/bash /bin/bash; fi
# Modules
ARG MODULES="00-banner.sh 01-custom_script.sh 00-local_mounts.sh 00-smb_mounts.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="jq \
curl \
cifs-utils"
# 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 #
################
# Add 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
# hadolint ignore=SC2013
RUN \
for file in $(grep -Esril "/local/config/addons_config/netalertx" /etc /defaults); do sed -i "s=/local/config/addons_config/netalertx=/local/config=g" "$file"; done
#
#WORKDIR /
#ENTRYPOINT [ "/usr/bin/env" ]
#CMD [ "/ha_entrypoint.sh" ]
#SHELL ["/bin/bash", "-o", "pipefail", "-c"]
############
# 5 Labels #
############
ARG BUILD_ARCH
ARG BUILD_DATE
ARG BUILD_DESCRIPTION
ARG BUILD_NAME
ARG BUILD_REF
ARG BUILD_REPOSITORY
ARG BUILD_VERSION
LABEL \
io.hass.name="${BUILD_NAME}" \
io.hass.description="${BUILD_DESCRIPTION}" \
io.hass.arch="${BUILD_ARCH}" \
io.hass.type="addon" \
io.hass.version=${BUILD_VERSION} \
maintainer="alexbelgium (https://github.com/alexbelgium)" \
org.opencontainers.image.title="${BUILD_NAME}" \
org.opencontainers.image.description="${BUILD_DESCRIPTION}" \
org.opencontainers.image.vendor="Home Assistant Add-ons" \
org.opencontainers.image.authors="alexbelgium (https://github.com/alexbelgium)" \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.url="https://github.com/alexbelgium" \
org.opencontainers.image.source="https://github.com/${BUILD_REPOSITORY}" \
org.opencontainers.image.documentation="https://github.com/${BUILD_REPOSITORY}/blob/main/README.md" \
org.opencontainers.image.created=${BUILD_DATE} \
org.opencontainers.image.revision=${BUILD_REF} \
org.opencontainers.image.version=${BUILD_VERSION}
####################
# 6 HealthcheckNOT #
####################

57
netalertx/README.md Normal file
View File

@@ -0,0 +1,57 @@
# Home assistant add-on: NetAlertX
[![Donate][donation-badge]](https://www.buymeacoffee.com/alexbelgium)
[![Donate][paypal-badge]](https://www.paypal.com/donate/?hosted_button_id=DZFULJZTP3UQA)
![Version](https://img.shields.io/badge/dynamic/json?label=Version&query=%24.version&url=https%3A%2F%2Fraw.githubusercontent.com%2Falexbelgium%2Fhassio-addons%2Fmaster%2Fnetalertx%2Fconfig.json)
![Ingress](https://img.shields.io/badge/dynamic/json?label=Ingress&query=%24.ingress&url=https%3A%2F%2Fraw.githubusercontent.com%2Falexbelgium%2Fhassio-addons%2Fmaster%2Fnetalertx%2Fconfig.json)
![Arch](https://img.shields.io/badge/dynamic/json?color=success&label=Arch&query=%24.arch&url=https%3A%2F%2Fraw.githubusercontent.com%2Falexbelgium%2Fhassio-addons%2Fmaster%2Fnetalertx%2Fconfig.json)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/9c6cf10bdbba45ecb202d7f579b5be0e)](https://www.codacy.com/gh/alexbelgium/hassio-addons/dashboard?utm_source=github.com&utm_medium=referral&utm_content=alexbelgium/hassio-addons&utm_campaign=Badge_Grade)
[![GitHub Super-Linter](https://img.shields.io/github/actions/workflow/status/alexbelgium/hassio-addons/weekly-supelinter.yaml?label=Lint%20code%20base)](https://github.com/alexbelgium/hassio-addons/actions/workflows/weekly-supelinter.yaml)
[![Builder](https://img.shields.io/github/actions/workflow/status/alexbelgium/hassio-addons/onpush_builder.yaml?label=Builder)](https://github.com/alexbelgium/hassio-addons/actions/workflows/onpush_builder.yaml)
[donation-badge]: https://img.shields.io/badge/Buy%20me%20a%20coffee%20(no%20paypal)-%23d32f2f?logo=buy-me-a-coffee&style=flat&logoColor=white
[paypal-badge]: https://img.shields.io/badge/Buy%20me%20a%20coffee%20with%20Paypal-0070BA?logo=paypal&style=flat&logoColor=white
_Thanks to everyone having starred my repo! To star it click on the image below, then it will be on top right. Thanks!_
[![Stargazers repo roster for @alexbelgium/hassio-addons](https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.github/stars2.svg)](https://github.com/alexbelgium/hassio-addons/stargazers)
![downloads evolution](https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/netalertx/stats.png)
## About
🖧🔍 WIFI / LAN intruder detector. Scans for devices connected to your network and alerts you if new and unknown devices are found.
This addon is based on the [docker image](https://github.com/jokob-sk/NetAlertX/tree/main/dockerfiles) from jokob-sk.
## Installation
The installation of this add-on is pretty straightforward and not different in
comparison to installing any other Hass.io add-on.
1. [Add my Hass.io add-ons repository][repository] to your Hass.io instance.
1. Install this add-on.
1. Click the `Save` button to store your configuration.
1. Start the add-on.
1. Check the logs of the add-on to see if everything went well.
1. Carefully configure the add-on to your preferences, see the official documentation for for that.
## Configuration
1. If unavailable, the app generates a default app.conf and app.db file on the first run.
1. The preferred way is to manage the configuration via the Settings section in the UI, if UI is inaccessible you can modify app.conf in the /app/config/ folder directly
1. You have to specify which network(s) should be scanned. This is done by entering subnets that are accessible from the host. If you use the default ARPSCAN plugin, you have to specify at least one valid subnet and interface in the SCAN_SUBNETS setting. See the [documentation on How to set up multiple SUBNETS, VLANs and what are limitations](https://github.com/jokob-sk/NetAlertX/blob/main/docs/SUBNETS.md) for troubleshooting and more advanced scenarios.
Webui can be found at <http://homeassistant:20211>.
```yaml
PGID: user
GPID: user
localdisks: sda1 #put the hardware name of your drive to mount separated by commas, or its label. ex. sda1, sdb1, MYNAS...
networkdisks: "<//SERVER/SHARE>" # list of smbv2/3 servers to mount (optional)
cifsusername: "username" # smb username (optional)
cifspassword: "password" # smb password (optional)
```
[repository]: https://github.com/alexbelgium/hassio-addons

66
netalertx/apparmor.txt Normal file
View File

@@ -0,0 +1,66 @@
#include <tunables/global>
profile netalertx_addon flags=(attach_disconnected,mediate_deleted) {
#include <abstractions/base>
capability,
file,
signal,
mount,
umount,
remount,
network udp,
network tcp,
network dgram,
network stream,
network inet,
network inet6,
network netlink raw,
network unix dgram,
capability setgid,
capability setuid,
capability sys_admin,
capability dac_read_search,
# capability dac_override,
# capability sys_rawio,
# S6-Overlay
/init ix,
/run/{s6,s6-rc*,service}/** ix,
/package/** ix,
/command/** ix,
/run/{,**} rwk,
/dev/tty rw,
/bin/** ix,
/usr/bin/** ix,
/usr/lib/bashio/** ix,
/etc/s6/** rix,
/run/s6/** rix,
/etc/services.d/** rwix,
/etc/cont-init.d/** rwix,
/etc/cont-finish.d/** rwix,
/init rix,
/var/run/** mrwkl,
/var/run/ mrwkl,
/dev/i2c-1 mrwkl,
# Files required
/dev/fuse mrwkl,
/dev/sda1 mrwkl,
/dev/sdb1 mrwkl,
/dev/nvme0 mrwkl,
/dev/nvme1 mrwkl,
/dev/mmcblk0p1 mrwkl,
/dev/* mrwkl,
/tmp/** mrkwl,
# Data access
/data/** rw,
# suppress ptrace denials when using 'docker ps' or using 'ps' inside a container
ptrace (trace,read) peer=docker-default,
# docker daemon confinement requires explict allow rule for signal
signal (receive) set=(kill,term) peer=/usr/bin/docker,
}

11
netalertx/build.json Normal file
View File

@@ -0,0 +1,11 @@
{
"build_from": {
"aarch64": "netalertx:latest",
"amd64": "netalertx:latest",
"armv7": "netalertx:latest",
"armv6": "netalertx:latest"
},
"codenotary": {
"signer": "alexandrep.github@gmail.com"
}
}

114
netalertx/config.json Normal file
View File

@@ -0,0 +1,114 @@
{
"arch": [
"aarch64",
"amd64",
"armv7",
"armv6"
],
"codenotary": "alexandrep.github@gmail.com",
"description": "🖧🔍 WIFI / LAN scanner, intruder, and presence detector",
"devices": [
"/dev/dri",
"/dev/dri/card0",
"/dev/dri/card1",
"/dev/dri/renderD128",
"/dev/vchiq",
"/dev/video10",
"/dev/video11",
"/dev/video12",
"/dev/video13",
"/dev/video14",
"/dev/video15",
"/dev/video16",
"/dev/ttyUSB0",
"/dev/sda",
"/dev/sdb",
"/dev/sdc",
"/dev/sdd",
"/dev/sde",
"/dev/sdf",
"/dev/sdg",
"/dev/nvme",
"/dev/nvme0n1p1",
"/dev/nvme0n1p2",
"/dev/nvme0n1p3",
"/dev/nvme1n1p1",
"/dev/nvme1n1p2",
"/dev/nvme1n1p3",
"/dev/nvme2n1p1",
"/dev/nvme2n1p2",
"/dev/nvme3n1p3",
"/dev/mmcblk",
"/dev/fuse",
"/dev/sda1",
"/dev/sdb1",
"/dev/sdc1",
"/dev/sdd1",
"/dev/sde1",
"/dev/sdf1",
"/dev/sdg1",
"/dev/sda2",
"/dev/sdb2",
"/dev/sdc2",
"/dev/sdd2",
"/dev/sde2",
"/dev/sdf2",
"/dev/sdg2",
"/dev/sda3",
"/dev/sdb3",
"/dev/sda4",
"/dev/sdb4",
"/dev/sda5",
"/dev/sda6",
"/dev/sda7",
"/dev/sda8",
"/dev/nvme0",
"/dev/nvme1",
"/dev/nvme2"
],
"environment": {
"PORT": "20211",
"TZ": "Europe/Berlin",
"APP_CONF_OVERRIDE":{"GRAPHQL_PORT":"20212"}
},
"image": "ghcr.io/alexbelgium/netalertx-{arch}",
"init": false,
"map": [
"config:rw",
"media:rw",
"share:rw",
"ssl"
],
"name": "NetAlertX",
"options": {
"PGID": 0,
"PUID": 0
},
"ports": {
"20211/tcp": 20211,
"20212/tcp": 20212
},
"ports_description": {
"20211/tcp": "WebUI port",
"20212/tcp": "GraphQL port"
},
"privileged": [
"SYS_ADMIN",
"DAC_READ_SEARCH"
],
"schema": {
"PGID": "int",
"PUID": "int",
"TZ": "str?",
"cifsdomain": "str?",
"cifspassword": "str?",
"cifsusername": "str?",
"localdisks": "str?",
"networkdisks": "str?"
},
"slug": "netalertx",
"udev": true,
"url": "https://github.com/alexbelgium/hassio-addons",
"version": "0.0.1",
"webui": "[PROTO:ssl]://[HOST]:[PORT:20211]"
}

BIN
netalertx/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

BIN
netalertx/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

View File

@@ -0,0 +1,43 @@
#!/usr/bin/with-contenv bashio
# shellcheck shell=bash
set -e
##################
# SYMLINK CONFIG #
##################
#Create folders
if [ ! -d /share/netalertx ]; then
echo "Creating /share/netalertx"
mkdir -p /share/netalertx
chown -R "$PUID:$PGID" /share/netalertx
else
chown -R "$PUID:$PGID" /share/netalertx
fi
mkdir -p /config/www/local
if [ ! -d /share/netalertx/config ] && [ -d /config/www/local/config ]; then
echo "moving config folder"
mv /config/www/local/config /share/netalertx
ln -s /share/netalertx/config /config/www/local
echo "links done"
else
if [ -d /config/www/local/config ]; then rm -r /config/www/local/config; fi
ln -s /share/netalertx/config /config/www/local
echo "Using existing config"
fi
mkdir -p /config/keys
if [ ! -d /share/netalertx/keys ]; then
echo "moving keys folder"
mv /config/keys /share/netalertx
ln -s /share/netalertx/keys /config
echo "links done"
else
rm -r /config/keys
ln -s /share/netalertx/keys /config
echo "Using existing keys folder"
fi

View File

@@ -0,0 +1 @@
oneshot

View File

@@ -0,0 +1 @@
/etc/s6-overlay/s6-rc.d/init-alexbelgium/run

8
netalertx/updater.json Normal file
View File

@@ -0,0 +1,8 @@
{
"last_update": "23-12-2024",
"repository": "alexbelgium/hassio-addons",
"slug": "netalertx",
"source": "github",
"upstream_repo": "jokob-sk/netalertx",
"upstream_version": "24.12.23"
}