diff --git a/failover/failover.sh b/failover/failover.sh index d1f2182..bf01c9e 100755 --- a/failover/failover.sh +++ b/failover/failover.sh @@ -18,6 +18,7 @@ secondary="" synconly="false" syncname="sync" extraCmd="" +cssDir="/usr/local/nagiosxi/html/includes/components/custom-includes/css/" hostname=`/bin/hostname` @@ -69,9 +70,10 @@ do_primary() { [ $? -ne 0 ] && error "Cannot ping ${secondary}. Use --noping to continue wihout ping." && exit verbose "Creating package to send to secondary" /home/nagios/bin/rsync_xi.sh --prepend ${syncname} --primary "${primary}" --secondary "${secondary}" $extraCmd - if [ -r "/usr/local/nagiosxi/html/includes/components/custom-includes/css/header-gradient.css.primary" -a -w "/usr/local/nagiosxi/html/includes/components/custom-includes/css/header-gradient.css" ]; then + # Update header.css with proper gradient files + if [ -r "${cssDir}/header.css.primary" -a -w "${cssDir}/header.css" ]; then verbose "Copying local gradient files" - cp /usr/local/nagiosxi/html/includes/components/custom-includes/css/header-gradient.css.primary /usr/local/nagiosxi/html/includes/components/custom-includes/css/header-gradient.css + cp ${cssDir}/header.css.primary ${cssDir}/header.css fi } @@ -91,13 +93,18 @@ do_secondary() { [ -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 + # Update header.css with proper gradient files + if [ -r "${cssDir}/header.css.secondary" -a -w "${cssDir}/header.css" ]; then + verbose "Copying local gradient files" + cp ${cssDir}/header.css.secondary ${cssDir}/header.css fi + verbose "Ensuring that xi.key file has proper permissions" 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 + verbose "***" + warning "***" + error "***" + warning "This is intended to be manually executed when needed, so we assume you want to start Nagios..." -n start_nagios rm -f ${syncfile} verbose "Done." diff --git a/failover/rsync_xi.sh b/failover/rsync_xi.sh index 9f599eb..d87fd25 100755 --- a/failover/rsync_xi.sh +++ b/failover/rsync_xi.sh @@ -500,9 +500,6 @@ do_secondary() { [ ! -r "$syncfile" ] && error "No sync file ($syncfile) found." && exit 2 restore_secondary "$syncfile" if [ $? -eq 0 ]; then - 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 rm -f ${syncfile} fi } # End of do_secondary