From 93369881b9cf7ff3937362d0fc2d1344a8e33ec6 Mon Sep 17 00:00:00 2001 From: Skylark Date: Thu, 1 Aug 2024 15:32:17 +0000 Subject: [PATCH 1/5] adding xmlwriter --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index c340a262..48de9790 100644 --- a/Dockerfile +++ b/Dockerfile @@ -62,6 +62,7 @@ RUN apk --update --no-cache add \ php82-sockets \ php82-tokenizer \ php82-xml \ + php82-xmlwriter \ php82-zip \ python3 \ py3-pip \ From d751ffaadd0e00ae8d9a9d31ad73b391ac01dbdd Mon Sep 17 00:00:00 2001 From: Skylark Date: Fri, 13 Sep 2024 10:47:27 +0000 Subject: [PATCH 2/5] add plugin installer --- Dockerfile | 1 + README.md | 10 ++++++ rootfs/etc/cont-init.d/09-install-plugins.sh | 34 ++++++++++++++++++++ 3 files changed, 45 insertions(+) create mode 100644 rootfs/etc/cont-init.d/09-install-plugins.sh diff --git a/Dockerfile b/Dockerfile index 09588090..9028ae5e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -62,6 +62,7 @@ RUN apk --update --no-cache add \ php82-sockets \ php82-tokenizer \ php82-xml \ + php82-xmlwriter \ php82-zip \ python3 \ py3-pip \ diff --git a/README.md b/README.md index 8a671c2b..ae5f6ee7 100644 --- a/README.md +++ b/README.md @@ -188,6 +188,16 @@ Image: librenms/librenms:latest * `DB_PASSWORD`: MySQL password (default `librenms`) * `DB_TIMEOUT`: Time in seconds after which we stop trying to reach the MySQL server (useful for clusters, default `60`) +### Plugins +* `INSTALL_PLUGINS`: Space-separated list of plugins to install + +> This environment variable allows you to specify which plugins should be installed +> in your LibreNMS container. It's particularly useful for enabling SAML authentication. +> The value should be a space-separated list of plugin names. + + +* `DB_HOST`: MySQL database hostname / IP address + ### Misc * `LIBRENMS_BASE_URL`: URL of your LibreNMS instance (default `/`) diff --git a/rootfs/etc/cont-init.d/09-install-plugins.sh b/rootfs/etc/cont-init.d/09-install-plugins.sh new file mode 100644 index 00000000..8b3149f9 --- /dev/null +++ b/rootfs/etc/cont-init.d/09-install-plugins.sh @@ -0,0 +1,34 @@ +#!/usr/bin/with-contenv sh +# shellcheck shell=sh +set -e + +INSTALL_PLUGINS=${INSTALL_PLUGINS:-0} +SIDECAR_DISPATCHER=${SIDECAR_DISPATCHER:-0} +SIDECAR_SYSLOGNG=${SIDECAR_SYSLOGNG:-0} +SIDECAR_SNMPTRAPD=${SIDECAR_SNMPTRAPD:-0} + +# Exit if any sidecar is enabled +if [ "$SIDECAR_DISPATCHER" = "1" ] || [ "$SIDECAR_SYSLOGNG" = "1" ] || [ "$SIDECAR_SNMPTRAPD" = "1" ]; then + exit 0 +fi + +# Exit if plugins are not needed +if [ "$INSTALL_PLUGINS" = "0" ]; then + exit 0 +fi + +echo ">> Plugin configuration detected" + +echo "Fixing permissions..." +chown librenms:librenms \ + "${LIBRENMS_PATH}"/composer.* \ + "${LIBRENMS_PATH}/logs/librenms.log" \ + "${LIBRENMS_PATH}/scripts/composer_wrapper.php" + +chown -R librenms:librenms \ + "${LIBRENMS_PATH}/scripts" \ + "${LIBRENMS_PATH}/vendor" \ + "${LIBRENMS_PATH}/bootstrap" + +# Install plugins +lnms plugin:add "$INSTALL_PLUGINS" From 24b213082703ac5f2865c3c5d36c452463abdf04 Mon Sep 17 00:00:00 2001 From: Skylark Date: Fri, 13 Sep 2024 10:48:43 +0000 Subject: [PATCH 3/5] text cleanup --- README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/README.md b/README.md index ae5f6ee7..2b650cee 100644 --- a/README.md +++ b/README.md @@ -195,9 +195,6 @@ Image: librenms/librenms:latest > in your LibreNMS container. It's particularly useful for enabling SAML authentication. > The value should be a space-separated list of plugin names. - -* `DB_HOST`: MySQL database hostname / IP address - ### Misc * `LIBRENMS_BASE_URL`: URL of your LibreNMS instance (default `/`) From f5959002dc7e9ce915a1f457de0756f2259126f2 Mon Sep 17 00:00:00 2001 From: Skylark Date: Wed, 16 Oct 2024 13:26:16 +0000 Subject: [PATCH 4/5] Php 8.3 update --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index fee2bb21..dbe38812 100644 --- a/Dockerfile +++ b/Dockerfile @@ -62,6 +62,7 @@ RUN apk --update --no-cache add \ php83-sockets \ php83-tokenizer \ php83-xml \ + php83-xmlwriter \ php83-zip \ python3 \ py3-pip \ From 1aedf4bae9a3fdaa4da37782d048f2be55437d11 Mon Sep 17 00:00:00 2001 From: Skylark Date: Mon, 27 Jan 2025 09:40:22 +0000 Subject: [PATCH 5/5] Create 09-plugin-add.sh --- rootfs/etc/cont-init.d/09-plugin-add.sh | 43 +++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 rootfs/etc/cont-init.d/09-plugin-add.sh diff --git a/rootfs/etc/cont-init.d/09-plugin-add.sh b/rootfs/etc/cont-init.d/09-plugin-add.sh new file mode 100644 index 00000000..318197a5 --- /dev/null +++ b/rootfs/etc/cont-init.d/09-plugin-add.sh @@ -0,0 +1,43 @@ +#!/usr/bin/with-contenv sh +# shellcheck shell=sh +set -e + +INSTALL_PLUGINS=${INSTALL_PLUGINS:-0} + +# Continue only if plugins are needed +if [ "$INSTALL_PLUGINS" = "0" ]; then + exit 0 +fi + +echo ">>" +echo ">> Plugin configuration detected" +echo ">>" + +# Fix perms +echo "Fixing perms..." +chown librenms:librenms \ + ${LIBRENMS_PATH}/composer.* \ + ${LIBRENMS_PATH}/logs/librenms.log \ + ${LIBRENMS_PATH}/scripts/composer_wrapper.php +chown -R librenms:librenms \ + ${LIBRENMS_PATH}/scripts \ + ${LIBRENMS_PATH}/vendor \ + ${LIBRENMS_PATH}/bootstrap + +# Create service +IFS=, read -ra PLUGINS <<< "$INSTALL_PLUGINS" + +for plugin in "${PLUGINS[@]}"; do + echo "Installing plugin: $plugin" + + if ! lnms plugin:installed "$plugin"; then + if ! lnms plugin:add "$plugin"; then + echo "Error installing $plugin" >&2 + exit 1 + fi + echo "Installed $plugin" + else + echo "$plugin already installed" + fi + +done