Skip to content
Open
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
25 changes: 17 additions & 8 deletions lib/rdk/Start_MaintenanceTasks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,24 @@ runMaintenanceLogUploadTask()

if [ -f "$LOG_UPLOAD_BIN_PATH" ]; then
logUploadLog "Starting log upload"
upload_protocol=$(grep 'LogUploadSettings:UploadRepository:uploadProtocol' /tmp/DCMSettings.conf | cut -d '=' -f2 | sed 's/^"//; s/"$//')
[ -z "$upload_protocol" ] && upload_protocol='HTTP'
logUploadLog "upload_protocol: $upload_protocol"

httplink=$(grep 'LogUploadSettings:UploadRepository:URL' /tmp/DCMSettings.conf | cut -d '=' -f2 | sed 's/^"//; s/"$//')
if [ -n "$httplink" ]; then
upload_httplink="$httplink"

if [ -L "/tmp/DCMSettings.conf" ]; then
logUploadLog "ERROR: DCMSettings.conf is a symlink"
Comment thread
MV-1970 marked this conversation as resolved.
Resolved
else
logUploadLog "'LogUploadSettings:UploadRepository:URL' is not found in DCMSettings.conf"
upload_protocol=$(grep 'LogUploadSettings:UploadRepository:uploadProtocol' /tmp/DCMSettings.conf | cut -d '=' -f2 | sed 's/^"//; s/"$//')
[ -z "$upload_protocol" ] && upload_protocol='HTTPS'
logUploadLog "upload_protocol: $upload_protocol"

httplink=$(grep 'LogUploadSettings:UploadRepository:URL' /tmp/DCMSettings.conf | cut -d '=' -f2 | sed 's/^"//; s/"$//')
if [ -n "$httplink" ]; then
if echo "$httplink" | grep -qE '^https?://'; then
upload_httplink="$httplink"
else
logUploadLog "ERROR: Invalid URL format in DCMSettings.conf"
fi
else
logUploadLog "'LogUploadSettings:UploadRepository:URL' is not found in DCMSettings.conf"
fi
fi

if [ "$BUILD_TYPE" != "prod" ] && [ -f /opt/dcm.properties ]; then
Expand Down
8 changes: 4 additions & 4 deletions lib/rdk/core_shell.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ upload() {
fi
fi
# Checking whether cores are leading to /opt size exceeding.
count=`ls $CORE_PATH | grep $process | wc -l`
count=`ls $CORE_PATH | grep "$process" | wc -l`
while [ $count -gt 5 ]; do
oldcore=`ls -t $CORE_PATH | grep $process | tail -1`
oldcore=`ls -t $CORE_PATH | grep "$process" | tail -1`
echo $(/bin/timestamp) "Deleting $oldcore as the same process has more than 5 cores in $CORE_PATH" >> $LOG_PATH/core_log.txt
rm -rf $CORE_PATH/$oldcore
count=`ls $CORE_PATH | grep $process | wc -l`
rm -rf "$CORE_PATH/$oldcore"
count=`ls $CORE_PATH | grep "$process" | wc -l`
done

sh /lib/rdk/diskCleanup.sh
Expand Down
23 changes: 15 additions & 8 deletions lib/rdk/cronjobs_update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,31 @@ if [ $# -ne 3 ] && [ "$1" = "add" -o "$1" = "update" ]; then
fi

LOCK="/tmp/.cronjob.LCK"
if [ -L "$LOCK" ]; then
rm -f "$LOCK"
fi
exec 8>$LOCK
flock -x 8
flock -x -w 30 8 || exit 1

remove()
{
sed -i "/[A-Za-z0-9]*$1[A-Za-z0-9]*/d" $current_cron_file
escaped=$(printf '%s\n' "$1" | sed 's/[][\\.^$*\/]/\\&/g')
sed -i "/[A-Za-z0-9]*${escaped}[A-Za-z0-9]*/d" "$current_cron_file"
}

add()
{
echo "$1" >> $current_cron_file
if echo "$1" | grep -q '[;&]'; then
Comment thread
MV-1970 marked this conversation as resolved.
Resolved
exit 1
fi
echo "$1" >> "$current_cron_file"
}

check_entry()
{
output=`grep -c "$1" $current_cron_file`
output=`grep -cF "$1" "$current_cron_file"`
echo "`/bin/timestamp` output=$output" >> $log_file
echo $output
echo "$output"
}


Expand All @@ -77,14 +84,14 @@ if [ -f /etc/os-release ]; then
touch /var/spool/cron/root
pid=`pidof crond`
echo "`/bin/timestamp` crond pid: $pid" >> $log_file
if [ -z $pid ]; then
if [ -z "$pid" ]; then
crond -b -L /dev/null -c /var/spool/cron/
fi
fi


current_cron_file="/tmp/cron_list"
crontab -l -c /var/spool/cron/ > $current_cron_file
crontab -l -c /var/spool/cron/ > "$current_cron_file"

echo "`/bin/timestamp` :Arguments - 1st:$1, 2nd:$2, 3rd:$3" >> $log_file
if [ "$1" = "remove" ]; then
Expand All @@ -110,7 +117,7 @@ fi


# update the new cron entries to root cron
crontab $current_cron_file -c /var/spool/cron/
crontab "$current_cron_file" -c /var/spool/cron/

# add flock -u to unlock the file descriptor before removing the file
flock -u 8
Expand Down
2 changes: 1 addition & 1 deletion lib/rdk/warehouse-reset.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ fi

echo "Warehouse Reset:Starting file cleanUp"
# /opt override cleanup
ls /opt/*.conf | grep -v receiver.conf | xargs rm
find /opt -maxdepth 1 -name "*.conf" ! -name "receiver.conf" -exec rm {} \;
rm -rf /opt/*.ini
if [ -f /opt/hosts ]; then rm -rf /opt/hosts; fi
if [ -f /opt/dcm.properties ];then rm -rf /opt/dcm.properties ; fi
Expand Down
Loading