diff --git a/.github/workflows/docker_dev.yml b/.github/workflows/docker_dev.yml index d5d19223..40e74449 100755 --- a/.github/workflows/docker_dev.yml +++ b/.github/workflows/docker_dev.yml @@ -48,7 +48,6 @@ jobs: with: # list of Docker images to use as base name for tags images: | - jokobsk/pi.alert_dev jokobsk/netalertx-dev # generate Docker tags based on the following events/attributes tags: | diff --git a/dockerfiles/README.md b/dockerfiles/README.md index 64e07c4c..3b6d639e 100755 --- a/dockerfiles/README.md +++ b/dockerfiles/README.md @@ -38,7 +38,7 @@ docker run -d --rm --network=host \ | `PORT` |Port of the web interface | `20211` | | `LISTEN_ADDR` |Set the specific IP Address for the listener address for the nginx webserver (web interface). This could be useful when using multiple subnets to hide the web interface from all untrusted networks. | `0.0.0.0` | |`TZ` |Time zone to display stats correctly. Find your time zone [here](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) | `Europe/Berlin` | -|`ALWAYS_FRESH_INSTALL` | Setting `ALWAYS_FRESH_INSTALL=true` will delete the content of the `/db` & `/config` folders. For testing purposes. Can be coupled with [watchtower](https://github.com/containrrr/watchtower) to have an always freshly installed `netalertx`/`-dev` image. | `N/A` | +|`ALWAYS_FRESH_INSTALL` | Setting to `true` will delete the content of the `/db` & `/config` folders. For testing purposes. Can be coupled with [watchtower](https://github.com/containrrr/watchtower) to have an always freshly installed `netalertx`/`-dev` image. | `N/A` | ### Docker paths diff --git a/docs/DEV_ENV_SETUP.md b/docs/DEV_ENV_SETUP.md new file mode 100755 index 00000000..ec15a037 --- /dev/null +++ b/docs/DEV_ENV_SETUP.md @@ -0,0 +1,64 @@ +## Development environemnt set up + +>[!NOTE] +> Replace `/development` with the path where your code files will be stored. The default container name is `netalertx` so there might be a conflict with your running containers. + +## 1. Download the code: + +- `mkdir /development` +- `cd /development && git clone https://github.com/jokob-sk/NetAlertX.git` + +## 2. Create a DEV .env_dev file + +`touch /development/.env_dev && sudo nano /development/.env_dev` + +The file content should be following, with your custom values. + +```yaml +#-------------------------------- +#NETALERTX +#-------------------------------- +TZ=Europe/Berlin +PORT=22222 # make sure this port is unique on your whole network +DEV_LOCATION=/development/NetAlertX +APP_DATA_LOCATION=/volume/docker_appdata +# ALWAYS_FRESH_INSTALL=true # uncommenting this will always delete the content of /config and /db dirs on boot to simulate a fresh install +``` + +## 3. Create /db and /config dirs + +Create a folder `netalertx` in the `APP_DATA_LOCATION` (in this example in `/volume/docker_appdata`) with 2 subfolders `db` and `config`. + +- `mkdir /volume/docker_appdata/netalertx` +- `mkdir /volume/docker_appdata/netalertx/db` +- `mkdir /volume/docker_appdata/netalertx/config` + +## 4. Run the container + +- `cd /development/NetAlertX && sudo docker-compose --env-file ../.env_dev ` + +You can then modify the python script without restarting/rebuilding the container every time. Additionally, you can trigger a plugin run via the UI: + + + + +## 💡 Tips + +A quick cheat sheet of useful commands. + +### Removing the container and image + +A command to stop, remove the container and the image (replace `netalertx` and `netalertx-netalertx` with the appropriate values) + +- `sudo docker container stop netalertx ; sudo docker container rm netalertx ; sudo docker image rm netalertx-netalertx` + +### Restart hanging python script + +SSH into the container and kill & restart the main script loop + +- `sudo docker exec -it netalertx /bin/bash` +- `pkill -f "python /app/server" && python /app/server & ` + + + + diff --git a/docs/NOTIFICATIONS.md b/docs/NOTIFICATIONS.md index 3c7efa17..c3bdc68a 100755 --- a/docs/NOTIFICATIONS.md +++ b/docs/NOTIFICATIONS.md @@ -52,4 +52,4 @@ In Notification Processing settings, you can specify blanket rules. These allow You can completely ignore detected devices globally. This could be because your instance detects docker containers, you want to ignore devices from a specific manufacturer via MAC rules or you want to ignore devices on a specific IP range. 1. Ignored MACs (`NEWDEV_ignored_MACs`) - List of MACs to ignore. -2. Ignored IPs (`NEWDEV_ignored_MACs`) - List of IPs to ignore. \ No newline at end of file +2. Ignored IPs (`NEWDEV_ignored_IPs`) - List of IPs to ignore. \ No newline at end of file diff --git a/docs/WEB_UI_PORT_DEBUG.md b/docs/WEB_UI_PORT_DEBUG.md index 9ea3f06f..6314c94a 100755 --- a/docs/WEB_UI_PORT_DEBUG.md +++ b/docs/WEB_UI_PORT_DEBUG.md @@ -43,4 +43,7 @@ In the container execute: ## 7. Make sure permissions are correct +> [!TIP] +> You can try to start the container without mapping the `/app/config` and `/app/db` dirs and if the UI shows up then the issue is most likely related to your file system permissions or file ownership. + Please read the [Permissions troubleshooting guide](/docs/FILE_PERMISSIONS.md) and provide a screesnhot of the permissions and ownership in the `/app/db` and `app/config` directories. \ No newline at end of file diff --git a/front/devices.php b/front/devices.php index b2135c80..4995e130 100755 --- a/front/devices.php +++ b/front/devices.php @@ -307,8 +307,6 @@ function getDevicesTotals(devicesData) { // Calculate count dynamically based on filter condition let count = filterDataByStatus(devicesData, filter.status).length; - console.log(getSetting('UI_hide_empty')); - // Check any condition to skip adding the object to dataArray if ( (['', 'False'].includes(getSetting('UI_hide_empty')) || (getSetting('UI_hide_empty') == "True" && count > 0)) && diff --git a/front/js/modal.js b/front/js/modal.js index cc4af4bd..bcb173d4 100755 --- a/front/js/modal.js +++ b/front/js/modal.js @@ -266,7 +266,7 @@ function checkNotification() { if (oldestInterruptNotification) { // Show modal dialog with the oldest unread notification - const decodedContent = JSON.parse(decodeURIComponent(oldestInterruptNotification.content)); + const decodedContent = decodeURIComponent(oldestInterruptNotification.content); showModalOK("Notification", decodedContent, function() { // Mark the notification as read diff --git a/front/maintenance.php b/front/maintenance.php index 4a38038d..af9021ae 100755 --- a/front/maintenance.php +++ b/front/maintenance.php @@ -425,8 +425,10 @@ $db->close();
+app.conf file.always_after_scan, on_new_device, on_notification"
+ "string": "When the plugin should run. Good options are always_after_scan, on_new_device, on_notification"
}
]
},
{
"function": "RUN_SCHD",
"type": "text",
-
"default_value": "*/5 * * * *",
"options": [],
"localized": ["name", "description"],
@@ -89,19 +80,11 @@
{
"language_code": "en_us",
"string": "Only enabled if you select schedule in the SYNC_RUN setting. Make sure you enter the schedule in the correct cron-like format (e.g. validate at crontab.guru). For example entering 0 4 * * * will run the scan after 4 am in the TIMEZONE you set above. Will be run NEXT time the time passes."
- },
- {
- "language_code": "es_es",
- "string": "Solo está habilitado si selecciona schedule en la configuración SYNC_RUN. Asegúrese de ingresar la programación en el formato similar a cron correcto (por ejemplo, valide en crontab.guru). Por ejemplo, ingresar 0 4 * * * ejecutará el escaneo después de las 4 a.m. en el TIMEZONE código> que configuró arriba. Se ejecutará la PRÓXIMA vez que pase el tiempo."
- },
- {
- "language_code": "de_de",
- "string": "Nur aktiviert, wenn Sie schedule in der SYNC_RUN-Einstellung auswählen. Stellen Sie sicher, dass Sie den Zeitplan im richtigen Cron-ähnlichen Format eingeben (z. B. validieren unter crontab.guru). Wenn Sie beispielsweise 0 4 * * * eingeben, wird der Scan nach 4 Uhr morgens in der TIMEZONE ausgeführt. Code> den Sie oben festgelegt haben. Wird das NÄCHSTE Mal ausgeführt, wenn die Zeit vergeht."
}
]
},
{
- "function": "api_token",
+ "function": "text_example",
"type": "text",
"maxLength": 50,
"default_value": "",
@@ -110,79 +93,18 @@
"name": [
{
"language_code": "en_us",
- "string": "API token"
+ "string": "Setting name"
}
],
"description": [
{
"language_code": "en_us",
- "string": "API token to secure communication. It's sent in the request header. The API token needs to be the same on the hub and on the nodes."
+ "string": "Description / simple setup instructions"
}
]
},
{
- "function": "encryption_key",
- "type": "text",
- "maxLength": 50,
- "default_value": "",
- "options": [],
- "localized": ["name", "description"],
- "name": [
- {
- "language_code": "en_us",
- "string": "Encryption Key"
- }
- ],
- "description": [
- {
- "language_code": "en_us",
- "string": "Encryption key used to encrypt the data before sending and for decryption on th ehub. The key needs to be the same on the hub and on the nodes."
- }
- ]
- },
- {
- "function": "hub_url",
- "type": "text",
-
- "maxLength": 50,
- "default_value": "",
- "options": [],
- "localized": ["name", "description"],
- "name": [
- {
- "language_code": "en_us",
- "string": "Hub URL"
- }
- ],
- "description": [
- {
- "language_code": "en_us",
- "string": "The URL of the hub (target instance). Set on the Node. Without a trailig slash, for example http://192.168.1.82:20211"
- }
- ]
- },
- {
- "function": "node_name",
- "type": "text",
- "maxLength": 50,
- "default_value": "",
- "options": [],
- "localized": ["name", "description"],
- "name": [
- {
- "language_code": "en_us",
- "string": "Node name"
- }
- ],
- "description": [
- {
- "language_code": "en_us",
- "string": "Use a unique node name, without spaces or special characters, such as Node_Vlan01"
- }
- ]
- },
- {
- "function": "devices",
+ "function": "boolean_example",
"type": "boolean",
"default_value": false,
"options": [],
@@ -190,18 +112,18 @@
"name": [
{
"language_code": "en_us",
- "string": "Sync Devices"
+ "string": "Setting name"
}
],
"description": [
{
"language_code": "en_us",
- "string": "When enabled the whole Devices table is sent over. Only new devices with new MACs are inserted in the target hub."
+ "string": "Description / simple setup instructions"
}
]
},
{
- "function": "plugins",
+ "function": "multiselect_example_from_setting",
"type": "text.multiselect",
"maxLength": 50,
"default_value": [],
@@ -217,13 +139,13 @@
"name": [
{
"language_code": "en_us",
- "string": "Sync Plugins"
+ "string": "Setting name"
}
],
"description": [
{
"language_code": "en_us",
- "string": "Plugins to synchronize. Only plugins that produce some kind of output in last_result.log can be synchronized."
+ "string": "Description / simple setup instructions"
}
]
},
@@ -237,28 +159,12 @@
{
"language_code": "en_us",
"string": "Command"
- },
- {
- "language_code": "es_es",
- "string": "Comando"
- },
- {
- "language_code": "de_de",
- "string": "Befehl"
}
],
"description": [
{
"language_code": "en_us",
"string": "Command to run. This can not be changed"
- },
- {
- "language_code": "es_es",
- "string": "Comando a ejecutar. Esto no se puede cambiar"
- },
- {
- "language_code": "de_de",
- "string": "Befehl zum Ausführen. Dies kann nicht geändert werden"
}
]
},
@@ -272,28 +178,12 @@
{
"language_code": "en_us",
"string": "Run timeout"
- },
- {
- "language_code": "es_es",
- "string": "Tiempo límite de ejecución"
- },
- {
- "language_code": "de_de",
- "string": "Zeitüberschreitung"
}
],
"description": [
{
"language_code": "en_us",
"string": "Maximum time in seconds to wait for the script to finish. If this time is exceeded the script is aborted."
- },
- {
- "language_code": "es_es",
- "string": "Tiempo máximo en segundos para esperar a que finalice el script. Si se supera este tiempo, el script se cancela."
- },
- {
- "language_code": "de_de",
- "string": "Maximale Zeit in Sekunden, die auf den Abschluss des Skripts gewartet werden soll. Bei Überschreitung dieser Zeit wird das Skript abgebrochen."
}
]
}
@@ -312,14 +202,6 @@
{
"language_code": "en_us",
"string": "MAC"
- },
- {
- "language_code": "es_es",
- "string": "MAC"
- },
- {
- "language_code": "de_de",
- "string": "MAC"
}
]
},
@@ -336,14 +218,6 @@
{
"language_code": "en_us",
"string": "IP"
- },
- {
- "language_code": "es_es",
- "string": "IP"
- },
- {
- "language_code": "de_de",
- "string": "IP"
}
]
},
@@ -376,14 +250,6 @@
{
"language_code": "en_us",
"string": "Vendor"
- },
- {
- "language_code": "es_es",
- "string": "Proveedor"
- },
- {
- "language_code": "de_de",
- "string": "Hersteller"
}
]
},
@@ -434,14 +300,6 @@
{
"language_code": "en_us",
"string": "Scan method"
- },
- {
- "language_code": "es_es",
- "string": "Método de escaneo"
- },
- {
- "language_code": "de_de",
- "string": "Scanmethode"
}
]
},
@@ -457,14 +315,6 @@
{
"language_code": "en_us",
"string": "Created"
- },
- {
- "language_code": "es_es",
- "string": "Creado"
- },
- {
- "language_code": "de_de",
- "string": "Erstellt"
}
]
},
@@ -480,14 +330,6 @@
{
"language_code": "en_us",
"string": "Changed"
- },
- {
- "language_code": "es_es",
- "string": "Cambiado"
- },
- {
- "language_code": "de_de",
- "string": "Geändert"
}
]
},
@@ -520,14 +362,6 @@
{
"language_code": "en_us",
"string": "Status"
- },
- {
- "language_code": "es_es",
- "string": "Estado"
- },
- {
- "language_code": "de_de",
- "string": "Status"
}
]
}
diff --git a/front/plugins/sync/config.json b/front/plugins/sync/config.json
index 4f12ba57..862efcfb 100755
--- a/front/plugins/sync/config.json
+++ b/front/plugins/sync/config.json
@@ -136,7 +136,7 @@
"description": [
{
"language_code": "en_us",
- "string": "Encryption key used to encrypt the data before sending and for decryption on th ehub. The key needs to be the same on the hub and on the nodes."
+ "string": "Encryption key used to encrypt the data before sending and for decryption on the hub. The key needs to be the same on the hub and on the nodes."
}
]
},
diff --git a/front/plugins/ui_settings/README.md b/front/plugins/ui_settings/README.md
index c73241c3..1ec55841 100755
--- a/front/plugins/ui_settings/README.md
+++ b/front/plugins/ui_settings/README.md
@@ -1,23 +1,8 @@
## Overview
-PLugin functionality overview and links to external resources if relevant. Include use cases if available.
-
-> [!TIP]
-> Some tip.
-
-### Quick setup guide
-
-To set up the plugin correctly, make sure...
-
-#### Required Settings
-
-- When to run `PREF_RUN`
--
+UI-related settings.
### Usage
-- Head to **Settings** > **Plugin name** to adjust the default values.
+- Head to **Settings** > **UI Settings** to adjust the default values.
-### Notes
-
-- Additional notes, limitations, Author info.
\ No newline at end of file
diff --git a/front/plugins/unifi_import/README.md b/front/plugins/unifi_import/README.md
index 08ea07fd..9a891420 100755
--- a/front/plugins/unifi_import/README.md
+++ b/front/plugins/unifi_import/README.md
@@ -6,14 +6,16 @@ A plugin allowing for importing devices from a UniFi controller.
Specify the following settings in the Settings section of NetAlertX:
-- `UNFIMP_username` - Username used to login into the UNIFI controller.
-- `UNFIMP_password` - Password used to login into the UNIFI controller.
-- `UNFIMP_host` - Host url or IP address where the UNIFI controller is hosted (excluding http://)
+- `UNFIMP_username` - Username used to log in the UNIFI controller.
+- `UNFIMP_password` - Password used to log in the UNIFI controller.
+- `UNFIMP_host` - Host URL or IP address where the UNIFI controller is hosted (excluding `http://`)
- `UNFIMP_sites` - Name of the sites (usually 'default', check the URL in your UniFi controller UI if unsure. The site id is in the following part of the URL: `https://192.168.1.1:8443/manage/site/this-is-the-site-id/settings/`).
- `UNFIMP_protocol` - https:// or http://
-- `UNFIMP_port` - Usually 8443
+- `UNFIMP_port` - Usually `8443` or `8843`
+- `UNFIMP_version` - e.g. `UDMP-unifiOS` is used for the "Cloud Gateway Ultra"
+
### Notes
- Currently only used to import devices, not their status, type or network map.
-- It is recommend to create a read-only user in your UniFi controller
\ No newline at end of file
+- It is recommended to create a read-only user in your UniFi controller
\ No newline at end of file
diff --git a/front/settings.php b/front/settings.php
index f8d33a63..9bf7394f 100755
--- a/front/settings.php
+++ b/front/settings.php
@@ -122,7 +122,7 @@ $settingsJSON_DB = json_encode($settings, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX