Repository: fedora-arm/arm-image-installer
Pull request #1: adding wifi config
Author: login: say-paul
Created: 2025-03-04T15:17:25Z | Merged: 2025-03-12T19:39:31Z

Add wifi config for convenience.


Diff:
diff --git a/README b/README
index 5f5bf14..156f9f7 100644
--- a/README
+++ b/README
@@ -12,6 +12,7 @@ ARM disk image for use with various hardware targets.
  - Turn SE Linux on and off
  - Remove the root password
  - Update U-Boot for a Target
+ - Setup wifi connection, security options supported are `wpa-psk`(default) for WPA2(mostly used) and `sae` for WPA3.
  
 Note that the list of supported devices is a list of devices that arm-image-installer
 supports setting up the early boot firmware, it does not indicate the level of
@@ -36,6 +37,9 @@ Optional
 	--showboot	- Show boot messages, removes 'rhgb quiet' from kargs
 	--sysrq         - Enable System Request debugging of the kernel
 	--target=TARGET - target board for uboot
+	--wifi-ssid=SSID        - Wi-Fi SSID to configure
+	--wifi-pass=PASS        - Wi-Fi password to configure
+	--wifi-security=TYPE    - Wi-Fi security type (wpa-psk, sae)
 	-y              - Assumes yes, will not wait for confirmation
 Help
 	--supported     - List of hardware we support writing out boot firmware
diff --git a/arm-image-installer b/arm-image-installer
index d2c00c5..3af65dc 100755
--- a/arm-image-installer
+++ b/arm-image-installer
@@ -24,12 +24,15 @@ Optional
 	--showboot	- Show boot messages, removes 'rhgb quiet' from kargs
 	--sysrq         - Enable System Request debugging of the kernel
 	--target=TARGET - target board for uboot
+	--wifi-ssid=SSID        - Wi-Fi SSID to configure
+	--wifi-pass=PASS        - Wi-Fi password to configure
+	--wifi-security=TYPE    - Wi-Fi security type (wpa-psk, sae)
 	-y              - Assumes yes, will not wait for confirmation
 Help
 	--supported     - List of hardware we support writing out boot firmware
 	--version       - Display version and exit
 
-Example: $(basename ${0}) --image=Fedora-Rawhide.xz --target=pine64_plus --media=/dev/mmcblk0
+Example: $(basename ${0}) --image=Fedora-Rawhide.xz --target=pine64_plus --media=/dev/mmcblk0 --wifi-ssid=MY_SSID --wifi-pass=MY_PASSWORD
 
 "
 }
@@ -134,6 +137,48 @@ while [ $# -gt 0 ]; do
 				exit 1
 			fi
 			;;
+		--wifi-ssid*)
+            if echo $1 | grep '=' >/dev/null ; then
+                WIFI_SSID=$(echo $1 | sed 's/^--wifi-ssid=//')
+            elif [ -n "$2" ]; then
+                WIFI_SSID=$2
+                shift
+            else
+                echo "$(basename ${0}): Error - '--wifi-ssid' expects an argument"
+                usage
+                exit 1
+            fi
+            ;;
+        --wifi-pass*)
+            if echo $1 | grep '=' >/dev/null ; then
+                WIFI_PASS=$(echo $1 | sed 's/^--wifi-pass=//')
+            elif [ -n "$2" ]; then
+                WIFI_PASS=$2
+                shift
+            else
+                echo "$(basename ${0}): Error - '--wifi-pass' expects an argument"
+                usage
+                exit 1
+            fi
+            ;;
+        --wifi-security*)
+            if echo $1 | grep '=' >/dev/null ; then
+                WIFI_SECURITY=$(echo $1 | sed 's/^--wifi-security=//')
+            elif [ -n "$2" ]; then
+                WIFI_SECURITY=$2
+                shift
+            else
+                echo "$(basename ${0}): Error - '--wifi-security' expects an argument"
+                usage
+                exit 1
+            fi
+            # Validate the security type
+            if [[ "$WIFI_SECURITY" != "wpa-psk" && "$WIFI_SECURITY" != "sae" ]]; then
+                echo "$(basename ${0}): Error - Invalid Wi-Fi security type: $WIFI_SECURITY"
+                usage
+                exit 1
+            fi
+            ;;
 		--norootpass)
 			NOROOTPASS=1
 			;;
@@ -296,6 +341,10 @@ if [ "$CONSOLE" != "" ]; then
 		echo "= Console for $TARGET will be added."
 	fi
 fi
+# wifi ssid to be added
+if [ "$WIFI_SSID" != "" ]; then
+	echo "= Wifi ssid: $WIFI_SSID will autoconnect on boot."
+fi
 # User ssh key
 if [ "$SSH_KEY" != "" ]; then
 	echo "= SSH Public Key $SSH_KEY will be added."
@@ -607,6 +656,44 @@ if [ "$SSH_KEY" != "" ]; then
 	fi
 fi
 
+# Configure Wi-Fi if SSID is provided
+if [ "$WIFI_SSID" != "" ]; then
+    echo "= Configuring Wi-Fi: $WIFI_SSID"
+    # Use the SSID as the filename (replace spaces and special characters with underscores)
+    FILENAME=$(echo "$WIFI_SSID" | tr ' ' '_' | tr -cd '[:alnum:]._-').nmconnection
+    cat > ${PREFIX}/etc/NetworkManager/system-connections/$FILENAME <<-EOF
+[connection]
+id=${WIFI_SSID}
+type=wifi
+
+[wifi]
+mode=infrastructure
+ssid=${WIFI_SSID}
+EOF
+
+    # Add security configuration if a password is provided
+    if [ -n "$WIFI_PASS" ]; then
+        cat >> ${PREFIX}/etc/NetworkManager/system-connections/$FILENAME <<-EOF
+[wifi-security]
+key-mgmt=${WIFI_SECURITY:-wpa-psk}
+psk=${WIFI_PASS}
+EOF
+    fi
+
+    # Add common IPv4 and IPv6 settings
+    cat >> ${PREFIX}/etc/NetworkManager/system-connections/$FILENAME <<-EOF
+[ipv4]
+method=auto
+
+[ipv6]
+method=auto
+addr-gen-mode=default
+EOF
+
+    # Set file permissions
+    chmod 600 ${PREFIX}/etc/NetworkManager/system-connections/$FILENAME
+fi
+
 # Add console
 if [ "$CONSOLE" = "1" ]; then
 	if [ "$SYSCON" = "" ]; then


Reviews:
user: login: nullr0ute
body: One of the reasons we've never done any network configuration is because it's hard to get it right, other things I've not seen addressed here are UUID and mac addresses.
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-04T15:51:55Z
user: login: say-paul
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-05T16:04:18Z
user: login: say-paul
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-05T16:13:00Z
user: login: say-paul
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-05T16:13:15Z
user: login: say-paul
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-05T16:13:45Z
user: login: nullr0ute
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-05T16:26:10Z
user: login: nullr0ute
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-05T16:26:45Z
user: login: say-paul
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-05T16:31:20Z
user: login: nullr0ute
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-05T16:39:21Z
user: login: nullr0ute
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-11T13:11:15Z
user: login: nullr0ute
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-11T13:16:08Z
user: login: say-paul
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-12T14:54:14Z
user: login: say-paul
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-12T14:54:37Z
user: login: nullr0ute
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-12T17:37:15Z
user: login: say-paul
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-12T19:29:57Z
user: login: pcdubs
body: LGTM
state: APPROVED
author_association: COLLABORATOR
submitted_at: 2025-03-12T19:34:39Z
user: login: nullr0ute
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-03-12T19:39:19Z

Review comments:
diff_hunk: @@ -606,6 +632,34 @@ if [ "$SSH_KEY" != "" ]; then
 		echo "= WARNING: No SSH Key Added."
 	fi
 fi
+# Configure Wi-Fi if SSID and password are provided
+if [ "$WIFI_SSID" != "" ] && [ "$WIFI_PASS" != "" ]; then
+    echo "= Configuring Wi-Fi: $WIFI_SSID"
+    mkdir -p ${PREFIX}/etc/NetworkManager/system-connections/
path: arm-image-installer
user: login: nullr0ute
body: Why are we making this directory? It's already owned by NetworkManager
created_at: 2025-03-04T15:42:27Z
author_association: CONTRIBUTOR
diff_hunk: @@ -606,6 +632,34 @@ if [ "$SSH_KEY" != "" ]; then
 		echo "= WARNING: No SSH Key Added."
 	fi
 fi
