Skip to content
Closed
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
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,24 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### [1.1.0](https://github.com/rdkcentral/sysint-broadband/compare/1.0.0...1.1.0)

- RDKB-63303, RDKB-63414 : Move RdkLogger Scripts to Cron [`#15`](https://github.com/rdkcentral/sysint-broadband/pull/15)
- RDKB-63514: Optimize and reduce RDKB memory usage - Reducing journalctl logs storage - Update log [`#14`](https://github.com/rdkcentral/sysint-broadband/pull/14)
- RDKB-63373, XB10-1930 : Observing integer expression expected in uplo… [`#10`](https://github.com/rdkcentral/sysint-broadband/pull/10)
- RDKB-63514: Optimize and reduce RDKB memory usage - Reducing journalctl logs storage [`#11`](https://github.com/rdkcentral/sysint-broadband/pull/11)
- RDKB-62753: Crontab output is not expected for RFC_Reboot.sh [`#12`](https://github.com/rdkcentral/sysint-broadband/pull/12)
- Updating update_journal_log.sh [`433739b`](https://github.com/rdkcentral/sysint-broadband/commit/433739b128f406e2754e29d0a99502c81f881762)
- RDKB-63373, XB10-1930 : Observing integer expression expected in uploadRDKBLogs.sh [`41695de`](https://github.com/rdkcentral/sysint-broadband/commit/41695deeffe480b5d6f67012dac7383c095ac05b)
- Updating update_journal_logs.sh [`d76c346`](https://github.com/rdkcentral/sysint-broadband/commit/d76c346da430cbafed9bf9b01fa99fc47dcd6b7e)

#### 1.0.0

> 29 January 2026

- Create CODEOWNERS [`#7`](https://github.com/rdkcentral/sysint-broadband/pull/7)
- Create CONTRIBUTING.md [`#6`](https://github.com/rdkcentral/sysint-broadband/pull/6)
- Create fossid_integration_stateless_diffscan_target_repo.yml [`#5`](https://github.com/rdkcentral/sysint-broadband/pull/5)
- Import of source (stable2) [`2fc8051`](https://github.com/rdkcentral/sysint-broadband/commit/2fc8051f1468a67dd0ce3f650105e5678f7ed30b)
- Create cla.yml [`ae32072`](https://github.com/rdkcentral/sysint-broadband/commit/ae320721e019c03b5edd620f9f9aa8e5a4c69465)
- Add changelog for release 1.0.0 [`f0fa4a8`](https://github.com/rdkcentral/sysint-broadband/commit/f0fa4a8c00a83b9ade058763419092fd3eb0b27b)
13 changes: 8 additions & 5 deletions RfcRebootCronschedule.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

. /etc/device.properties

calcRebootExecTime()

Check failure on line 15 in RfcRebootCronschedule.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 'RfcRebootCronschedule.sh' (Match: rdkb/components/opensource/ccsp/sysint/rdkb/components/opensource/ccsp/sysint/1, 100 lines, url: https://code.rdkcentral.com/r/plugins/gitiles/rdkb/components/opensource/ccsp/sysint/+archive/RDKB-TEST-RELEASE-1.tar.gz, file: RfcRebootCronschedule.sh)
{

# Extract maintenance window start and end time
Expand All @@ -37,17 +37,20 @@
time_offset=`dmcli eRT getv Device.Time.TimeOffset | grep "value:" | cut -d ":" -f 3 | tr -d ' '`

if [ "x$BOX_TYPE" = "xHUB4" ] || [ "x$BOX_TYPE" = "xSR213" ]; then
#Maintence start and end time in UTC
#Maintenance start and end time in UTC
main_start_time=$start_time
main_end_time=$end_time
else
#Maintence start and end time in local
main_start_time=$((start_time-time_offset))
main_end_time=$((end_time-time_offset))
#Maintenance start and end time in local. Ensure that start and end times are non-negative.
main_start_time=$(((start_time - time_offset + 86400) % 86400))
main_end_time=$(((end_time - time_offset + 86400) % 86400))
fi

#calculate random time in sec
rand_time_in_sec=`awk -v min=$main_start_time -v max=$main_end_time -v seed="$(date +%N)" 'BEGIN{srand(seed);print int(min+rand()*(max-min+1))}'`
rand_time_in_sec=`awk -v min=$main_start_time -v max=$main_end_time -v seed="$(date +%N)" 'BEGIN{
if (max < min) max += 86400; #handle maintenance window crossing midnight
srand(seed);print int(min+rand()*(max-min+1));
}'`

# To avoid cron to be set beyond 24 hr clock limit
if [ $rand_time_in_sec -ge 86400 ]
Expand Down
168 changes: 138 additions & 30 deletions fileUploadRandom.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh

Check failure on line 1 in fileUploadRandom.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 'fileUploadRandom.sh' (Match: rdkb/components/opensource/ccsp/sysint/rdkb/components/opensource/ccsp/sysint/1, 315 lines, url: https://code.rdkcentral.com/r/plugins/gitiles/rdkb/components/opensource/ccsp/sysint/+archive/RDKB-RELEASE-TEST-DUNFELL-1.tar.gz, file: fileUploadRandom.sh)
##########################################################################
# If not stated otherwise in this file or this component's Licenses.txt
# file the following copyright and licenses apply:
Expand Down Expand Up @@ -34,7 +34,18 @@
SELFHEAL_PATH="/usr/ccsp/tad"
CERT_CHECKER_PATH="/lib/rdk"

calcRandTimeandUpload()
CRON_MODE=0
FILEUPLOAD_TMP_DIR="/tmp/.fileupload_state"
DELAY_REMAINING_FILE="$FILEUPLOAD_TMP_DIR/.delay_remaining_secs"
HEARTBEAT_TICK_FILE="$FILEUPLOAD_TMP_DIR/.heartbeat_tick"
CRON_SETUP_FLAG="$FILEUPLOAD_TMP_DIR/.cron_setup_complete"
NEXT_UPLOAD_TIME_FILE="$FILEUPLOAD_TMP_DIR/.next_upload_timestamp"

if [ ! -d "$FILEUPLOAD_TMP_DIR" ]; then
mkdir -p "$FILEUPLOAD_TMP_DIR"
fi

generate_random_delay()
{
rand_hr=0
rand_min=0
Expand All @@ -53,7 +64,59 @@

min_to_sleep=$(($rand_hr*60 + $rand_min))
sec_to_sleep=$(($min_to_sleep*60 + $rand_sec))
sleep $sec_to_sleep;
}

calcRandTimeandUpload()
{
delay_completed=0
if [ "$CRON_MODE" = "1" ]; then
if [ ! -f "$DELAY_REMAINING_FILE" ]; then
generate_random_delay
echo "$sec_to_sleep" > "$DELAY_REMAINING_FILE"
echo_t "fileupload_random: Initial random delay stored: $sec_to_sleep seconds" >> "$NEXT_UPLOAD_TIME_FILE"
else
echo_t "fileupload_random: Random delay already generated, reusing existing value" >> "$NEXT_UPLOAD_TIME_FILE"
fi

if [ -f "$HEARTBEAT_TICK_FILE" ]; then
current_tick=$(cat "$HEARTBEAT_TICK_FILE")
else
current_tick=0
fi

if [ "$current_tick" = "0" ]; then
remaining=$(cat "$DELAY_REMAINING_FILE" 2>/dev/null)
[ -z "$remaining" ] && remaining=0

if [ "$remaining" -le 300 ]; then
echo_t "fileupload_random: Sleeping $remaining seconds now" >> "$NEXT_UPLOAD_TIME_FILE"
rm -f "$DELAY_REMAINING_FILE" "$HEARTBEAT_TICK_FILE"
delay_completed=1
[ "$remaining" -gt 0 ] && sleep "$remaining"
else
echo_t "fileupload_random: Remaining delay before upload: $remaining seconds" >> "$NEXT_UPLOAD_TIME_FILE"
new_remaining=$((remaining - 300))
if [ "$new_remaining" -lt 0 ]; then
new_remaining=0
fi
echo $new_remaining > "$DELAY_REMAINING_FILE"
fi
else
echo_t "fileupload_random: Skipping countdown this minute (tick=$current_tick/4)" >> "$NEXT_UPLOAD_TIME_FILE"
fi

if [ "$delay_completed" != "1" ]; then
new_tick=$(( (current_tick + 1) % 5 ))
echo "$new_tick" > "$HEARTBEAT_TICK_FILE"
return 0
fi
fi

if [ "$CRON_MODE" != "1" ]; then
generate_random_delay
echo_t "fileupload_random: Sleeping for $sec_to_sleep seconds" >> "$NEXT_UPLOAD_TIME_FILE"
sleep $sec_to_sleep;
fi

if [ -f "$MAINTENANCEWINDOW" ]
then
Expand Down Expand Up @@ -229,34 +292,79 @@

BUILD_TYPE=`getBuildType`
SERVER=`getTFTPServer $BUILD_TYPE`
loop=1
upload_logfile=1
while [ $loop -eq 1 ]
do
sleep 60

if [ "$UTC_ENABLE" == "true" ]
then
cur_hr=`LTime H | tr -dc '0-9'`
cur_min=`LTime M | tr -dc '0-9'`
else
cur_hr=`date +"%H"`
cur_min=`date +"%M"`
fi
check_maintenance_window_upload()
{
upload_logfile=1
if [ "$UTC_ENABLE" == "true" ]; then
cur_hr=`LTime H | tr -dc '0-9'`
cur_min=`LTime M | tr -dc '0-9'`
else
cur_hr=`date +"%H"`
cur_min=`date +"%M"`
fi

if [ "$cur_hr" -ge "02" ] && [ "$cur_hr" -le "05" ]
then
if [ "$cur_hr" = "05" ] && [ "$cur_min" != "00" ]
then
upload_logfile=1
else
if [ "$upload_logfile" = "1" ]
then
calcRandTimeandUpload
fi
fi
else
upload_logfile=1
fi
done
if [ "$cur_hr" -ge "02" ] && [ "$cur_hr" -le "05" ]; then
if [ "$cur_hr" = "05" ] && [ "$cur_min" != "00" ]; then
upload_logfile=1
else
if [ "$upload_logfile" = "1" ]; then
calcRandTimeandUpload
fi
fi
else
upload_logfile=1
fi
}
install_cron_entry() {
CRON_LINE="* * * * * /rdklogger/fileUploadRandom.sh"

if crontab -l 2>/dev/null | grep -q "fileUploadRandom.sh"; then
echo_t "fileUploadRandom.sh - Cron entry already present"
return 0
fi

(crontab -l 2>/dev/null; echo "$CRON_LINE") | crontab -
rc=$?

if [ $rc -eq 0 ]; then
echo_t "fileUploadRandom.sh - Cron installed cleanly: $CRON_LINE"
else
echo_t "fileUploadRandom.sh - Cron install failed (rc=$rc)"
fi
}

service_mode() {
while [ 1 ];
do
sleep 60
CRON_MODE=0
check_maintenance_window_upload
done
}

rdklogger_cron_enable=`syscfg get RdkbLogCronEnable`

if [ "$rdklogger_cron_enable" = "true" ]; then
CRON_MODE=1

if [ ! -d "$FILEUPLOAD_TMP_DIR" ]; then
mkdir -p "$FILEUPLOAD_TMP_DIR"
fi

if [ ! -f "$CRON_SETUP_FLAG" ]; then
install_cron_entry
touch "$CRON_SETUP_FLAG"
fi

if [ -f "$DELAY_REMAINING_FILE" ]; then
calcRandTimeandUpload
else
check_maintenance_window_upload
fi

exit 0
else
CRON_MODE=0
service_mode
fi
Loading
Loading