
This commit adds support for 1) Post-install scripts for In-Service patches 2) Pre-install scripts for In-Service patches Test Plan: [PASS] Install scripts run before and after install [PASS] Scripts are optional Story: 2010676 Task: 49480 Change-Id: I6729798a59ac61c7eae395d8a3a3b425fe4e6f72 Signed-off-by: Jessica Castelino <jessica.castelino@windriver.com> Signed-off-by: sshathee <shunmugam.shatheesh@windriver.com>
67 lines
1.4 KiB
Bash
67 lines
1.4 KiB
Bash
#!/bin/bash
|
|
#
|
|
# Copyright (c) 2023-2024 Wind River Systems, Inc.
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
|
|
. /etc/software/software-functions
|
|
|
|
if [ -z "$1" ]
|
|
then
|
|
loginfo "No input parameter provided to identify script type."
|
|
exit 0
|
|
fi
|
|
|
|
declare DIR="${PATCH_SCRIPTDIR}/${1}"
|
|
declare SCRIPTS=$(find $DIR -type f -executable | sort)
|
|
declare -i NUM_SCRIPTS=$(echo "$SCRIPTS" | wc -l)
|
|
|
|
if [ $NUM_SCRIPTS -eq 0 ]
|
|
then
|
|
loginfo "No in-service patch scripts found."
|
|
exit 0
|
|
fi
|
|
|
|
loginfo "Running $NUM_SCRIPTS in-service patch scripts"
|
|
|
|
declare SCRIPTLOG=/var/log/software.log
|
|
cat <<EOF >>$SCRIPTLOG
|
|
############################################################
|
|
`date "+%FT%T.%3N"`: Running $NUM_SCRIPTS install patch scripts:
|
|
|
|
$SCRIPTS
|
|
|
|
############################################################
|
|
EOF
|
|
|
|
declare -i FAILURES=0
|
|
for cmd in $SCRIPTS
|
|
do
|
|
cat <<EOF >>$SCRIPTLOG
|
|
############################################################
|
|
`date "+%FT%T.%3N"`: Running $cmd
|
|
|
|
EOF
|
|
|
|
bash -x $cmd >>$SCRIPTLOG 2>&1
|
|
rc=$?
|
|
if [ $rc -ne $PATCH_STATUS_OK ]
|
|
then
|
|
let -i FAILURES++
|
|
fi
|
|
cat <<EOF >>$SCRIPTLOG
|
|
`date "+%FT%T.%3N"`: Completed running $cmd (rc=$rc)
|
|
############################################################
|
|
|
|
EOF
|
|
done
|
|
|
|
cat <<EOF >>$SCRIPTLOG
|
|
|
|
`date "+%FT%T.%3N"`: Completed running scripts with $FAILURES failures
|
|
############################################################
|
|
EOF
|
|
|
|
exit $FAILURES
|