Compare commits

...

12 Commits
2021 ... master

@ -15,3 +15,7 @@ copy-test:
copy:
rsync -avu /home/nagios/princeton/failover/ /home/nagios/bin/
release-%:
rm -f $@.zip
zip -r $@.zip colors.sh failover.sh nagios_startstop.sh rsync_xi.sh START STOP SYNC local/

@ -69,10 +69,6 @@ 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
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
fi
}
do_secondary() {
@ -86,18 +82,22 @@ 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`)
[ -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
fullfile="/store/backups/nagiosxi/$syncfile"
if [ -f "$fullfile" ]; then
verbose " Sync file found ($fullfile). Continuing."
/home/nagios/bin/rsync_xi.sh --primary "${primary}" --secondary "${secondary}" --file "$fullfile"
else
warning " No sync file found. Continuing to activate Nagios."
fi
if [ $? -eq 0 ]; then
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 5
start_nagios
rm -f ${syncfile}
rm -f ${fullfile}
verbose "Done."
fi
}

@ -1,7 +0,0 @@
#header {
background: rgb(59,234,2);
background: -moz-linear-gradient(90deg, rgba(59,234,2,1) 0%, rgba(8,124,8,1) 35%);
background: -webkit-linear-gradient(90deg, rgba(59,234,2,1) 0%, rgba(8,124,8,1) 35%);
background: linear-gradient(90deg, rgba(59,234,2,1) 0%, rgba(8,124,8,1) 35%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr="#3bea02",endColorstr="#087c08",GradientType=1);
}

@ -1,7 +0,0 @@
#header {
background: rgb(0,0,255);
background: -moz-linear-gradient(90deg, rgba(0,0,255,1) 0%, rgba(0,0,0,1) 50%);
background: -webkit-linear-gradient(90deg, rgba(0,0,255,1) 0%, rgba(0,0,0,1) 50%);
background: linear-gradient(90deg, rgba(0,0,255,1) 0%, rgba(0,0,0,1) 50%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr="#0000ff",endColorstr="#000000",GradientType=1);
}

@ -1,7 +0,0 @@
#header {
background: rgb(0,255,0);
background: -moz-linear-gradient(90deg, rgba(0,255,0,1) 0%, rgba(0,0,0,1) 50%);
background: -webkit-linear-gradient(90deg, rgba(0,255,0,1) 0%, rgba(0,0,0,1) 50%);
background: linear-gradient(90deg, rgba(0,255,0,1) 0%, rgba(0,0,0,1) 50%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr="#00ff00",endColorstr="#000000",GradientType=1);
}

@ -18,6 +18,7 @@ execute="-n"
syncfile=""
isP=/bin/false
isS=/bin/false
rsync_opts="-a --delete --delete-after"
# Import Nagios XI and xi-sys.cfg config vars
. $BASEDIR/../var/xi-sys.cfg
@ -117,11 +118,12 @@ workDir=$rootdir/$name
mkdir -p $workDir
do_rsync() {
verbose "Syncing $*..."
verbose "Syncing $1 (Excluding ${2:-nothing})..."
src="$1"
[ -n "$2" ] && exclude="--exclude $2" || exclude=""
[ ! -e "$src" ] && warning " OK: No such file or directory: $src" && return
[ -d "$src" ] && sudo rsync -a --delete --delete-after --rsync-path="sudo /bin/rsync" ${execute} ${src}/ nagios@${sName}:${src}/
[ -f "$src" ] && sudo rsync -a --delete --delete-after --rsync-path="sudo /bin/rsync" ${execute} ${src} nagios@${sName}:${src}
[ -d "$src" ] && sudo /usr/bin/rsync --rsync-path="sudo /bin/rsync" ${rsync_opts} ${exclude} ${execute} ${src}/ nagios@${sName}:${src}/
[ -f "$src" ] && sudo /usr/bin/rsync --rsync-path="sudo /bin/rsync" ${rsync_opts} ${exclude} ${execute} ${src} nagios@${sName}:${src}
}
do_backup_files() {
@ -150,7 +152,7 @@ do_rsync $httpdconfdir/nrdp.conf
do_rsync $httpdconfdir/ssl.conf
do_rsync /usr/local/nagios
do_rsync /usr/local/nagiosmobile
do_rsync /usr/local/nagiosxi
do_rsync /usr/local/nagiosxi custom-includes/css/
do_rsync /usr/local/nagvis
do_rsync /usr/local/nrdp
do_rsync /usr/share/snmp
@ -158,7 +160,6 @@ do_rsync /var/lib/mrtg
do_rsync /var/spool/cron/apache
do_rsync /var/spool/cron/crontabs/$apacheuser
} # End of do_backup_files
do_backup_sql() {
@ -344,12 +345,16 @@ do
x=$(($x+1))
done
# Save old Program URL
old_url=$(echo "select value from xi_options where name='url'" | mysql -h "$ndoutils_dbserver" --port="$ndoutils_dbport" -u root --password=$mysqlpass -N nagiosxi)
mysql -h "$ndoutils_dbserver" --port="$ndoutils_dbport" -u root --password=$mysqlpass < $backupdir/mysql/nagios.sql
res=$?
if [ $res != 0 ]; then
error "Error restoring MySQL database 'nagios'"
exit 1
fi
# Restore old Program URL
echo "update xi_options set value='$old_url' where name='url'" | mysql -h "$ndoutils_dbserver" --port="$ndoutils_dbport" -u root --password=$mysqlpass -N nagiosxi
if [[ "$cfg__db_info__nagiosql__dbserver" == *":"* ]]; then
nagiosql_dbport=`echo "$cfg__db_info__nagiosql__dbserver" | cut -f2 -d":"`

Loading…
Cancel
Save