From 66cb9b0e0f24f0da0854d35af1cd50a012f54bda Mon Sep 17 00:00:00 2001 From: Aravindan NC <35158113+AravindanNC@users.noreply.github.com> Date: Tue, 7 Oct 2025 13:57:26 +0000 Subject: [PATCH 01/11] RDKEMW-9104: Enhance NM_Bootstrap.sh for RDKE migration --- lib/rdk/NM_Bootstrap.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/rdk/NM_Bootstrap.sh b/lib/rdk/NM_Bootstrap.sh index d7b092d9..0881b2be 100644 --- a/lib/rdk/NM_Bootstrap.sh +++ b/lib/rdk/NM_Bootstrap.sh @@ -25,20 +25,18 @@ if [ -f $WIFI_WPA_SUPPLICANT_CONF ]; then SSID=$(cat $WIFI_WPA_SUPPLICANT_CONF | grep -w ssid= | cut -d '"' -f 2) PSK=$(cat $WIFI_WPA_SUPPLICANT_CONF | grep -w psk= | cut -d '"' -f 2) - if [ -z "$( ls -A '/opt/NetworkManager/system-connections' )" ]; then if [ -z $SSID ]; then echo "`/bin/timestamp` :$0: No SSID found in supplicant conf" >> /opt/logs/NMMonitor.log else if [ -z $PSK ]; then #connect to wifi - nmcli conn add type wifi con-name $SSID autoconnect yes ifname wlan0 ssid $SSID + nmcli conn add type wifi con-name "$SSID" autoconnect yes ifname wlan0 ssid "$SSID" nmcli conn reload else #connect to wifi - nmcli conn add type wifi con-name $SSID autoconnect yes ifname wlan0 ssid $SSID wifi-sec.key-mgmt wpa-psk wifi-sec.psk $PSK + nmcli conn add type wifi con-name "$SSID" autoconnect yes ifname wlan0 ssid "$SSID" wifi-sec.key-mgmt wpa-psk wifi-sec.psk "$PSK" nmcli conn reload fi fi - fi sed -i '/network={/,/}/d' /opt/secure/wifi/wpa_supplicant.conf fi From f0a8575fdf99ae91c7d69c46de7f840d3d6d3c61 Mon Sep 17 00:00:00 2001 From: Aravindan NC <35158113+AravindanNC@users.noreply.github.com> Date: Tue, 7 Oct 2025 16:56:45 +0000 Subject: [PATCH 02/11] RDKEMW-9104: Enhance NM_Bootstrap.sh for RDKE migration --- lib/rdk/NM_Bootstrap.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/rdk/NM_Bootstrap.sh b/lib/rdk/NM_Bootstrap.sh index 0881b2be..3f2ba827 100644 --- a/lib/rdk/NM_Bootstrap.sh +++ b/lib/rdk/NM_Bootstrap.sh @@ -28,6 +28,9 @@ if [ -f $WIFI_WPA_SUPPLICANT_CONF ]; then if [ -z $SSID ]; then echo "`/bin/timestamp` :$0: No SSID found in supplicant conf" >> /opt/logs/NMMonitor.log else + if [ -n "$( ls -A '/opt/NetworkManager/system-connections' )" ]; then + rm -rf /opt/NetworkManager/system-connections/* + fi if [ -z $PSK ]; then #connect to wifi nmcli conn add type wifi con-name "$SSID" autoconnect yes ifname wlan0 ssid "$SSID" From c9a0291c0dc73caee8a99254f43f2b27d4633881 Mon Sep 17 00:00:00 2001 From: Aravindan NC <35158113+AravindanNC@users.noreply.github.com> Date: Tue, 7 Oct 2025 18:43:19 +0000 Subject: [PATCH 03/11] RDKEMW-9104: Enhance NM_Bootstrap.sh for RDKE migration --- lib/rdk/NM_Bootstrap.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/rdk/NM_Bootstrap.sh b/lib/rdk/NM_Bootstrap.sh index 3f2ba827..4137ad96 100644 --- a/lib/rdk/NM_Bootstrap.sh +++ b/lib/rdk/NM_Bootstrap.sh @@ -29,7 +29,15 @@ if [ -f $WIFI_WPA_SUPPLICANT_CONF ]; then echo "`/bin/timestamp` :$0: No SSID found in supplicant conf" >> /opt/logs/NMMonitor.log else if [ -n "$( ls -A '/opt/NetworkManager/system-connections' )" ]; then - rm -rf /opt/NetworkManager/system-connections/* + for file in "$CONNECTIONS_DIR"/*; do + NM_SSID=$(grep '^ssid=' "$file" | cut -d '=' -f 2) + NM_PSK=$(grep '^psk=' "$file" | cut -d '=' -f 2) + if [ "$SSID" == "$NM_SSID" ] && [ "$PSK" == "$NM_PSK" ]; then + echo "`/bin/timestamp` :$0: Matching SSID $SSID and PSK found from previous RDKE" >> /opt/logs/NMMonitor.log + else + rm -rf "$file" + fi + done fi if [ -z $PSK ]; then #connect to wifi From a1ff1ce5386e5329f8bf8b2131286c9fc9e2eef8 Mon Sep 17 00:00:00 2001 From: Aravindan NC <35158113+AravindanNC@users.noreply.github.com> Date: Wed, 8 Oct 2025 16:33:28 -0400 Subject: [PATCH 04/11] RDKEMW-9104: Enhance NM_Bootstrap.sh for RDKE migration --- lib/rdk/NM_Bootstrap.sh | 64 ++++++++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 27 deletions(-) diff --git a/lib/rdk/NM_Bootstrap.sh b/lib/rdk/NM_Bootstrap.sh index 4137ad96..600da3ad 100644 --- a/lib/rdk/NM_Bootstrap.sh +++ b/lib/rdk/NM_Bootstrap.sh @@ -19,35 +19,45 @@ # limitations under the License. ############################################################################## -WIFI_WPA_SUPPLICANT_CONF="/opt/secure/wifi/wpa_supplicant.conf" +RDKV_SUPP_CONF="/opt/secure/wifi/wpa_supplicant.conf" +if [ -f $RDKV_SUPP_CONF ]; then + if [ -f "/opt/secure/migration/migration_data_store.json" ]; then + bootType=$(cat /tmp/boottype) + bootMigration="BOOT_MIGRATION" + if [ "$bootType" == "$bootMigration" ]; then + rm -f $RDKV_SUPP_CONF + exit 0 + fi + fi + SSID=$(cat $RDKV_SUPP_CONF | grep -w ssid= | cut -d '"' -f 2) + PSK_LINE=$(grep psk= "$RDKV_SUPP_CONF") + + # Case 1: Quoted passphrase + if [[ "$PSK_LINE" =~ psk=\"(.+)\" ]]; then + PSK="${BASH_REMATCH[1]}" + + # Case 2: Unquoted 64-char raw PSK + elif [[ "$PSK_LINE" =~ psk=([a-fA-F0-9]{64}) ]]; then + PSK="${BASH_REMATCH[1]}" -if [ -f $WIFI_WPA_SUPPLICANT_CONF ]; then - SSID=$(cat $WIFI_WPA_SUPPLICANT_CONF | grep -w ssid= | cut -d '"' -f 2) - PSK=$(cat $WIFI_WPA_SUPPLICANT_CONF | grep -w psk= | cut -d '"' -f 2) + # No match + else + PSK="" + fi - if [ -z $SSID ]; then - echo "`/bin/timestamp` :$0: No SSID found in supplicant conf" >> /opt/logs/NMMonitor.log + if [ -z $SSID ]; then + echo "`/bin/timestamp` :$0: No SSID found in supplicant conf" >> /opt/logs/NMMonitor.log + else + rm -rf /opt/NetworkManager/system-connections/* + if [ -z $PSK ]; then + #connect to wifi + nmcli conn add type wifi con-name "$SSID" autoconnect yes ifname wlan0 ssid "$SSID" + nmcli conn reload else - if [ -n "$( ls -A '/opt/NetworkManager/system-connections' )" ]; then - for file in "$CONNECTIONS_DIR"/*; do - NM_SSID=$(grep '^ssid=' "$file" | cut -d '=' -f 2) - NM_PSK=$(grep '^psk=' "$file" | cut -d '=' -f 2) - if [ "$SSID" == "$NM_SSID" ] && [ "$PSK" == "$NM_PSK" ]; then - echo "`/bin/timestamp` :$0: Matching SSID $SSID and PSK found from previous RDKE" >> /opt/logs/NMMonitor.log - else - rm -rf "$file" - fi - done - fi - if [ -z $PSK ]; then - #connect to wifi - nmcli conn add type wifi con-name "$SSID" autoconnect yes ifname wlan0 ssid "$SSID" - nmcli conn reload - else - #connect to wifi - nmcli conn add type wifi con-name "$SSID" autoconnect yes ifname wlan0 ssid "$SSID" wifi-sec.key-mgmt wpa-psk wifi-sec.psk "$PSK" - nmcli conn reload - fi + #connect to wifi + nmcli conn add type wifi con-name "$SSID" autoconnect yes ifname wlan0 ssid "$SSID" wifi-sec.key-mgmt wpa-psk wifi-sec.psk "$PSK" + nmcli conn reload fi - sed -i '/network={/,/}/d' /opt/secure/wifi/wpa_supplicant.conf + fi + rm -f $RDKV_SUPP_CONF fi From 800b4beab0fc9b22a6c912ba674da18823aab872 Mon Sep 17 00:00:00 2001 From: Aravindan NC <35158113+AravindanNC@users.noreply.github.com> Date: Wed, 8 Oct 2025 16:35:41 -0400 Subject: [PATCH 05/11] RDKEMW-9104: Enhance NM_Bootstrap.sh for RDKE migration --- systemd_units/NetworkManager_ecfs.conf | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 systemd_units/NetworkManager_ecfs.conf diff --git a/systemd_units/NetworkManager_ecfs.conf b/systemd_units/NetworkManager_ecfs.conf new file mode 100644 index 00000000..312b8901 --- /dev/null +++ b/systemd_units/NetworkManager_ecfs.conf @@ -0,0 +1,2 @@ +[Unit] +After=ecfs-init.service From 24821c84b2e37b1a5ac9eee0611173970e771fbe Mon Sep 17 00:00:00 2001 From: Aravindan NC <35158113+AravindanNC@users.noreply.github.com> Date: Thu, 9 Oct 2025 08:47:18 -0400 Subject: [PATCH 06/11] RDKEMW-9104: Enhance NM_Bootstrap.sh for RDKE migration --- systemd_units/NetworkManager_ecfs.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/systemd_units/NetworkManager_ecfs.conf b/systemd_units/NetworkManager_ecfs.conf index 312b8901..dcf4079f 100644 --- a/systemd_units/NetworkManager_ecfs.conf +++ b/systemd_units/NetworkManager_ecfs.conf @@ -1,2 +1,2 @@ [Unit] -After=ecfs-init.service +After=securemount.service From ce7ad6ed7cde5450f351f28582fb2a9f19b88ad2 Mon Sep 17 00:00:00 2001 From: Aravindan NC <35158113+AravindanNC@users.noreply.github.com> Date: Thu, 9 Oct 2025 10:43:12 -0400 Subject: [PATCH 07/11] RDKEMW-9104: Enhance NM_Bootstrap.sh for RDKE migration --- lib/rdk/NM_Bootstrap.sh | 8 -------- 1 file changed, 8 deletions(-) diff --git a/lib/rdk/NM_Bootstrap.sh b/lib/rdk/NM_Bootstrap.sh index 600da3ad..ca374ea3 100644 --- a/lib/rdk/NM_Bootstrap.sh +++ b/lib/rdk/NM_Bootstrap.sh @@ -21,14 +21,6 @@ RDKV_SUPP_CONF="/opt/secure/wifi/wpa_supplicant.conf" if [ -f $RDKV_SUPP_CONF ]; then - if [ -f "/opt/secure/migration/migration_data_store.json" ]; then - bootType=$(cat /tmp/boottype) - bootMigration="BOOT_MIGRATION" - if [ "$bootType" == "$bootMigration" ]; then - rm -f $RDKV_SUPP_CONF - exit 0 - fi - fi SSID=$(cat $RDKV_SUPP_CONF | grep -w ssid= | cut -d '"' -f 2) PSK_LINE=$(grep psk= "$RDKV_SUPP_CONF") From 7a254f4cbf38a55b4b95e0b8bbc77205753b25b9 Mon Sep 17 00:00:00 2001 From: Aravindan NC <35158113+AravindanNC@users.noreply.github.com> Date: Thu, 9 Oct 2025 10:44:02 -0400 Subject: [PATCH 08/11] RDKEMW-9104: Enhance NM_Bootstrap.sh for RDKE migration --- systemd_units/NetworkManager_ecfs.conf | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 systemd_units/NetworkManager_ecfs.conf diff --git a/systemd_units/NetworkManager_ecfs.conf b/systemd_units/NetworkManager_ecfs.conf deleted file mode 100644 index dcf4079f..00000000 --- a/systemd_units/NetworkManager_ecfs.conf +++ /dev/null @@ -1,2 +0,0 @@ -[Unit] -After=securemount.service From b2846ba86c17fd85dbe508ea7710b89e44b9e3cb Mon Sep 17 00:00:00 2001 From: Aravindan NC <35158113+AravindanNC@users.noreply.github.com> Date: Thu, 9 Oct 2025 12:22:57 -0400 Subject: [PATCH 09/11] RDKEMW-9104: Enhance NM_Bootstrap.sh for RDKE migration --- lib/rdk/NM_Bootstrap.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/rdk/NM_Bootstrap.sh b/lib/rdk/NM_Bootstrap.sh index ca374ea3..42cb9b40 100644 --- a/lib/rdk/NM_Bootstrap.sh +++ b/lib/rdk/NM_Bootstrap.sh @@ -19,7 +19,17 @@ # limitations under the License. ############################################################################## +RDK_PROFILE=$(grep "RDK_PROFILE" /etc/device.properties | cut -d '=' -f 2) RDKV_SUPP_CONF="/opt/secure/wifi/wpa_supplicant.conf" +if [ "$RDK_PROFILE" == "TV" ]; then + echo "`/bin/timestamp` :$0: Not migrating Wifi credentials for TVs from NM_Bootsrtap" >> /opt/logs/NMMonitor.log + if [ -f $RDKV_SUPP_CONF ]; then + sed -i '/network={/,/}/d' /opt/secure/wifi/wpa_supplicant.conf + fi + exit 0 +fi + + if [ -f $RDKV_SUPP_CONF ]; then SSID=$(cat $RDKV_SUPP_CONF | grep -w ssid= | cut -d '"' -f 2) PSK_LINE=$(grep psk= "$RDKV_SUPP_CONF") @@ -51,5 +61,5 @@ if [ -f $RDKV_SUPP_CONF ]; then nmcli conn reload fi fi - rm -f $RDKV_SUPP_CONF + sed -i '/network={/,/}/d' /opt/secure/wifi/wpa_supplicant.conf fi From b5e0d102c8c3a0c6a800042d459e937888e6903e Mon Sep 17 00:00:00 2001 From: Aravindan NC <35158113+AravindanNC@users.noreply.github.com> Date: Thu, 9 Oct 2025 12:24:44 -0400 Subject: [PATCH 10/11] RDKEMW-9104: Enhance NM_Bootstrap.sh for RDKE migration --- systemd_units/NetworkManager_ecfs.conf | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 systemd_units/NetworkManager_ecfs.conf diff --git a/systemd_units/NetworkManager_ecfs.conf b/systemd_units/NetworkManager_ecfs.conf new file mode 100644 index 00000000..dcf4079f --- /dev/null +++ b/systemd_units/NetworkManager_ecfs.conf @@ -0,0 +1,2 @@ +[Unit] +After=securemount.service From a03b0cab08978d6ddf2655c09b0e9c2bb12a17bc Mon Sep 17 00:00:00 2001 From: Aravindan NC <35158113+AravindanNC@users.noreply.github.com> Date: Thu, 9 Oct 2025 14:49:08 -0400 Subject: [PATCH 11/11] RDKEMW-9104: Enhance NM_Bootstrap.sh for RDKE migration --- lib/rdk/NM_Bootstrap.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/rdk/NM_Bootstrap.sh b/lib/rdk/NM_Bootstrap.sh index 42cb9b40..149e199c 100644 --- a/lib/rdk/NM_Bootstrap.sh +++ b/lib/rdk/NM_Bootstrap.sh @@ -26,6 +26,7 @@ if [ "$RDK_PROFILE" == "TV" ]; then if [ -f $RDKV_SUPP_CONF ]; then sed -i '/network={/,/}/d' /opt/secure/wifi/wpa_supplicant.conf fi + rm -rf /opt/NetworkManager/system-connections/* exit 0 fi