Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 38 additions & 16 deletions lib/rdk/NM_Bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,47 @@
# limitations under the License.
##############################################################################

WIFI_WPA_SUPPLICANT_CONF="/opt/secure/wifi/wpa_supplicant.conf"
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
rm -rf /opt/NetworkManager/system-connections/*
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")

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)
# 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]}"

# No match
else
PSK=""
fi

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
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 [ -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
fi
sed -i '/network={/,/}/d' /opt/secure/wifi/wpa_supplicant.conf
Expand Down
2 changes: 2 additions & 0 deletions systemd_units/NetworkManager_ecfs.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[Unit]

Check failure on line 1 in systemd_units/NetworkManager_ecfs.conf

View workflow job for this annotation

GitHub Actions / call-fossid-workflow / Fossid Annotate PR

FossID License Issue Detected

Source code with 'Apache-2.0' license found in local file 'systemd_units/NetworkManager_ecfs.conf' (Match: rdk/components/generic/netmonitor/rdk/components/generic/netmonitor/e99bec6, full file, url: https://code.rdkcentral.com/r/plugins/gitiles/rdk/components/generic/netmonitor/+archive/e99bec69e1cea9464d956cd0109277d48a9b7d09.tar.gz, file: conf/nlmon.conf)
After=securemount.service
Loading