From b5256e83eacadee8e28f08a9a66c24c57763810f Mon Sep 17 00:00:00 2001 From: Eric Loyd Date: Mon, 13 Jun 2022 14:13:42 -0400 Subject: [PATCH] Update failover/failover.sh Removed header.css code, added code to skip the sync if the sync file doesn't exist, and sleep for 2 seconds before trying to start Nagios. --- failover/failover.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/failover/failover.sh b/failover/failover.sh index d1f2182..7f889be 100755 --- a/failover/failover.sh +++ b/failover/failover.sh @@ -86,18 +86,21 @@ do_secondary() { warning "The primary (${primary}) is on the network but --force specified. Proceeding anyway." fi fi - verbose "Expanding package from the primary" + verbose "Checking for package from the primary" syncfile=$(basename `ls -tr1 ${backupDir}/${syncname}* | tail -1`) + if [ -r "$syncfile" ]; then + verbose " Sync file found (/store/backups/nagiosxi/$syncfile). Continuing." + /home/nagios/bin/rsync_xi.sh --primary "${primary}" --secondary "${secondary}" --file "/store/backups/nagiosxi/$syncfile" + else + warning " No sync file found. Continuing to activate Nagios." + fi [ -z "$syncfile" ] && error "No sync file ($syncfile) found." && exit 2 - /home/nagios/bin/rsync_xi.sh --primary "${primary}" --secondary "${secondary}" --file "/store/backups/nagiosxi/$syncfile" if [ $? -eq 0 ]; then sleep 2 - if [ -r "/usr/local/nagiosxi/html/includes/components/custom-includes/css/header-gradient.css.secondary" -a -w "/usr/local/nagiosxi/html/includes/components/custom-includes/css/header-gradient.css" ]; then - cp /usr/local/nagiosxi/html/includes/components/custom-includes/css/header-gradient.css.secondary /usr/local/nagiosxi/html/includes/components/custom-includes/css/header-gradient.css - fi chmod 0640 /usr/local/nagiosxi/var/keys/xi.key chown nagios:nagios /usr/local/nagiosxi/var/keys/xi.key verbose "This is intended to be manually executed when needed, so we assume you want to start Nagios..." -n + sleep 2 start_nagios rm -f ${syncfile} verbose "Done."