+# Configure Wi-Fi if SSID and password are provided
+if [ "$WIFI_SSID" != "" ] && [ "$WIFI_PASS" != "" ]; then
+    echo "= Configuring Wi-Fi: $WIFI_SSID"
+    mkdir -p ${PREFIX}/etc/NetworkManager/system-connections/
+    # Use the SSID as the filename (replace spaces and special characters with underscores)
+    FILENAME=$(echo "$WIFI_SSID" | tr ' ' '_' | tr -cd '[:alnum:]._-').nmconnection
+    cat > ${PREFIX}/etc/NetworkManager/system-connections/$FILENAME <<-EOF
+[connection]
+id=$WIFI_SSID
+type=wifi
+interface-name=wlan0
path: arm-image-installer
user: login: nullr0ute
body: We can't assume that is the case. In different systems I have wlP6p1s0, wlan0, wlp1s0, wlp4s0, wlu1 and others. 
created_at: 2025-03-04T15:46:32Z
author_association: CONTRIBUTOR
diff_hunk: @@ -606,6 +632,34 @@ if [ "$SSH_KEY" != "" ]; then
 		echo "= WARNING: No SSH Key Added."
 	fi
 fi
+# Configure Wi-Fi if SSID and password are provided
+if [ "$WIFI_SSID" != "" ] && [ "$WIFI_PASS" != "" ]; then
+    echo "= Configuring Wi-Fi: $WIFI_SSID"
+    mkdir -p ${PREFIX}/etc/NetworkManager/system-connections/
+    # Use the SSID as the filename (replace spaces and special characters with underscores)
+    FILENAME=$(echo "$WIFI_SSID" | tr ' ' '_' | tr -cd '[:alnum:]._-').nmconnection
+    cat > ${PREFIX}/etc/NetworkManager/system-connections/$FILENAME <<-EOF
+[connection]
+id=$WIFI_SSID
+type=wifi
+interface-name=wlan0
+
+[wifi]
+mode=infrastructure
+ssid=$WIFI_SSID
+
+[wifi-security]
+key-mgmt=wpa-psk
path: arm-image-installer
user: login: nullr0ute
body: We can't assume that, it depends on the AP and with WPA3 it's possibly sae
created_at: 2025-03-04T15:47:45Z
author_association: CONTRIBUTOR
diff_hunk: @@ -606,6 +632,34 @@ if [ "$SSH_KEY" != "" ]; then
 		echo "= WARNING: No SSH Key Added."
 	fi
 fi
+# Configure Wi-Fi if SSID and password are provided
+if [ "$WIFI_SSID" != "" ] && [ "$WIFI_PASS" != "" ]; then
+    echo "= Configuring Wi-Fi: $WIFI_SSID"
+    mkdir -p ${PREFIX}/etc/NetworkManager/system-connections/
+    # Use the SSID as the filename (replace spaces and special characters with underscores)
+    FILENAME=$(echo "$WIFI_SSID" | tr ' ' '_' | tr -cd '[:alnum:]._-').nmconnection
+    cat > ${PREFIX}/etc/NetworkManager/system-connections/$FILENAME <<-EOF
+[connection]
+id=$WIFI_SSID
+type=wifi
+interface-name=wlan0
+
+[wifi]
+mode=infrastructure
+ssid=$WIFI_SSID
+
+[wifi-security]
+key-mgmt=wpa-psk
+psk=$WIFI_PASS
+
+[ipv4]
+method=auto
+
+[ipv6]
+method=auto
path: arm-image-installer
user: login: nullr0ute
body: Looking through my configs this usually, but not always has addr-gen-mode=default
created_at: 2025-03-04T15:49:50Z
author_association: CONTRIBUTOR
diff_hunk: @@ -606,6 +632,34 @@ if [ "$SSH_KEY" != "" ]; then
 		echo "= WARNING: No SSH Key Added."
 	fi
 fi
