Refactor MOTD/SSH setup in build script

Simplifies MOTD and SSH setup by sourcing common install functions and conditionally running motd_ssh. Improves error handling and messaging for debugging access during container initialization.
This commit is contained in:
CanbiZ 2025-11-17 14:22:48 +01:00
parent 82439d30cd
commit e2179db113

View File

@ -2708,15 +2708,15 @@ EOF'
# This ensures the container is fully booted and accessible via SSH # This ensures the container is fully booted and accessible via SSH
if [[ "${DEV_MODE_MOTD:-false}" == "true" ]]; then if [[ "${DEV_MODE_MOTD:-false}" == "true" ]]; then
msg_dev "Setting up MOTD and SSH for debugging access" msg_dev "Setting up MOTD and SSH for debugging access"
pct exec "$CTID" -- bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/install/${var_install}.sh)" <<'MOTD_SETUP' # Load common install functions and run motd_ssh if available
# Only run motd_ssh function if it exists if pct exec "$CTID" -- bash -c "
if declare -f motd_ssh >/dev/null 2>&1; then source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/install.func)
motd_ssh declare -f motd_ssh >/dev/null 2>&1 && motd_ssh || true
else " >/dev/null 2>&1; then
msg_warn "motd_ssh function not found in ${var_install}.sh" msg_dev "MOTD/SSH ready - container accessible via SSH (IP: $ip_in_lxc)"
fi else
MOTD_SETUP msg_warn "MOTD/SSH setup failed, but continuing with installation"
msg_dev "MOTD/SSH ready - container accessible via SSH (IP: $ip_in_lxc)" fi
fi fi
# Run application installer # Run application installer