From a426e80b83f2e804b833540ce26b480a3e70c70a Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Thu, 13 Mar 2025 15:32:38 +0100 Subject: [PATCH] NPMplus (NginxProxyManager-plus) (#3051) --- ct/npmplus.sh | 41 ++++++++++++++ install/npmplus-install.sh | 107 +++++++++++++++++++++++++++++++++++++ json/npmplus.json | 54 +++++++++++++++++++ 3 files changed, 202 insertions(+) create mode 100644 ct/npmplus.sh create mode 100644 install/npmplus-install.sh create mode 100644 json/npmplus.json diff --git a/ct/npmplus.sh b/ct/npmplus.sh new file mode 100644 index 000000000..b43129820 --- /dev/null +++ b/ct/npmplus.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) +# Copyright (c) 2021-2025 community-scripts ORG +# Author: MickLesk (CanbiZ) +# License: MIT | https://github.com/community-scripts/ProxmoxVED/raw/main/LICENSE +# Source: https://github.com/ZoeyVid/NPMplus + +APP="NPMplus" +var_tags="proxy;nginx" +var_cpu="1" +var_ram="512" +var_disk="3" +var_os="alpine" +var_version="3.21" +var_unprivileged="1" + +header_info "$APP" +variables +color +catch_errors + +function update_script() { + UPD=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "SUPPORT" --radiolist --cancel-button Exit-Script "Spacebar = Select" 11 58 1 \ + "1" "Check for Alpine Updates" ON \ + 3>&1 1>&2 2>&3) + + header_info + if [ "$UPD" == "1" ]; then + apk update && apk upgrade + exit + fi +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" +echo -e "${INFO}${YW} Access it using the following URL:${CL}" +echo -e "${TAB}${GATEWAY}${BGN}https://${IP}:81${CL}" diff --git a/install/npmplus-install.sh b/install/npmplus-install.sh new file mode 100644 index 000000000..a71a8aa38 --- /dev/null +++ b/install/npmplus-install.sh @@ -0,0 +1,107 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2025 community-scripts ORG +# Author: MickLesk (CanbiZ) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://github.com/ZoeyVid/NPMplus + +source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apk add \ + newt \ + curl \ + openssh \ + tzdata \ + nano \ + gawk \ + yq \ + mc + +msg_ok "Installed Dependencies" + +msg_info "Installing Docker & Compose" +$STD apk add docker +$STD rc-service docker start +$STD rc-update add docker default + +get_latest_release() { + curl -sL https://api.github.com/repos/$1/releases/latest | grep '"tag_name":' | cut -d'"' -f4 +} +DOCKER_COMPOSE_LATEST_VERSION=$(get_latest_release "docker/compose") +DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker} +mkdir -p $DOCKER_CONFIG/cli-plugins +curl -sSL https://github.com/docker/compose/releases/download/$DOCKER_COMPOSE_LATEST_VERSION/docker-compose-linux-x86_64 -o ~/.docker/cli-plugins/docker-compose +chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose +msg_ok "Installed Docker & Compose" + +msg_info "Fetching NPMplus" +cd /opt +wget -q https://raw.githubusercontent.com/ZoeyVid/NPMplus/refs/heads/develop/compose.yaml +msg_ok "Fetched NPMplus" + +attempts=0 +while true; do + read -r -p "Enter your TZ Identifier (e.g., Europe/Berlin): " TZ_INPUT + if validate_tz "$TZ_INPUT"; then + break + fi + msg_error "Invalid timezone! Please enter a valid TZ identifier." + + attempts=$((attempts + 1)) + if [[ "$attempts" -ge 3 ]]; then + msg_error "Maximum attempts reached. Exiting." + exit 1 + fi +done + +read -r -p "Enter your ACME Email: " ACME_EMAIL_INPUT + +yq -i " + .services.npmplus.environment |= + (map(select(. != \"TZ=*\" and . != \"ACME_EMAIL=*\")) + + [\"TZ=$TZ_INPUT\", \"ACME_EMAIL=$ACME_EMAIL_INPUT\"]) +" /opt/compose.yaml + +msg_info "Building and Starting NPMplus (Patience)" +$STD docker compose up -d +CONTAINER_ID="" +for i in {1..60}; do + CONTAINER_ID=$(docker ps --filter "name=npmplus" --format "{{.ID}}") + if [[ -n "$CONTAINER_ID" ]]; then + STATUS=$(docker inspect --format '{{.State.Health.Status}}' "$CONTAINER_ID" 2>/dev/null || echo "starting") + if [[ "$STATUS" == "healthy" ]]; then + msg_ok "NPMplus is running and healthy" + break + elif [[ "$STATUS" == "unhealthy" ]]; then + msg_error "NPMplus container is unhealthy! Check logs." + docker logs "$CONTAINER_ID" + exit 1 + fi + fi + sleep 2 + [[ $i -eq 60 ]] && msg_error "NPMplus container did not become healthy within 120s." && docker logs "$CONTAINER_ID" && exit 1 +done +msg_ok "Builded and started NPMplus" + +motd_ssh +customize + +msg_info "Retrieving Default Login (Patience)" +for i in {1..60}; do + PASSWORD_LINE=$(docker logs "$CONTAINER_ID" 2>&1 | awk '/Creating a new user:/ {print; exit}') + if [[ -n "$PASSWORD_LINE" ]]; then + PASSWORD=$(echo "$PASSWORD_LINE" | awk -F 'password: ' '{print $2}') + echo -e "username: admin@example.org\npassword: $PASSWORD" >/opt/.npm_pwd + msg_ok "Saved default login to /opt/.npm_pwd" + exit 0 + fi + sleep 2 + [[ $i -eq 60 ]] && msg_error "Failed to retrieve default login credentials." && exit 1 +done diff --git a/json/npmplus.json b/json/npmplus.json new file mode 100644 index 000000000..c3f39124f --- /dev/null +++ b/json/npmplus.json @@ -0,0 +1,54 @@ +{ + "name": "NPMplus", + "slug": "npmplus", + "categories": [ + 21 + ], + "date_created": "2025-03-13", + "type": "ct", + "updateable": false, + "privileged": false, + "interface_port": 81, + "documentation": null, + "website": "https://github.com/ZoeyVid/NPMplus", + "logo": "https://raw.githubusercontent.com/ZoeyVid/NPMplus/refs/heads/develop/frontend/app-images/logo-256.png", + "description": "NPMplus is an enhanced version of Nginx Proxy Manager. It simplifies the process of setting up reverse proxies with TLS termination through a user-friendly web interface. Key features include HTTP/3 support, integration with CrowdSec IPS, inclusion of GoAccess for real-time log analysis, and support for ModSecurity with the Core Rule Set.", + "install_methods": [ + { + "type": "default", + "script": "ct/npmplus.sh", + "resources": { + "cpu": 1, + "ram": 512, + "hdd": 3, + "os": "alpine", + "version": "3.21" + } + }, + { + "type": "alpine", + "script": "ct/npmplus.sh", + "resources": { + "cpu": 1, + "ram": 512, + "hdd": 3, + "os": "alpine", + "version": "3.21" + } + } + ], + "default_credentials": { + "username": "root", + "password": null + }, + "notes": [ + { + "text": "The initial starting process can be take 1-2min. ", + "type": "info" + }, + { + "text": "Application credentials: ´cat /opt/.npm_pwd´", + "type": "info" + } + ] +}