+# Configure Wi-Fi if SSID and password are provided
+if [ "$WIFI_SSID" != "" ] && [ "$WIFI_PASS" != "" ]; then
+    echo "= Configuring Wi-Fi: $WIFI_SSID"
+    mkdir -p ${PREFIX}/etc/NetworkManager/system-connections/
+    # Use the SSID as the filename (replace spaces and special characters with underscores)
+    FILENAME=$(echo "$WIFI_SSID" | tr ' ' '_' | tr -cd '[:alnum:]._-').nmconnection
+    cat > ${PREFIX}/etc/NetworkManager/system-connections/$FILENAME <<-EOF
+[connection]
+id=$WIFI_SSID
+type=wifi
+interface-name=wlan0
path: arm-image-installer
user: login: say-paul
body: removed the parameter, let networkmanager handle it.
created_at: 2025-03-05T16:04:18Z
author_association: CONTRIBUTOR
diff_hunk: @@ -606,6 +632,34 @@ if [ "$SSH_KEY" != "" ]; then
 		echo "= WARNING: No SSH Key Added."
 	fi
 fi
+# Configure Wi-Fi if SSID and password are provided
+if [ "$WIFI_SSID" != "" ] && [ "$WIFI_PASS" != "" ]; then
+    echo "= Configuring Wi-Fi: $WIFI_SSID"
+    mkdir -p ${PREFIX}/etc/NetworkManager/system-connections/
+    # Use the SSID as the filename (replace spaces and special characters with underscores)
+    FILENAME=$(echo "$WIFI_SSID" | tr ' ' '_' | tr -cd '[:alnum:]._-').nmconnection
+    cat > ${PREFIX}/etc/NetworkManager/system-connections/$FILENAME <<-EOF
+[connection]
+id=$WIFI_SSID
+type=wifi
+interface-name=wlan0
+
+[wifi]
+mode=infrastructure
+ssid=$WIFI_SSID
+
+[wifi-security]
+key-mgmt=wpa-psk
path: arm-image-installer
user: login: say-paul
body: Thanks for the feed back , I parameterized it for open,wap2 and wpa3.
Did more research and found out that there enterprise grade key management like: wpa-eap or wpa-eap-suite-b-192, which I intentionally left that out  to keep it simple and avoiding additional flags in the installer. My intention is primarily provide hobbyist with simple network setup similar to raspberry pi imager. 
created_at: 2025-03-05T16:12:59Z
author_association: CONTRIBUTOR
diff_hunk: @@ -606,6 +632,34 @@ if [ "$SSH_KEY" != "" ]; then
 		echo "= WARNING: No SSH Key Added."
 	fi
 fi
+# Configure Wi-Fi if SSID and password are provided
+if [ "$WIFI_SSID" != "" ] && [ "$WIFI_PASS" != "" ]; then
+    echo "= Configuring Wi-Fi: $WIFI_SSID"
+    mkdir -p ${PREFIX}/etc/NetworkManager/system-connections/
+    # Use the SSID as the filename (replace spaces and special characters with underscores)
+    FILENAME=$(echo "$WIFI_SSID" | tr ' ' '_' | tr -cd '[:alnum:]._-').nmconnection
+    cat > ${PREFIX}/etc/NetworkManager/system-connections/$FILENAME <<-EOF
+[connection]
+id=$WIFI_SSID
+type=wifi
+interface-name=wlan0
+
+[wifi]
+mode=infrastructure
+ssid=$WIFI_SSID
+
+[wifi-security]
+key-mgmt=wpa-psk
+psk=$WIFI_PASS
+
+[ipv4]
+method=auto
+
+[ipv6]
+method=auto
path: arm-image-installer
user: login: say-paul
body: added....
created_at: 2025-03-05T16:13:15Z
author_association: CONTRIBUTOR
diff_hunk: @@ -606,6 +632,34 @@ if [ "$SSH_KEY" != "" ]; then
 		echo "= WARNING: No SSH Key Added."
 	fi
 fi
