From 1aedf4bae9a3fdaa4da37782d048f2be55437d11 Mon Sep 17 00:00:00 2001 From: Skylark Date: Mon, 27 Jan 2025 09:40:22 +0000 Subject: [PATCH] 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 0000000..318197a --- /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