3 # Copyright (c) 2017 Wind River Systems, Inc.
5 # SPDX-License-Identifier: Apache-2.0
9 # The patching subsystem provides a patch-functions bash source file
10 # with useful function and variable definitions.
12 . /etc/patching/patch-functions
15 # We can now check to see what type of node we're on, if it's locked, etc,
20 # Declare an overall script return code
22 declare -i GLOBAL_RC=$PATCH_STATUS_OK
25 # handle restarting horizon.
29 # Horizon only runs on the controller
31 if [ ! -f $PATCH_FLAGDIR/horizon.restarted ]
33 # Check SM to see if Horizon is running
34 sm-query service horizon | grep -q 'enabled-active'
37 loginfo "$0: Logging out all horizon sessions"
40 rm -f /var/tmp/sessionid*
42 loginfo "$0: Restarting horizon"
44 # Ask SM to restart Horizon
45 sm-restart service horizon
46 touch $PATCH_FLAGDIR/horizon.restarted
48 # Wait up to 30 seconds for service to recover
49 let -i UNTIL=$SECONDS+30
50 while [ $UNTIL -ge $SECONDS ]
52 # Check to see if it's running
53 sm-query service horizon | grep -q 'enabled-active'
59 # Still not running? Let's wait 5 seconds and check again
63 sm-query service horizon | grep -q 'enabled-active'
66 # Still not running! Clear the flag and mark the RC as failed
67 loginfo "$0: Failed to restart horizon"
68 rm -f $PATCH_FLAGDIR/horizon.restarted
69 GLOBAL_RC=$PATCH_STATUS_FAILED
70 sm-query service horizon
77 # Exit the script with the overall return code