2023-12-19 19:49:20 -05:00
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
2026-01-06 13:28:12 +01:00
|
|
|
|
# Copyright (c) 2021-2026 tteck
|
2023-12-19 19:49:20 -05:00
|
|
|
|
# Author: tteck (tteckster)
|
several scripts: add additional github link in source (#12282)
* fix(error-handler): prevent silent() from re-enabling error handling during recovery
Root cause: silent() (core.func) unconditionally calls set -Eeuo pipefail
and trap 'error_handler' ERR after every command. When build_container()
intentionally disables error handling for its recovery section, any
intermediate call through silent()/ re-enables it. This causes the
grep/sed pipeline for missing_cmd extraction to trigger error_handler
(grep returns exit code 1 on no match + pipefail = fatal).
Fixes:
1. silent(): Save errexit state before disabling, only restore if it was
active. Callers that intentionally disabled error handling (e.g.
build_container recovery) are no longer silently re-enabled.
2. build.func: Add || true to missing_cmd grep pipeline as defense-in-depth
against pipeline failure propagation.
3. build.func: Add explicit set +Eeuo pipefail / trap - ERR after
post_update_to_api() call, before error classification grep/sed section.
4. build.func: Remove stale global combined_log variable from variables()
that used a different path format (/tmp/install-SESSION-combined.log)
than the actual local variable (/tmp/NSAPP-CTID-SESSION.log). The global
was never written to and caused confusion when error_handler displayed it.
* Update build.func
* chore(install): add Github source links to all setup_nodejs scripts
52 install scripts had a project website in '# Source:' but no GitHub
link. Merged the GitHub repo URL into the Source header as:
# Source: https://website.com/ | Github: https://github.com/OWNER/REPO
Repos sourced from fetch_and_deploy_gh_release calls, get_latest_github_release
calls, or known project repos for npm/pip installed apps.
Two scripts (fumadocs, pve-scripts-local) had no Source line at all —
added one. Shinobi skipped (GitLab-only, no GitHub repo).
* chore(install): add Github source links to all fetch_and_deploy scripts
77 additional install scripts had fetch_and_deploy_gh_release calls but
no GitHub link in the Source header. Merged the primary app repo into
the Source header as:
# Source: https://website.com/ | Github: https://github.com/OWNER/REPO
Where multiple fetch_and_deploy calls existed (app + dependency), the
primary app repo was selected:
- ersatztv: ErsatzTV/ErsatzTV (not ffmpeg)
- firefly: firefly-iii/firefly-iii (not data-importer)
- komga: gotson/komga (not kepubify dep)
- sabnzbd: sabnzbd/sabnzbd (not par2cmdline-turbo dep)
- signoz: SigNoz/signoz (not otel-collector)
- tunarr: chrisbenincasa/tunarr (not ffmpeg dep)
Also fixed cosmos-install.sh double https:// in Source URL.
Skipped: autocaliweb (source already on codeberg, GitHub repos are deps only)
* revert: restore misc/build.func and misc/core.func to main state
These error-handler fixes belong to fix/error-handler-recovery, not to
this sources-only branch.
* chore(ct,tools): sync Source headers with install/ and add Github links to addon scripts
2026-02-24 15:11:53 +01:00
|
|
|
|
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
|
|
|
|
|
# Source: https://www.netdata.cloud/ | Github: https://github.com/netdata/netdata
|
2023-12-19 19:49:20 -05:00
|
|
|
|
|
2023-12-20 11:25:00 -05:00
|
|
|
|
function header_info {
|
2025-04-01 10:25:46 +02:00
|
|
|
|
clear
|
|
|
|
|
|
cat <<"EOF"
|
2023-12-19 19:49:20 -05:00
|
|
|
|
_ __ __ ____ __
|
|
|
|
|
|
/ | / /__ / /_/ __ \____ _/ /_____ _
|
|
|
|
|
|
/ |/ / _ \/ __/ / / / __ `/ __/ __ `/
|
|
|
|
|
|
/ /| / __/ /_/ /_/ / /_/ / /_/ /_/ /
|
|
|
|
|
|
/_/ |_/\___/\__/_____/\__,_/\__/\__,_/
|
|
|
|
|
|
|
|
|
|
|
|
EOF
|
2023-12-20 11:25:00 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
YW=$(echo "\033[33m")
|
|
|
|
|
|
BL=$(echo "\033[36m")
|
|
|
|
|
|
RD=$(echo "\033[01;31m")
|
|
|
|
|
|
GN=$(echo "\033[1;92m")
|
|
|
|
|
|
CL=$(echo "\033[m")
|
|
|
|
|
|
BFR="\\r\\033[K"
|
|
|
|
|
|
HOLD="-"
|
|
|
|
|
|
CM="${GN}✓${CL}"
|
|
|
|
|
|
silent() { "$@" >/dev/null 2>&1; }
|
2026-02-17 16:36:20 +01:00
|
|
|
|
|
|
|
|
|
|
# Telemetry
|
|
|
|
|
|
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/api.func) 2>/dev/null || true
|
core: Execution ID & Telemetry Improvements (#12041)
* fix: send telemetry BEFORE log collection in signal handlers
- Swap ensure_log_on_host/post_update_to_api order in on_interrupt, on_terminate, api_exit_script, and inline SIGHUP/SIGINT/SIGTERM traps
- For signal exits (>128): send telemetry immediately, then best-effort log collection
- Add 2>/dev/null || true to all I/O in signal handlers to prevent SIGPIPE
- Fix on_exit: exit_code=0 now reports 'done' instead of 'failed 1'
- Root cause: pct pull hangs on dying containers blocked telemetry updates, leaving 595+ records stuck in 'installing' daily
* feat: add execution_id to all telemetry payloads
- Generate EXECUTION_ID from RANDOM_UUID in variables()
- Export EXECUTION_ID to container environment
- Add execution_id field to all 8 API payloads in api.func
- Add execution_id to post_progress_to_api in install.func and alpine-install.func
- Fallback to RANDOM_UUID when EXECUTION_ID not set (backward compat)
* fix: correct telemetry type values for PVE and addon scripts
- PVE scripts (tools/pve/*): change type 'tool' -> 'pve'
- Addon scripts (tools/addon/*): fix 4 scripts that wrongly used 'tool' -> 'addon'
(netdata, add-tailscale-lxc, add-netbird-lxc, all-templates)
- api.func: post_tool_to_api sends type='pve', default fallback 'pve'
- Aligns with PocketBase categories: lxc, vm, pve, addon
* fix: persist diagnostics opt-in inside containers for addon telemetry
- install.func + alpine-install.func: create /usr/local/community-scripts/diagnostics
inside the container when DIAGNOSTICS=yes (from build.func export)
- Enables addon scripts running later inside containers to find the opt-in
- Update init_tool_telemetry default type from 'tool' to 'pve'
* refactor: clean up diagnostics/telemetry opt-in system
- diagnostics_check(): deduplicate heredoc (was 2x 22 lines), improve whiptail
text with clear what/what-not collected, add telemetry + privacy links
- diagnostics_menu(): better UX with current status, clear enable/disable
buttons, note about existing containers
- variables(): change DIAGNOSTICS default from 'yes' to 'no' (safe: no
telemetry before user consents via diagnostics_check)
- install.func + alpine-install.func: persist BOTH yes AND no in container
so opt-out is explicit (not just missing file = no)
- Fix typo 'menue' -> 'menu' in config file comments
* fix: no pre-selection in telemetry dialog, link to telemetry-service README
- Add --defaultno so 'No, opt out' is focused by default (user must Tab to Yes)
- Change privacy link from discussions/1836 to telemetry-service#privacy--compliance
* fix: use radiolist for telemetry dialog (no pre-selection)
- Replace --yesno with --radiolist: user must actively SPACE-select an option
- Both options start as OFF (no pre-selection)
- Cancel/Exit defaults to 'no' (opt-out)
* simplify: inline telemetry dialog text like other whiptail dialogs
* improve: telemetry dialog with more detail, link to PRIVACY.md
- Add what we collect / don't collect sections back to dialog
- Link to telemetry-service/docs/PRIVACY.md instead of README anchor
- Update config file comment with same link
2026-02-18 10:24:06 +01:00
|
|
|
|
declare -f init_tool_telemetry &>/dev/null && init_tool_telemetry "netdata" "addon"
|
2026-02-17 16:36:20 +01:00
|
|
|
|
|
2023-12-20 11:25:00 -05:00
|
|
|
|
set -e
|
|
|
|
|
|
header_info
|
2023-12-22 19:45:53 -05:00
|
|
|
|
echo "Loading..."
|
2023-12-20 11:25:00 -05:00
|
|
|
|
function msg_info() {
|
|
|
|
|
|
local msg="$1"
|
|
|
|
|
|
echo -ne " ${HOLD} ${YW}${msg}..."
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function msg_ok() {
|
|
|
|
|
|
local msg="$1"
|
|
|
|
|
|
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
|
|
|
|
|
|
}
|
2023-12-19 19:49:20 -05:00
|
|
|
|
|
2025-08-20 14:00:10 +02:00
|
|
|
|
function msg_error() { echo -e "${RD}✗ $1${CL}"; }
|
|
|
|
|
|
|
2025-09-04 10:28:09 +02:00
|
|
|
|
# This function checks the version of Proxmox Virtual Environment (PVE) and exits if the version is not supported.
|
2025-11-20 13:01:01 +01:00
|
|
|
|
# Supported: Proxmox VE 8.0.x – 8.9.x and 9.0–9.1.x
|
2025-08-20 14:00:10 +02:00
|
|
|
|
pve_check() {
|
|
|
|
|
|
local PVE_VER
|
|
|
|
|
|
PVE_VER="$(pveversion | awk -F'/' '{print $2}' | awk -F'-' '{print $1}')"
|
|
|
|
|
|
|
2025-09-04 10:28:09 +02:00
|
|
|
|
# Check for Proxmox VE 8.x: allow 8.0–8.9
|
|
|
|
|
|
if [[ "$PVE_VER" =~ ^8\.([0-9]+) ]]; then
|
2025-08-20 14:00:10 +02:00
|
|
|
|
local MINOR="${BASH_REMATCH[1]}"
|
2025-09-04 10:28:09 +02:00
|
|
|
|
if ((MINOR < 0 || MINOR > 9)); then
|
|
|
|
|
|
msg_error "This version of Proxmox VE is not supported."
|
|
|
|
|
|
msg_error "Supported: Proxmox VE version 8.0 – 8.9"
|
2025-08-20 14:00:10 +02:00
|
|
|
|
exit 1
|
|
|
|
|
|
fi
|
|
|
|
|
|
return 0
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
2025-11-20 13:01:01 +01:00
|
|
|
|
# Check for Proxmox VE 9.x: allow 9.0–9.1.x
|
2025-09-04 10:28:09 +02:00
|
|
|
|
if [[ "$PVE_VER" =~ ^9\.([0-9]+) ]]; then
|
2025-08-20 14:00:10 +02:00
|
|
|
|
local MINOR="${BASH_REMATCH[1]}"
|
2025-11-20 13:01:01 +01:00
|
|
|
|
if ((MINOR < 0 || MINOR > 1)); then
|
2025-09-04 10:28:09 +02:00
|
|
|
|
msg_error "This version of Proxmox VE is not yet supported."
|
2025-11-20 13:01:01 +01:00
|
|
|
|
msg_error "Supported: Proxmox VE version 9.0–9.1.x"
|
2025-08-20 14:00:10 +02:00
|
|
|
|
exit 1
|
|
|
|
|
|
fi
|
|
|
|
|
|
return 0
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
2025-09-04 10:28:09 +02:00
|
|
|
|
# All other unsupported versions
|
|
|
|
|
|
msg_error "This version of Proxmox VE is not supported."
|
2025-11-20 13:01:01 +01:00
|
|
|
|
msg_error "Supported versions: Proxmox VE 8.0 – 8.9 or 9.0–9.1.x"
|
2025-08-20 14:00:10 +02:00
|
|
|
|
exit 1
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
detect_codename() {
|
|
|
|
|
|
source /etc/os-release
|
|
|
|
|
|
if [[ "$ID" != "debian" ]]; then
|
|
|
|
|
|
msg_error "Unsupported base OS: $ID (only Proxmox VE / Debian supported)."
|
|
|
|
|
|
exit 1
|
|
|
|
|
|
fi
|
|
|
|
|
|
CODENAME="${VERSION_CODENAME:-}"
|
|
|
|
|
|
if [[ -z "$CODENAME" ]]; then
|
|
|
|
|
|
msg_error "Could not detect Debian codename."
|
|
|
|
|
|
exit 1
|
|
|
|
|
|
fi
|
|
|
|
|
|
echo "$CODENAME"
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
get_latest_repo_pkg() {
|
|
|
|
|
|
local REPO_URL=$1
|
|
|
|
|
|
curl -fsSL "$REPO_URL" |
|
|
|
|
|
|
grep -oP 'netdata-repo_[^"]+all\.deb' |
|
|
|
|
|
|
sort -V |
|
|
|
|
|
|
tail -n1
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-12-19 19:49:20 -05:00
|
|
|
|
install() {
|
2023-12-22 19:45:53 -05:00
|
|
|
|
header_info
|
2023-12-20 11:25:00 -05:00
|
|
|
|
while true; do
|
2025-08-20 14:00:10 +02:00
|
|
|
|
read -p "Are you sure you want to install NetData on Proxmox VE host. Proceed(y/n)? " yn
|
2023-12-20 11:25:00 -05:00
|
|
|
|
case $yn in
|
|
|
|
|
|
[Yy]*) break ;;
|
|
|
|
|
|
[Nn]*) exit ;;
|
|
|
|
|
|
*) echo "Please answer yes or no." ;;
|
|
|
|
|
|
esac
|
|
|
|
|
|
done
|
2025-08-20 14:00:10 +02:00
|
|
|
|
|
2023-12-20 11:25:00 -05:00
|
|
|
|
read -r -p "Verbose mode? <y/N> " prompt
|
2025-08-20 14:00:10 +02:00
|
|
|
|
[[ ${prompt,,} =~ ^(y|yes)$ ]] && STD="" || STD="silent"
|
|
|
|
|
|
|
|
|
|
|
|
CODENAME=$(detect_codename)
|
|
|
|
|
|
REPO_URL="https://repo.netdata.cloud/repos/repoconfig/debian/${CODENAME}/"
|
2023-12-22 19:45:53 -05:00
|
|
|
|
|
2023-12-20 11:25:00 -05:00
|
|
|
|
msg_info "Setting up repository"
|
2025-03-29 14:04:28 +01:00
|
|
|
|
$STD apt-get install -y debian-keyring
|
2025-08-20 14:00:10 +02:00
|
|
|
|
PKG=$(get_latest_repo_pkg "$REPO_URL")
|
|
|
|
|
|
if [[ -z "$PKG" ]]; then
|
|
|
|
|
|
msg_error "Could not find netdata-repo package for Debian $CODENAME"
|
|
|
|
|
|
exit 1
|
|
|
|
|
|
fi
|
|
|
|
|
|
curl -fsSL "${REPO_URL}${PKG}" -o "$PKG"
|
|
|
|
|
|
$STD dpkg -i "$PKG"
|
|
|
|
|
|
rm -f "$PKG"
|
2023-12-20 11:25:00 -05:00
|
|
|
|
msg_ok "Set up repository"
|
2023-12-19 19:49:20 -05:00
|
|
|
|
|
2023-12-20 11:25:00 -05:00
|
|
|
|
msg_info "Installing Netdata"
|
|
|
|
|
|
$STD apt-get update
|
|
|
|
|
|
$STD apt-get install -y netdata
|
2023-12-22 19:45:53 -05:00
|
|
|
|
msg_ok "Installed Netdata"
|
2026-01-06 22:57:40 +01:00
|
|
|
|
msg_ok "Completed successfully!\n"
|
2023-12-20 11:25:00 -05:00
|
|
|
|
echo -e "\n Netdata should be reachable at${BL} http://$(hostname -I | awk '{print $1}'):19999 ${CL}\n"
|
2023-12-19 19:49:20 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
uninstall() {
|
2023-12-22 19:45:53 -05:00
|
|
|
|
header_info
|
2023-12-20 11:25:00 -05:00
|
|
|
|
read -r -p "Verbose mode? <y/N> " prompt
|
2025-08-20 14:00:10 +02:00
|
|
|
|
[[ ${prompt,,} =~ ^(y|yes)$ ]] && STD="" || STD="silent"
|
2023-12-22 19:45:53 -05:00
|
|
|
|
|
|
|
|
|
|
msg_info "Uninstalling Netdata"
|
2025-08-20 14:00:10 +02:00
|
|
|
|
systemctl stop netdata || true
|
2023-12-20 11:25:00 -05:00
|
|
|
|
rm -rf /var/log/netdata /var/lib/netdata /var/cache/netdata /etc/netdata/go.d
|
|
|
|
|
|
rm -rf /etc/apt/trusted.gpg.d/netdata-archive-keyring.gpg /etc/apt/sources.list.d/netdata.list
|
|
|
|
|
|
$STD apt-get remove --purge -y netdata netdata-repo
|
|
|
|
|
|
systemctl daemon-reload
|
|
|
|
|
|
$STD apt autoremove -y
|
2025-08-20 14:00:10 +02:00
|
|
|
|
$STD userdel netdata || true
|
2023-12-22 19:45:53 -05:00
|
|
|
|
msg_ok "Uninstalled Netdata"
|
2026-01-06 22:57:40 +01:00
|
|
|
|
msg_ok "Completed successfully!\n"
|
2023-12-19 19:49:20 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-20 14:00:10 +02:00
|
|
|
|
header_info
|
|
|
|
|
|
pve_check
|
2023-12-19 19:49:20 -05:00
|
|
|
|
|
2025-04-01 10:25:46 +02:00
|
|
|
|
OPTIONS=(Install "Install NetData on Proxmox VE"
|
|
|
|
|
|
Uninstall "Uninstall NetData from Proxmox VE")
|
2023-12-19 19:49:20 -05:00
|
|
|
|
|
2025-08-20 14:00:10 +02:00
|
|
|
|
CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "NetData" \
|
|
|
|
|
|
--menu "Select an option:" 10 58 2 "${OPTIONS[@]}" 3>&1 1>&2 2>&3)
|
2023-12-19 19:49:20 -05:00
|
|
|
|
|
|
|
|
|
|
case $CHOICE in
|
2025-08-20 14:00:10 +02:00
|
|
|
|
"Install") install ;;
|
|
|
|
|
|
"Uninstall") uninstall ;;
|
2025-04-01 10:25:46 +02:00
|
|
|
|
*)
|
|
|
|
|
|
echo "Exiting..."
|
|
|
|
|
|
exit 0
|
|
|
|
|
|
;;
|
2023-12-19 19:49:20 -05:00
|
|
|
|
esac
|