+# Configure Wi-Fi if SSID and password are provided
+if [ "$WIFI_SSID" != "" ] && [ "$WIFI_PASS" != "" ]; then
+    echo "= Configuring Wi-Fi: $WIFI_SSID"
+    mkdir -p ${PREFIX}/etc/NetworkManager/system-connections/
path: arm-image-installer
user: login: say-paul
body: Thanks for point out the redundant step.. removed it.
created_at: 2025-03-05T16:13:45Z
author_association: CONTRIBUTOR
diff_hunk: @@ -606,6 +632,34 @@ if [ "$SSH_KEY" != "" ]; then
 		echo "= WARNING: No SSH Key Added."
 	fi
 fi
+# Configure Wi-Fi if SSID and password are provided
+if [ "$WIFI_SSID" != "" ] && [ "$WIFI_PASS" != "" ]; then
+    echo "= Configuring Wi-Fi: $WIFI_SSID"
+    mkdir -p ${PREFIX}/etc/NetworkManager/system-connections/
+    # Use the SSID as the filename (replace spaces and special characters with underscores)
+    FILENAME=$(echo "$WIFI_SSID" | tr ' ' '_' | tr -cd '[:alnum:]._-').nmconnection
+    cat > ${PREFIX}/etc/NetworkManager/system-connections/$FILENAME <<-EOF
+[connection]
+id=$WIFI_SSID
+type=wifi
+interface-name=wlan0
+
+[wifi]
+mode=infrastructure
+ssid=$WIFI_SSID
+
+[wifi-security]
+key-mgmt=wpa-psk
path: arm-image-installer
user: login: nullr0ute
body: Yes, enterprise is complex, and at times you need to deal with 2FA or even client side certs. Maybe add a note in the help or in the README
created_at: 2025-03-05T16:26:10Z
author_association: CONTRIBUTOR
diff_hunk: @@ -606,6 +632,34 @@ if [ "$SSH_KEY" != "" ]; then
 		echo "= WARNING: No SSH Key Added."
 	fi
 fi
+# Configure Wi-Fi if SSID and password are provided
+if [ "$WIFI_SSID" != "" ] && [ "$WIFI_PASS" != "" ]; then
+    echo "= Configuring Wi-Fi: $WIFI_SSID"
+    mkdir -p ${PREFIX}/etc/NetworkManager/system-connections/
+    # Use the SSID as the filename (replace spaces and special characters with underscores)
+    FILENAME=$(echo "$WIFI_SSID" | tr ' ' '_' | tr -cd '[:alnum:]._-').nmconnection
+    cat > ${PREFIX}/etc/NetworkManager/system-connections/$FILENAME <<-EOF
+[connection]
+id=$WIFI_SSID
+type=wifi
+interface-name=wlan0
path: arm-image-installer
user: login: nullr0ute
body: Does it work without the parameter though? 
created_at: 2025-03-05T16:26:45Z
author_association: CONTRIBUTOR
diff_hunk: @@ -606,6 +632,34 @@ if [ "$SSH_KEY" != "" ]; then
 		echo "= WARNING: No SSH Key Added."
 	fi
 fi
+# Configure Wi-Fi if SSID and password are provided
+if [ "$WIFI_SSID" != "" ] && [ "$WIFI_PASS" != "" ]; then
+    echo "= Configuring Wi-Fi: $WIFI_SSID"
+    mkdir -p ${PREFIX}/etc/NetworkManager/system-connections/
+    # Use the SSID as the filename (replace spaces and special characters with underscores)
+    FILENAME=$(echo "$WIFI_SSID" | tr ' ' '_' | tr -cd '[:alnum:]._-').nmconnection
+    cat > ${PREFIX}/etc/NetworkManager/system-connections/$FILENAME <<-EOF
+[connection]
+id=$WIFI_SSID
+type=wifi
+interface-name=wlan0
path: arm-image-installer
user: login: say-paul
body: Tested on rpi02W with f41, Worked.
created_at: 2025-03-05T16:31:20Z
author_association: CONTRIBUTOR
diff_hunk: @@ -606,6 +632,34 @@ if [ "$SSH_KEY" != "" ]; then
 		echo "= WARNING: No SSH Key Added."
 	fi
 fi
