mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-03-06 19:05:56 +01:00
* 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
109 lines
3.4 KiB
Bash
109 lines
3.4 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
# Copyright (c) 2021-2026 tteck
|
|
# Author: tteck (tteckster)
|
|
# Co-Author: MickLesk (Canbiz)
|
|
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
|
# Source: https://netbird.io/ | Github: https://github.com/netbirdio/netbird
|
|
|
|
function header_info {
|
|
clear
|
|
cat <<"EOF"
|
|
_ __ __ ____ _ __
|
|
/ | / /__ / /_/ __ )(_)________/ /
|
|
/ |/ / _ \/ __/ __ / / ___/ __ /
|
|
/ /| / __/ /_/ /_/ / / / / /_/ /
|
|
/_/ |_/\___/\__/_____/_/_/ \__,_/
|
|
|
|
EOF
|
|
}
|
|
header_info
|
|
set -e
|
|
|
|
# Telemetry
|
|
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/api.func) 2>/dev/null || true
|
|
declare -f init_tool_telemetry &>/dev/null && init_tool_telemetry "add-netbird-lxc" "addon"
|
|
|
|
while true; do
|
|
read -p "This will add NetBird to an existing LXC Container ONLY. Proceed(y/n)?" yn
|
|
case $yn in
|
|
[Yy]*) break ;;
|
|
[Nn]*) exit ;;
|
|
*) echo "Please answer yes or no." ;;
|
|
esac
|
|
done
|
|
header_info
|
|
echo "Loading..."
|
|
|
|
function msg() {
|
|
local TEXT="$1"
|
|
echo -e "$TEXT"
|
|
}
|
|
|
|
NODE=$(hostname)
|
|
MSG_MAX_LENGTH=0
|
|
while read -r line; do
|
|
TAG=$(echo "$line" | awk '{print $1}')
|
|
ITEM=$(echo "$line" | awk '{print substr($0,36)}')
|
|
OFFSET=2
|
|
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
|
|
MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET))
|
|
fi
|
|
CTID_MENU+=("$TAG" "$ITEM " "OFF")
|
|
done < <(pct list | awk 'NR>1')
|
|
|
|
while [ -z "${CTID:+x}" ]; do
|
|
CTID=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "Containers on $NODE" --radiolist \
|
|
"\nSelect a container to add NetBird to:\n" \
|
|
16 $(($MSG_MAX_LENGTH + 23)) 6 \
|
|
"${CTID_MENU[@]}" 3>&1 1>&2 2>&3)
|
|
done
|
|
|
|
LXC_STATUS=$(pct status "$CTID" | awk '{print $2}')
|
|
if [[ "$LXC_STATUS" != "running" ]]; then
|
|
msg "\e[1;33m The container $CTID is not running. Starting it now...\e[0m"
|
|
pct start "$CTID"
|
|
while [[ "$(pct status "$CTID" | awk '{print $2}')" != "running" ]]; do
|
|
msg "\e[1;33m Waiting for the container to start...\e[0m"
|
|
sleep 2
|
|
done
|
|
msg "\e[1;32m Container $CTID is now running.\e[0m"
|
|
fi
|
|
|
|
DISTRO=$(pct exec "$CTID" -- cat /etc/os-release | grep -w "ID" | cut -d'=' -f2 | tr -d '"')
|
|
if [[ "$DISTRO" != "debian" && "$DISTRO" != "ubuntu" ]]; then
|
|
msg "\e[1;31m Error: This script only supports Debian or Ubuntu LXC containers. Detected: $DISTRO. Aborting...\e[0m"
|
|
exit 1
|
|
fi
|
|
|
|
CTID_CONFIG_PATH=/etc/pve/lxc/${CTID}.conf
|
|
cat <<EOF >>$CTID_CONFIG_PATH
|
|
lxc.cgroup2.devices.allow: c 10:200 rwm
|
|
lxc.mount.entry: /dev/net/tun dev/net/tun none bind,create=file
|
|
EOF
|
|
header_info
|
|
msg "Installing NetBird..."
|
|
pct exec "$CTID" -- bash -c '
|
|
if ! command -v curl &>/dev/null; then
|
|
apt-get update -qq
|
|
apt-get install -y curl >/dev/null
|
|
fi
|
|
apt install -y ca-certificates gpg &>/dev/null
|
|
curl -fsSL "https://pkgs.netbird.io/debian/public.key" | gpg --dearmor >/usr/share/keyrings/netbird-archive-keyring.gpg
|
|
echo "deb [signed-by=/usr/share/keyrings/netbird-archive-keyring.gpg] https://pkgs.netbird.io/debian stable main" >/etc/apt/sources.list.d/netbird.list
|
|
apt-get update &>/dev/null
|
|
apt-get install -y netbird-ui &>/dev/null
|
|
if systemctl list-unit-files docker.service &>/dev/null; then
|
|
mkdir -p /etc/systemd/system/netbird.service.d
|
|
cat <<OVERRIDE >/etc/systemd/system/netbird.service.d/after-docker.conf
|
|
[Unit]
|
|
After=docker.service
|
|
Wants=docker.service
|
|
OVERRIDE
|
|
systemctl daemon-reload
|
|
fi
|
|
'
|
|
msg "\e[1;32m ✔ Installed NetBird.\e[0m"
|
|
sleep 2
|
|
msg "\e[1;31m Reboot ${CTID} LXC to apply the changes, then run netbird up in the LXC console\e[0m"
|