From 43a305ef9bce18d26b8cd430dc6352394a33f466 Mon Sep 17 00:00:00 2001 From: Christophe JEANNEROT Date: Sat, 21 Feb 2026 14:35:55 +0100 Subject: [PATCH] Actualiser debian12-fr.sh --- debian12-fr.sh | 74 ++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 57 insertions(+), 17 deletions(-) diff --git a/debian12-fr.sh b/debian12-fr.sh index 0b1c0dc..f6b1017 100644 --- a/debian12-fr.sh +++ b/debian12-fr.sh @@ -26,7 +26,9 @@ NSAPP="debian12vm" var_os="debian" var_version="12" -# ---- FR locale / keyboard (cloud-init) ---- +# ========================== +# FR locale / keyboard (cloud-init) - robust +# ========================== LOCALE="${LOCALE:-fr_FR.UTF-8}" KB_LAYOUT="${KB_LAYOUT:-fr}" # fr / be / us ... CONSOLE_KEYMAP="${CONSOLE_KEYMAP:-fr}" # fr / fr-latin9 ... @@ -223,9 +225,15 @@ function default_settings() { MAC="$GEN_MAC" VLAN="" MTU="" - START_VM="yes" - # ---- IMPORTANT: enable cloud-init by default to enforce FR keyboard/locale ---- + # ========================== + # Boot behavior (requested) + # - Do NOT start VM at end of script + # - Do NOT autostart on Proxmox reboot + # ========================== + START_VM="no" + + # Enable cloud-init by default to enforce FR locale/keyboard reliably CLOUD_INIT="yes" METHOD="default" @@ -242,7 +250,7 @@ function default_settings() { echo -e "${VLANTAG}${BOLD}${DGN}VLAN: ${BGN}Default${CL}" echo -e "${DEFAULT}${BOLD}${DGN}Interface MTU Size: ${BGN}Default${CL}" echo -e "${CLOUD}${BOLD}${DGN}Configure Cloud-init: ${BGN}yes${CL}" - echo -e "${GATEWAY}${BOLD}${DGN}Start VM when completed: ${BGN}yes${CL}" + echo -e "${GATEWAY}${BOLD}${DGN}Start VM when completed: ${BGN}no${CL}" echo -e "${CREATING}${BOLD}${DGN}Creating a Debian 12 VM using the above default settings${CL}" } @@ -367,7 +375,6 @@ function advanced_settings() { BRG="vmbr0" echo -e "${BRIDGE}${BOLD}${DGN}Bridge: ${BGN}$BRG${CL}" else - BRG="$BRG" echo -e "${BRIDGE}${BOLD}${DGN}Bridge: ${BGN}$BRG${CL}" fi else @@ -412,7 +419,7 @@ function advanced_settings() { exit-script fi - if (whiptail --backtitle "Proxmox VE Helper Scripts" --title "CLOUD-INIT" --yesno "Configure the VM with Cloud-init? (Required for FR keyboard/locale)" 10 66); then + if (whiptail --backtitle "Proxmox VE Helper Scripts" --title "CLOUD-INIT" --yesno "Configure the VM with Cloud-init? (Recommended for FR keyboard/locale)" 10 70); then echo -e "${CLOUD}${BOLD}${DGN}Configure Cloud-init: ${BGN}yes${CL}" CLOUD_INIT="yes" else @@ -420,7 +427,8 @@ function advanced_settings() { CLOUD_INIT="no" fi - if (whiptail --backtitle "Proxmox VE Helper Scripts" --title "START VIRTUAL MACHINE" --yesno "Start VM when completed?" 10 58); then + # Requested: do not start automatically => default is NO + if (whiptail --backtitle "Proxmox VE Helper Scripts" --title "START VIRTUAL MACHINE" --defaultno --yesno "Start VM when completed?" 10 58); then echo -e "${GATEWAY}${BOLD}${DGN}Start VM when completed: ${BGN}yes${CL}" START_VM="yes" else @@ -526,8 +534,14 @@ for i in {0,1}; do done msg_info "Creating a Debian 12 VM" + +# ========================== +# Boot behavior (requested) +# -onboot 0 => no autostart on Proxmox reboot +# ========================== qm create $VMID -agent 1${MACHINE} -tablet 0 -localtime 1 -bios ovmf${CPU_TYPE} -cores $CORE_COUNT -memory $RAM_SIZE \ - -name $HN -tags community-script -net0 virtio,bridge=$BRG,macaddr=$MAC$VLAN$MTU -onboot 1 -ostype l26 -scsihw virtio-scsi-pci + -name $HN -tags community-script -net0 virtio,bridge=$BRG,macaddr=$MAC$VLAN$MTU -onboot 0 -ostype l26 -scsihw virtio-scsi-pci + pvesm alloc $STORAGE $VMID $DISK0 4M 1>&/dev/null qm importdisk $VMID ${FILE} $STORAGE ${DISK_IMPORT:-} 1>&/dev/null @@ -539,37 +553,59 @@ if [ "$CLOUD_INIT" == "yes" ]; then -boot order=scsi0 \ -serial0 socket >/dev/null - # ---- Cloud-init: force FR locale + keyboard (AZERTY) ---- + # ========================== + # Cloud-init user-data (robust FR locale + keyboard) + # Requires storage "local" has snippets enabled + # ========================== SNIPPET_DIR="/var/lib/vz/snippets" mkdir -p "${SNIPPET_DIR}" USERDATA_FILE="${SNIPPET_DIR}/${VMID}-user-data.yaml" cat > "${USERDATA_FILE}" < /etc/default/keyboard - - printf "KEYMAP=\\"${CONSOLE_KEYMAP}\\"\\n" > /etc/default/console-setup + # keyboard (debconf + reconfigure) + - echo 'keyboard-configuration keyboard-configuration/layoutcode string ${KB_LAYOUT}' | debconf-set-selections + - echo 'keyboard-configuration keyboard-configuration/modelcode string pc105' | debconf-set-selections + - DEBIAN_FRONTEND=noninteractive dpkg-reconfigure keyboard-configuration || true + + # apply to console - setupcon -k || true + # systemd-localed (if present) - command -v localectl >/dev/null 2>&1 && localectl set-locale LANG=${LOCALE} || true - command -v localectl >/dev/null 2>&1 && localectl set-keymap ${CONSOLE_KEYMAP} || true EOF - # Attach user-data (requires: storage "local" has snippets enabled) qm set $VMID --cicustom "user=local:snippets/${VMID}-user-data.yaml" >/dev/null else @@ -620,10 +656,14 @@ else fi msg_ok "Created a Debian 12 VM ${CL}${BL}(${HN})" + +# Requested: VM should not start automatically => START_VM defaults to "no" if [ "$START_VM" == "yes" ]; then msg_info "Starting Debian 12 VM" qm start $VMID msg_ok "Started Debian 12 VM" +else + msg_ok "VM not started (as requested)." fi msg_ok "Completed successfully!\n"