Patch Netbird Script | Container Boot-Check | Debian/Ubuntu Only (#528)

* Update Add-Netbird

- Container Online-Check (Boot if LXC stopped)
- Alpine Check -> Abort if not Debian/Ubuntu

* Improve Netbird Json for website

* remove dev comments

* Change copyright
This commit is contained in:
CanbiZ 2024-11-27 15:54:44 +01:00 committed by GitHub
parent 9d72b5872a
commit 928a5cb9e5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 29 additions and 6 deletions

View File

@ -33,11 +33,15 @@
"notes": [
{
"text": "After the script finishes, reboot the LXC then run `netbird up` in the LXC console",
"type": "warning"
"type": "info"
},
{
"text": "Execute within the Proxmox shell",
"text": "Execute within the Proxmox main shell",
"type": "info"
}
{
"text": "The script only works in Debian/Ubuntu, not in Alpine!",
"type": "warning"
}
]
}
}

View File

@ -2,6 +2,7 @@
# Copyright (c) 2021-2024 tteck
# Author: tteck (tteckster)
# Co-Author: MickLesk (Canbiz)
# License: MIT
# https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
@ -10,9 +11,9 @@ clear
cat <<"EOF"
_ __ __ ____ _ __
/ | / /__ / /_/ __ )(_)________/ /
/ |/ / _ \/ __/ __ / / ___/ __ /
/ /| / __/ /_/ /_/ / / / / /_/ /
/_/ |_/\___/\__/_____/_/_/ \__,_/
/ |/ / _ \/ __/ __ / / ___/ __ /
/ /| / __/ /_/ /_/ / / / / /_/ /
/_/ |_/\___/\__/_____/_/_/ \__,_/
EOF
}
@ -28,6 +29,7 @@ while true; do
done
header_info
echo "Loading..."
function msg() {
local TEXT="$1"
echo -e "$TEXT"
@ -52,6 +54,23 @@ while [ -z "${CTID:+x}" ]; do
"${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit
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