@@ -548,22 +548,32 @@ configure_static_ip() {
548
548
fi
549
549
fi
550
550
551
- # Get a list of available network devices
551
+ # Get a list of available network devices and their types
552
552
network_devices=($( ip -o link show | awk -F' : ' ' {print $2}' ) )
553
+ network_device_types=($( ip -o link show | awk -F' : ' ' {print $2" " $3}' ) )
554
+
555
+ # Filter devices to include only Ethernet and Wi-Fi
556
+ selected_devices=()
557
+ for (( i = 0 ; i < ${# network_devices[@]} ; i++ )) ; do
558
+ device_type=" ${network_device_types[i]} "
559
+ if [[ " $device_type " == " ether" || " $device_type " == " wlan" ]]; then
560
+ selected_devices+=(" ${network_devices[i]} " )
561
+ fi
562
+ done
553
563
554
564
# Check if there are multiple network devices and let the user choose
555
- if [ ${# network_devices [@]} -eq 1 ]; then
556
- selected_device=${network_devices [0]}
565
+ if [ ${# selected_devices [@]} -eq 1 ]; then
566
+ selected_device=${selected_devices [0]}
557
567
else
558
568
echo " Select the network device for the static IP configuration:"
559
- for (( i = 0 ; i < ${# network_devices [@]} ; i++ )) ; do
560
- echo " $i ) ${network_devices [i]} "
569
+ for (( i = 0 ; i < ${# selected_devices [@]} ; i++ )) ; do
570
+ echo " $i ) ${selected_devices [i]} "
561
571
done
562
572
read -rp " Enter the number corresponding to your choice: " device_choice
563
573
564
574
# Validate the user's choice
565
- if [[ " $device_choice " =~ ^[0-9]+$ ]] && [ " $device_choice " -ge 0 ] && [ " $device_choice " -lt ${# network_devices [@]} ]; then
566
- selected_device=${network_devices [device_choice]}
575
+ if [[ " $device_choice " =~ ^[0-9]+$ ]] && [ " $device_choice " -ge 0 ] && [ " $device_choice " -lt ${# selected_devices [@]} ]; then
576
+ selected_device=${selected_devices [device_choice]}
567
577
else
568
578
echo " Invalid choice. Aborting static IP configuration."
569
579
return
0 commit comments