WNCXIONE-530: Fixed changes for migration. - #352
Conversation
Signed-off-by: Balaji Punnuru <Balaji_Punnuru@comcast.com>
|
Balaji Punnuru seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the NM_Bootstrap.sh script to improve WiFi connection management by detecting RDK profile and handling cases where no SSID is configured. Key changes include:
- Renaming the WiFi supplicant configuration variable and introducing RDK profile detection
- Removing a debug log line
- Adding fallback logic to handle missing SSID by copying previously configured network settings and setting up new WiFi connections using nmcli
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| rm -rf /opt/NetworkManager/system-connections/* | ||
| fi | ||
| if [ "$RDK_PROFILE" == "TV" ]; then | ||
| echo "`/bin/timestamp` :$0: Migrating Wifi credentials for TVs from NM_Bootsrtap" >> /opt/logs/NMMonitor.log |
There was a problem hiding this comment.
Corrected spelling of 'NM_Bootsrtap' to 'NM_Bootstrap'.
| echo "`/bin/timestamp` :$0: Migrating Wifi credentials for TVs from NM_Bootsrtap" >> /opt/logs/NMMonitor.log | |
| echo "`/bin/timestamp` :$0: Migrating Wifi credentials for TVs from NM_Bootstrap" >> /opt/logs/NMMonitor.log |
| SSID=$(cat $WIFI_WPA_SUPPLICANT_CONF | grep -w ssid= | cut -d '"' -f 2) | ||
| PSK_LINE=$(grep psk= "$WIFI_WPA_SUPPLICANT_CONF") | ||
|
|
||
| if [ -f $RDKV_SUPP_CONF ]; then |
There was a problem hiding this comment.
Variable $RDKV_SUPP_CONF should be quoted to prevent word splitting and glob expansion. Use "$RDKV_SUPP_CONF" instead.
| if [ -f $RDKV_SUPP_CONF ]; then | |
| if [ -f "$RDKV_SUPP_CONF" ]; then |
| sed -i '/network={/,/}/d' /opt/secure/wifi/wpa_supplicant.conf | ||
| fi | ||
|
|
||
| if [ -z $SSID ]; then |
There was a problem hiding this comment.
Variable $SSID should be quoted to prevent word splitting and handle empty/unset values correctly. Use "$SSID" instead.
| if [ -z $SSID ]; then | |
| if [ -z "$SSID" ]; then |
| if [ "$RDK_PROFILE" == "TV" ]; then | ||
| echo "`/bin/timestamp` :$0: Migrating Wifi credentials for TVs from NM_Bootsrtap" >> /opt/logs/NMMonitor.log | ||
| fi | ||
| if [ -z $PSK ]; then |
There was a problem hiding this comment.
Variable $PSK should be quoted to prevent word splitting and handle empty/unset values correctly. Use "$PSK" instead.
| if [ -z $PSK ]; then | |
| if [ -z "$PSK" ]; then |
| mkdir -p /opt/secure/NetworkManager/system-connections | ||
| fi | ||
| if [ -d /opt/NetworkManager/system-connections ]; then | ||
| cp /opt/NetworkManager/system-connections/* /opt/secure/NetworkManager/system-connections/ |
There was a problem hiding this comment.
This command will fail if the source directory is empty because the wildcard won't expand. Add a check for files or use a safer pattern like 'cp -r /opt/NetworkManager/system-connections/. /opt/secure/NetworkManager/system-connections/' with proper error handling.
| cp /opt/NetworkManager/system-connections/* /opt/secure/NetworkManager/system-connections/ | |
| cp -r /opt/NetworkManager/system-connections/. /opt/secure/NetworkManager/system-connections/ || echo "`/bin/timestamp` :$0: Failed to copy system-connections" >> /opt/logs/NMMonitor.log |
No description provided.