Add msg_dev function for dev mode messaging

Introduces a new msg_dev function in core.func to standardize development/debugging messages. Updates build.func to use msg_dev for clearer dev mode output, replacing previous msg_custom and msg_info usages for MOTD/SSH setup and container debugging steps.
This commit is contained in:
CanbiZ 2025-11-17 14:22:22 +01:00
parent ee5dc898f9
commit 82439d30cd
2 changed files with 20 additions and 7 deletions

View File

@ -2704,9 +2704,10 @@ EOF'
# Install SSH keys # Install SSH keys
install_ssh_keys_into_ct install_ssh_keys_into_ct
# Dev mode: Setup MOTD/SSH before installation for debugging # Dev mode: Setup MOTD/SSH AFTER network is ready and before installation
# 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_info "[DEV] Setting up MOTD and SSH before installation" 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' pct exec "$CTID" -- bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/install/${var_install}.sh)" <<'MOTD_SETUP'
# Only run motd_ssh function if it exists # Only run motd_ssh function if it exists
if declare -f motd_ssh >/dev/null 2>&1; then if declare -f motd_ssh >/dev/null 2>&1; then
@ -2715,7 +2716,7 @@ EOF'
msg_warn "motd_ssh function not found in ${var_install}.sh" msg_warn "motd_ssh function not found in ${var_install}.sh"
fi fi
MOTD_SETUP MOTD_SETUP
msg_ok "[DEV] MOTD/SSH ready - container accessible" msg_dev "MOTD/SSH ready - container accessible via SSH (IP: $ip_in_lxc)"
fi fi
# Run application installer # Run application installer
@ -2776,10 +2777,10 @@ MOTD_SETUP
# Dev mode: Keep container or open breakpoint shell # Dev mode: Keep container or open breakpoint shell
if [[ "${DEV_MODE_KEEP:-false}" == "true" ]]; then if [[ "${DEV_MODE_KEEP:-false}" == "true" ]]; then
msg_custom "🔧" "${YWB}" "[DEV] Keep mode active - container ${CTID} preserved" msg_dev "Keep mode active - container ${CTID} preserved"
return 0 return 0
elif [[ "${DEV_MODE_BREAKPOINT:-false}" == "true" ]]; then elif [[ "${DEV_MODE_BREAKPOINT:-false}" == "true" ]]; then
msg_custom "🐛" "${RD}" "[DEV] Breakpoint mode - opening shell in container ${CTID}" msg_dev "Breakpoint mode - opening shell in container ${CTID}"
echo -e "${YW}Type 'exit' to return to host${CL}" echo -e "${YW}Type 'exit' to return to host${CL}"
pct enter "$CTID" pct enter "$CTID"
echo "" echo ""
@ -2789,7 +2790,7 @@ MOTD_SETUP
pct destroy "$CTID" &>/dev/null || true pct destroy "$CTID" &>/dev/null || true
msg_ok "Container ${CTID} removed" msg_ok "Container ${CTID} removed"
else else
msg_custom "🔧" "${YW}" "Container ${CTID} kept for debugging" msg_dev "Container ${CTID} kept for debugging"
fi fi
exit $install_exit_code exit $install_exit_code
fi fi

View File

@ -633,7 +633,19 @@ msg_debug() {
} }
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# fatal() # msg_dev()
#
# - Display development mode messages with 🔧 icon
# - Only shown when dev_mode is active
# - Useful for debugging and development-specific output
# - Format: [DEV] message with distinct formatting
# - Usage: msg_dev "Container ready for debugging"
# ------------------------------------------------------------------------------
msg_dev() {
if [[ -n "${dev_mode:-}" ]]; then
echo -e "${SEARCH}${BOLD}${DGN}🔧 [DEV]${CL} $*"
fi
}
# #
# - Displays error message and immediately terminates script # - Displays error message and immediately terminates script
# - Sends SIGINT to current process to trigger error handler # - Sends SIGINT to current process to trigger error handler