mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-10-24 20:25:24 +00:00
* install: answer every prompt from the environment, survive a closed stdin Every interactive prompt takes a var_<app>_<name> override and treats a closed stdin like Enter (`|| true`), so an install keeps going after the console that started it is gone. Values the script cannot do without end with exit 64 and name the variable to set. Validation loops stop asking when nobody can answer instead of spinning on an empty read. * mongodb, paperless-gpt: accept yes as well as y
91 lines
3.1 KiB
Bash
91 lines
3.1 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
# Copyright (c) 2021-2026 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 \
|
|
tzdata \
|
|
gawk \
|
|
yq
|
|
msg_ok "Installed Dependencies"
|
|
|
|
msg_info "Installing Docker & Compose"
|
|
$STD apk add docker
|
|
$STD rc-service docker start
|
|
$STD rc-update add docker default
|
|
|
|
DOCKER_COMPOSE_LATEST_VERSION=$(get_latest_github_release "docker/compose" false)
|
|
DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker}
|
|
mkdir -p $DOCKER_CONFIG/cli-plugins
|
|
curl -fsSL https://github.com/docker/compose/releases/download/$DOCKER_COMPOSE_LATEST_VERSION/docker-compose-linux-$(arch_resolve "x86_64" "aarch64") -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
|
|
curl -fsSL "https://raw.githubusercontent.com/ZoeyVid/NPMplus/refs/heads/develop/compose.yaml" -o compose.yaml
|
|
msg_ok "Fetched NPMplus"
|
|
|
|
attempts=0
|
|
TZ_INPUT="${var_npmplus_tz:-}"
|
|
while true; do
|
|
[[ -n "$TZ_INPUT" ]] || read -r -p "${TAB3}Enter your TZ Identifier (e.g., Europe/Berlin): " TZ_INPUT || { msg_error "No TZ identifier given; set var_npmplus_tz or answer the prompt"; exit 64; }
|
|
if validate_tz "$TZ_INPUT"; then
|
|
break
|
|
fi
|
|
msg_error "Invalid timezone! Please enter a valid TZ identifier."
|
|
TZ_INPUT=""
|
|
|
|
attempts=$((attempts + 1))
|
|
if [[ "$attempts" -ge 3 ]]; then
|
|
msg_error "Maximum attempts reached. Exiting."
|
|
exit 254
|
|
fi
|
|
done
|
|
|
|
ACME_EMAIL_INPUT="${var_npmplus_acme_email:-}"
|
|
[[ -n "$ACME_EMAIL_INPUT" ]] || read -r -p "${TAB3}Enter your ACME Email: " ACME_EMAIL_INPUT || true
|
|
[[ -n "$ACME_EMAIL_INPUT" ]] || { msg_error "No ACME e-mail given; set var_npmplus_acme_email or answer the prompt"; exit 64; }
|
|
|
|
yq -i "
|
|
.services.npmplus.environment |=
|
|
(map(select(. != \"TZ=*\" and . != \"ACME_EMAIL=*\" and . != \"INITIAL_ADMIN_EMAIL=*\" and . != \"INITIAL_ADMIN_PASSWORD=*\")) +
|
|
[\"TZ=$TZ_INPUT\", \"ACME_EMAIL=$ACME_EMAIL_INPUT\", \"INITIAL_ADMIN_EMAIL=admin@local.com\", \"INITIAL_ADMIN_PASSWORD=community-scripts.org\"])
|
|
" /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 150
|
|
fi
|
|
fi
|
|
sleep 2
|
|
[[ $i -eq 60 ]] && msg_error "NPMplus container did not become healthy within 120s." && docker logs "$CONTAINER_ID" && exit 150
|
|
done
|
|
msg_ok "Builded and started NPMplus"
|
|
|
|
motd_ssh
|
|
customize
|
|
cleanup_lxc
|