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
8 changes: 7 additions & 1 deletion lib/rdk/NM_Dispatcher.sh
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,15 @@ interfaceName=$1
interfaceStatus=$2

if [ "$interfaceStatus" = "up" ]; then

/usr/bin/nm-online -q -t 60 # If Network manager is not online wait for 60 sec. TODO: Revisit this during connectivity check enable time
CON_STATE=$(nmcli -t -f GENERAL.STATE device show "$interfaceName" 2>/dev/null | cut -d: -f2)
NMdispatcherLog "Connection state of interface $interfaceName=$CON_STATE"
if [ "$CON_STATE" = "100 (connected)" ] || [ "$CON_STATE" = "120 (connected (site only))" ]; then
NMdispatcherLog "Connection state of $interfaceName is connected."
sh /lib/rdk/connectivitycheck.sh &
else
NMdispatcherLog "Connection state of $interfaceName Up But Not Fully connected."
fi
fi

if [ "x$interfaceName" != "x" ] && [ "$interfaceName" != "lo" ]; then
Expand Down
79 changes: 79 additions & 0 deletions lib/rdk/connectivitycheck.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/bin/sh
####################################################################################
# If not stated otherwise in this file or this component's LICENSE file the
# following copyright and licenses apply:
#
# Copyright 2024 Comcast Cable Communications Management, LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");

Check failure on line 8 in lib/rdk/connectivitycheck.sh

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 'lib/rdk/connectivitycheck.sh' (Match: tink-crypto/tink/1.0.0, 11 lines, url: https://github.com/tink-crypto/tink/archive/v1.0.0.tar.gz, file: kokoro/macos_external/presubmit.sh)
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
####################################################################################

. /etc/include.properties
. /etc/device.properties

if [ -f /lib/rdk/t2Shared_api.sh ]; then
source /lib/rdk/t2Shared_api.sh
fi

CONNCHECK_LOG_FILE="$LOG_PATH/NMMonitor.log"
CONNCHECK_FILE="/tmp/connectivity_check_done"
CONNCHECK_TIMEOUT=120 # 2 minutes
CONNCHECK_RETRY_INTERVAL=10 # 10 seconds

connectivityCheckLog()
{
echo "$(/bin/timestamp) : $0: $*" >> $CONNCHECK_LOG_FILE
}

if [ -n "$CONNECTIVITY_CHECK_URL" ]; then
URL="$CONNECTIVITY_CHECK_URL"
else
connectivityCheckLog "CONNECTIVITY_CHECK_URL not set. Exiting."
if [ ! -f $CONNCHECK_FILE ]; then
touch $CONNCHECK_FILE
fi
t2CountNotify "SYST_WARN_connectivitycheck_nourl_set"
exit 0
fi

# Get start time from /proc/uptime (integer part only)
START=$(cut -d. -f1 /proc/uptime)

while true; do
NOW=$(cut -d. -f1 /proc/uptime)
ELAPSED=$((NOW - START))

if [ "$ELAPSED" -ge "$CONNCHECK_TIMEOUT" ]; then
connectivityCheckLog "Failed to get HTTP 204 within $CONNCHECK_TIMEOUT seconds."
if [ ! -f $CONNCHECK_FILE ]; then
touch $CONNCHECK_FILE
fi
t2CountNotify "SYST_WARN_connectivitycheck_time_expire"
exit 0
fi

HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" "$URL")

if [ "$HTTP_CODE" -eq 204 ]; then
connectivityCheckLog "Connected: Received HTTP 204"
if [ ! -f $CONNCHECK_FILE ]; then
touch $CONNCHECK_FILE
fi
t2CountNotify "SYST_INFO_connectivitycheck_success"
exit 0
else
connectivityCheckLog "connectivitycheck.sh Not connected yet (HTTP $HTTP_CODE). Retrying in $CONNCHECK_RETRY_INTERVAL seconds..."
fi

sleep $CONNCHECK_RETRY_INTERVAL
done
4 changes: 2 additions & 2 deletions systemd_units/coredump-secure-upload.service
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
[Unit]
Description=COREDUMP UPLOAD

After=network-online.target tr69hostif.service
Requires=network-online.target
After=network-up.target tr69hostif.service
Requires=network-up.target

[Service]
ExecStart=/lib/rdk/uploadDumps.sh "" 1 secure
Expand Down
4 changes: 2 additions & 2 deletions systemd_units/coredump-upload.service
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
[Unit]
Description=COREDUMP UPLOAD

After=network-online.target
Requires=network-online.target
After=network-up.target
Requires=network-up.target

[Service]
ExecStart=/lib/rdk/uploadDumps.sh "" 1
Expand Down
4 changes: 2 additions & 2 deletions systemd_units/minidump-secure-upload.service
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
[Unit]
Description=MINIDUMP UPLOAD

After=network-online.target tr69hostif.service
Requires=network-online.target
After=network-up.target tr69hostif.service
Requires=network-up.target

[Service]
ExecStart=/lib/rdk/uploadDumps.sh "" 0 secure
Expand Down
4 changes: 2 additions & 2 deletions systemd_units/minidump-upload.service
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
[Unit]
Description=MINIDUMP UPLOAD

After=network-online.target
Requires=network-online.target
After=network-up.target
Requires=network-up.target

[Service]
ExecStart=/lib/rdk/uploadDumps.sh "" 0
Expand Down
8 changes: 0 additions & 8 deletions systemd_units/notify-network-ready.service

This file was deleted.

Loading