From ef0398bb7f5bb01023c610f0fed65025ccca6b7e Mon Sep 17 00:00:00 2001 From: Don Penney Date: Mon, 11 Mar 2019 13:28:33 -0400 Subject: [PATCH] Add failure checks to patching init script The sw-patch init script is called by the 'sw-patch install-local' command with a restart option to trigger the patch-agent to install patches, as there is no communications between the patch-agent and patch-controller at this point. However, the init script was not checking for failures reported by the patch-agent when it tries to install patches. In the case of #1819496, the lighttpd server was not running, due to a temporary config change at the time. As a result, the patch-agent was unable to communicate with the patching repo, and failed to install the patch. Because the init script was not checking for failures, the failure went unreported to the user. This update adds checks to the sw-patch init script, in order to report the failure back to the user. Change-Id: Id8d69bef3a5c6c2f81d56f4b26752d084f9a7ff2 Closes-Bug: 1819496 Signed-off-by: Don Penney --- cgcs-patch/bin/sw-patch-init.sh | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/cgcs-patch/bin/sw-patch-init.sh b/cgcs-patch/bin/sw-patch-init.sh index 53fbba29..f46cd4ed 100644 --- a/cgcs-patch/bin/sw-patch-init.sh +++ b/cgcs-patch/bin/sw-patch-init.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (c) 2014-2015 Wind River Systems, Inc. +# Copyright (c) 2014-2019 Wind River Systems, Inc. # # SPDX-License-Identifier: Apache-2.0 # @@ -14,6 +14,7 @@ NAME=$(basename $0) . /etc/platform/platform.conf logfile=/var/log/patching.log +patch_failed_file=/var/run/patch_install_failed function LOG_TO_FILE { echo "`date "+%FT%T.%3N"`: $NAME: $*" >> $logfile @@ -89,6 +90,7 @@ if [ ${FOUND} -eq 0 ]; then exit 1 fi +RC=0 case "$1" in start) if [ "${system_mode}" = "simplex" ]; then @@ -99,6 +101,10 @@ case "$1" in LOG_TO_FILE "***** Starting patch operation *****" /usr/sbin/sw-patch-agent --install 2>>$logfile + if [ -f ${patch_failed_file} ]; then + RC=1 + LOG_TO_FILE "***** Patch operation failed *****" + fi LOG_TO_FILE "***** Finished patch operation *****" LOG_TO_FILE "***** Shutting down lighttpd *****" @@ -112,6 +118,10 @@ case "$1" in LOG_TO_FILE "***** Starting patch operation *****" /usr/sbin/sw-patch-agent --install 2>>$logfile + if [ -f ${patch_failed_file} ]; then + RC=1 + LOG_TO_FILE "***** Patch operation failed *****" + fi LOG_TO_FILE "***** Finished patch operation *****" fi @@ -123,6 +133,10 @@ case "$1" in restart) LOG_TO_FILE "***** Starting patch operation *****" /usr/sbin/sw-patch-agent --install 2>>$logfile + if [ -f ${patch_failed_file} ]; then + RC=1 + LOG_TO_FILE "***** Patch operation failed *****" + fi LOG_TO_FILE "***** Finished patch operation *****" ;; *) @@ -130,5 +144,5 @@ case "$1" in exit 1 esac -exit 0 +exit $RC