+# Configure Wi-Fi if SSID and password are provided
+if [ "$WIFI_SSID" != "" ] && [ "$WIFI_PASS" != "" ]; then
+    echo "= Configuring Wi-Fi: $WIFI_SSID"
+    mkdir -p ${PREFIX}/etc/NetworkManager/system-connections/
+    # Use the SSID as the filename (replace spaces and special characters with underscores)
+    FILENAME=$(echo "$WIFI_SSID" | tr ' ' '_' | tr -cd '[:alnum:]._-').nmconnection
+    cat > ${PREFIX}/etc/NetworkManager/system-connections/$FILENAME <<-EOF
+[connection]
+id=$WIFI_SSID
+type=wifi
+interface-name=wlan0
path: arm-image-installer
user: login: nullr0ute
body: OK, I've never added wifi because I suspect it'll cause more problems than it fixes, but let's see
created_at: 2025-03-05T16:39:21Z
author_association: CONTRIBUTOR
diff_hunk: @@ -12,6 +12,7 @@ ARM disk image for use with various hardware targets.
  - Turn SE Linux on and off
  - Remove the root password
  - Update U-Boot for a Target
+ - Setup wifi connection
path: README
user: login: nullr0ute
body: Can we add a little more here around wpa-psk and sae options. Most won't know that sae is WPA3 for example.
created_at: 2025-03-11T13:11:15Z
author_association: CONTRIBUTOR
diff_hunk: @@ -632,32 +659,43 @@ if [ "$SSH_KEY" != "" ]; then
 		echo "= WARNING: No SSH Key Added."
 	fi
 fi
-# Configure Wi-Fi if SSID and password are provided
-if [ "$WIFI_SSID" != "" ] && [ "$WIFI_PASS" != "" ]; then
+
+# Configure Wi-Fi if SSID is provided
+if [ "$WIFI_SSID" != "" ]; then
     echo "= Configuring Wi-Fi: $WIFI_SSID"
-    mkdir -p ${PREFIX}/etc/NetworkManager/system-connections/
     # Use the SSID as the filename (replace spaces and special characters with underscores)
     FILENAME=$(echo "$WIFI_SSID" | tr ' ' '_' | tr -cd '[:alnum:]._-').nmconnection
     cat > ${PREFIX}/etc/NetworkManager/system-connections/$FILENAME <<-EOF
 [connection]
-id=$WIFI_SSID
+id=${WIFI_SSID}
 type=wifi
-interface-name=wlan0
 
 [wifi]
 mode=infrastructure
-ssid=$WIFI_SSID
+ssid=${WIFI_SSID}
+hidden=${WIFI_HIDDEN:-false}
path: arm-image-installer
user: login: nullr0ute
body: This shouldn't be here at all if it's not hidden, if we've not tested this let's do it in a follow up patch to keep the initial support simple
created_at: 2025-03-11T13:16:07Z
author_association: CONTRIBUTOR
diff_hunk: @@ -632,32 +659,43 @@ if [ "$SSH_KEY" != "" ]; then
 		echo "= WARNING: No SSH Key Added."
 	fi
 fi
-# Configure Wi-Fi if SSID and password are provided
-if [ "$WIFI_SSID" != "" ] && [ "$WIFI_PASS" != "" ]; then
+
+# Configure Wi-Fi if SSID is provided
+if [ "$WIFI_SSID" != "" ]; then
     echo "= Configuring Wi-Fi: $WIFI_SSID"
-    mkdir -p ${PREFIX}/etc/NetworkManager/system-connections/
     # Use the SSID as the filename (replace spaces and special characters with underscores)
     FILENAME=$(echo "$WIFI_SSID" | tr ' ' '_' | tr -cd '[:alnum:]._-').nmconnection
     cat > ${PREFIX}/etc/NetworkManager/system-connections/$FILENAME <<-EOF
 [connection]
-id=$WIFI_SSID
+id=${WIFI_SSID}
 type=wifi
-interface-name=wlan0
 
 [wifi]
 mode=infrastructure
-ssid=$WIFI_SSID
+ssid=${WIFI_SSID}
+hidden=${WIFI_HIDDEN:-false}
path: arm-image-installer
user: login: say-paul
body: removed..
created_at: 2025-03-12T14:54:14Z
author_association: CONTRIBUTOR
diff_hunk: @@ -12,6 +12,7 @@ ARM disk image for use with various hardware targets.
  - Turn SE Linux on and off
  - Remove the root password
  - Update U-Boot for a Target
