diff --git a/recipes-core/initrdscripts/initramfs-module-install-efi_%.%.bbappend b/recipes-core/initrdscripts/initramfs-module-install-efi_%.%.bbappend index e75ba063a15742fd0402eeed9b46f2ebdb7ad8b7..bb3814cb12245713ce6fc7c0517847c4a8927d72 100644 --- a/recipes-core/initrdscripts/initramfs-module-install-efi_%.%.bbappend +++ b/recipes-core/initrdscripts/initramfs-module-install-efi_%.%.bbappend @@ -2,6 +2,10 @@ FILESEXTRAPATHS:prepend := "${THISDIR}/module-install-efi:${THISDIR}/autounatten RDEPENDS:${PN} += " \ qemu \ + ethtool \ + iproute2 \ + kernel-module-igb \ + kernel-module-igc \ kernel-module-kvm \ kernel-module-kvm-intel \ kernel-module-kvm-amd \ diff --git a/recipes-core/initrdscripts/module-install-efi/init-install-efi-sinsegye.sh b/recipes-core/initrdscripts/module-install-efi/init-install-efi-sinsegye.sh index 2f5fbba23c80923676644dd8a6ef27b1eac4105f..74ca3ad92e758ba42d24667f9a7b53e6af852cf4 100644 --- a/recipes-core/initrdscripts/module-install-efi/init-install-efi-sinsegye.sh +++ b/recipes-core/initrdscripts/module-install-efi/init-install-efi-sinsegye.sh @@ -11,6 +11,10 @@ # 2. Provides an option to install a Windows virtual machine using QEMU after the system installation. # +trap 'flash_fail' EXIT + +trap 'flash_fail' INT + # Set PATH PATH=/sbin:/bin:/usr/sbin:/usr/bin @@ -49,6 +53,100 @@ rescuezillafs="" rootfs="" swap="" +################################################## +# LED Control Functions (using ethtool --identify) +################################################## + +blink_pid="" + +get_phy_nics() { + ip link show | \ + awk -F': ' '/^[0-9]+: enp/ && $2 !~ /u/ { print $2 }' | \ + sort -V +} + +# Continuously blink a specific network card (loop calling ethtool --identify every 1 second), simulating "continuous blinking" +blink_nic_forever() { + local iface="$1" + + set +e + trap '' ERR + + while :; do + ethtool --identify "$iface" 1 &>/dev/null + done + set -e + trap - ERR +} + +# Make multiple network interfaces flash sequentially for 1 second, simulating a "running horse lamp". +run_marquee() { + local nics=("$@") + + set +e + trap '' ERR + + for iface in "${nics[@]}"; do + ethtool --identify "$iface" 1 &>/dev/null + done +} + +# Stop a certain background blink task +stop_blink() { + local pid="$1" + if [ -n "$pid" ] && kill -0 "$pid" 2>/dev/null; then + kill "$pid" 2>/dev/null || true + wait "$pid" 2>/dev/null || true + fi +} + +# ----------------------------------------------------- +# Start writing -> Line1 (assuming enp1s0) is continuously blinking +# ----------------------------------------------------- +start_flashing() { + echo "System flashing process LED blinking" + local nic_first + nic_first=$(get_phy_nics | head -n 1) + + if [ -z "$nic_first" ]; then + echo "Error: No physical network interfaces detected." + return 1 + fi + + blink_nic_forever "$nic_first" & + blink_pid="$!" +} + +# ----------------------------------------------------- +# Flashing successful -> Marquee +# ----------------------------------------------------- +flash_success() { + stop_blink "$blink_pid" + + nics=($(get_phy_nics)) + if [ ${#nics[@]} -eq 0 ]; then + echo "No physical network interfaces found." + return 1 + fi + + while :; do + run_marquee "${nics[@]}" + done +} + +# ----------------------------------------------------- +# Failed to flash -> Do not use ethtool, use hardware default (wired on, wireless off) +# ----------------------------------------------------- +flash_fail() { + echo "#############################################################" + echo "### ###" + echo "### FLASH FAILED! ###" + echo "### ###" + echo "#############################################################" + stop_blink "$blink_pid" + exit 1 +} + ######################## # Function Definitions # ######################## @@ -108,7 +206,7 @@ detect_disks() { if [ -z "${hdnamelist}" ]; then echo "No available hard drives found for installation." - exit 1 + flash_fail fi } @@ -152,7 +250,7 @@ select_install_target() { device=/dev/${TARGET_DEVICE_NAME} else echo "No hard drive selected. Installation aborted." - exit 1 + flash_fail fi } @@ -332,7 +430,7 @@ reset_disk() { # Check if VM_DISK exists if [ ! -b "$vm_disk" ]; then echo "Error: Disk $vm_disk does not exist." - exit 1 + flash_fail fi # Unmount all partitions of the disk @@ -394,6 +492,9 @@ install_virtual_machine() { # Main Script Execution # ######################### +# 杩涘叆鈥滅郴缁熸鍦ㄥ埛鍐欌€濋樁娈� => 鍚姩缃戝崱鐏寔缁棯鐑� +start_flashing + # Ensure automounter is disabled rm -f /etc/udev/rules.d/automount.rules rm -f /etc/udev/scripts/mount* @@ -425,6 +526,8 @@ umount /tgt_root # Sync filesystem changes sync +flash_success + echo "Installation successful. Remove your installation media and press ENTER to reboot." read enter