mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-11-04 04:24:31 +01:00
add-tailscale-lxc: start a stopped container and check its OS first (#18421)
The container menu lists stopped containers too, and pct exec on one exits 255: 12 of 41 failures in three days. Start it the way add-netbird-lxc does and wait for its default route. The install runs under bash, which an Alpine container from the template does not have; lxc-attach then exits 127 before the Alpine branch is reached. Install bash there first, and stop with a clear message on any OS other than Debian, Ubuntu or Alpine instead of failing on apt-get.
This commit is contained in:
committed by
GitHub
parent
39b3ed29ad
commit
2fbb6e261c
@@ -65,6 +65,28 @@ while [[ -z "${CTID}" ]]; do
|
||||
"${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit 0
|
||||
done
|
||||
|
||||
if [[ "$(pct status "$CTID" | awk '{print $2}')" != "running" ]]; then
|
||||
msg_info "Starting CT $CTID"
|
||||
pct start "$CTID"
|
||||
for _ in {1..30}; do
|
||||
pct exec "$CTID" -- sh -c 'ip route 2>/dev/null | grep -q "^default"' && break
|
||||
sleep 1
|
||||
done
|
||||
msg_ok "Started CT $CTID"
|
||||
fi
|
||||
|
||||
CT_OS=$(pct exec "$CTID" -- sh -c '. /etc/os-release 2>/dev/null; echo "${ID:-}"')
|
||||
case "$CT_OS" in
|
||||
debian | ubuntu) ;;
|
||||
alpine)
|
||||
pct exec "$CTID" -- sh -c 'command -v bash >/dev/null 2>&1 || apk add --no-cache bash >/dev/null'
|
||||
;;
|
||||
*)
|
||||
msg_error "CT $CTID runs ${CT_OS:-an unknown OS}. This add-on supports Debian, Ubuntu and Alpine containers."
|
||||
exit 238
|
||||
;;
|
||||
esac
|
||||
|
||||
CTID_CONFIG_PATH="/etc/pve/lxc/${CTID}.conf"
|
||||
|
||||
# Skip if already configured
|
||||
|
||||
Reference in New Issue
Block a user