+ - Setup wifi connection
path: README
user: login: say-paul
body: added details for easier undertsanding
created_at: 2025-03-12T14:54:37Z
author_association: CONTRIBUTOR
diff_hunk: @@ -632,32 +659,43 @@ if [ "$SSH_KEY" != "" ]; then
 		echo "= WARNING: No SSH Key Added."
 	fi
 fi
-# Configure Wi-Fi if SSID and password are provided
-if [ "$WIFI_SSID" != "" ] && [ "$WIFI_PASS" != "" ]; then
+
+# Configure Wi-Fi if SSID is provided
+if [ "$WIFI_SSID" != "" ]; then
     echo "= Configuring Wi-Fi: $WIFI_SSID"
-    mkdir -p ${PREFIX}/etc/NetworkManager/system-connections/
     # Use the SSID as the filename (replace spaces and special characters with underscores)
     FILENAME=$(echo "$WIFI_SSID" | tr ' ' '_' | tr -cd '[:alnum:]._-').nmconnection
     cat > ${PREFIX}/etc/NetworkManager/system-connections/$FILENAME <<-EOF
 [connection]
-id=$WIFI_SSID
+id=${WIFI_SSID}
 type=wifi
-interface-name=wlan0
 
 [wifi]
 mode=infrastructure
-ssid=$WIFI_SSID
+ssid=${WIFI_SSID}
+hidden=${WIFI_HIDDEN:-false}
path: arm-image-installer
user: login: nullr0ute
body: You need to remove the line from the help as well.  Otherwise this is ready 
created_at: 2025-03-12T17:37:15Z
author_association: CONTRIBUTOR
diff_hunk: @@ -632,32 +659,43 @@ if [ "$SSH_KEY" != "" ]; then
 		echo "= WARNING: No SSH Key Added."
 	fi
 fi
-# Configure Wi-Fi if SSID and password are provided
-if [ "$WIFI_SSID" != "" ] && [ "$WIFI_PASS" != "" ]; then
+
+# Configure Wi-Fi if SSID is provided
+if [ "$WIFI_SSID" != "" ]; then
     echo "= Configuring Wi-Fi: $WIFI_SSID"
-    mkdir -p ${PREFIX}/etc/NetworkManager/system-connections/
     # Use the SSID as the filename (replace spaces and special characters with underscores)
     FILENAME=$(echo "$WIFI_SSID" | tr ' ' '_' | tr -cd '[:alnum:]._-').nmconnection
     cat > ${PREFIX}/etc/NetworkManager/system-connections/$FILENAME <<-EOF
 [connection]
-id=$WIFI_SSID
+id=${WIFI_SSID}
 type=wifi
-interface-name=wlan0
 
 [wifi]
 mode=infrastructure
-ssid=$WIFI_SSID
+ssid=${WIFI_SSID}
+hidden=${WIFI_HIDDEN:-false}
path: arm-image-installer
user: login: say-paul
body: missed it :facepalm: .  Removed from help...
created_at: 2025-03-12T19:29:57Z
author_association: CONTRIBUTOR

PR comments:
user: login: say-paul
created_at: 2025-03-05T17:21:28Z
body: > other things I've not seen addressed here are UUID and mac addresses.

I am not aware of the usecases , as mentioned my initial goal is  to replicate the feature of rpi imager.
I am open to contributing to the above feature , we can have some issues/enhancement-request created to get started.

author_association: CONTRIBUTOR
user: login: pcdubs
created_at: 2025-03-11T13:08:35Z
body: LGTM, tested on Raspberry Pi 3 and 4. 
author_association: COLLABORATOR
user: login: nullr0ute
created_at: 2025-03-11T13:17:27Z
body: Just a couple of minor bits to take care of, can you also squish this down to a single commit with a decent commit message and then I think we're GTG.
author_association: CONTRIBUTOR
user: login: say-paul
created_at: 2025-03-12T15:24:28Z
body: > Just a couple of minor bits to take care of, can you also squish this down to a single commit with a decent commit message and then I think we're GTG.

squished to one commit .

@pcdubs @nullr0ute   when you have time, please review, thanks.
author_association: CONTRIBUTOR