#!/bin/bash -e

destdir=/usr/local/nagios/libexec

echo "UPGRADE: Extra Plugins are being upgraded..."

cp -r plugins/* "$destdir"
cp -r proy_plugins/*.pl "$destdir"
cp -r rrdtraf-v0.1/check_rrdtraf-v0.1.php "$destdir/check_rrdtraf.php"
cp -r check_rrdtraf-0.5/check_rrdtraf "$destdir"
cp -r check_postgres-2.12.0/check_postgres.pl "$destdir"

# Do the check_mysql_health magic
(
	cd ./check_mysql_health-2.1.8.2
	./configure # Have to configure to make makefile to make clean. arg.
	make clean
	./configure
	make
)

# Install Nagios::Monitoring::Plugin
(
   tar xzf Nagios-Monitoring-Plugin-0.51.tar.gz
   cd Nagios-Monitoring-Plugin-0.51
   perl Makefile.PL
   make
   make test
   make install
)

cp -r check_mysql_health-2.1.8.2/plugins-scripts/check_mysql_health "$destdir"

echo "UPGRADE: Extra Plugins upgraded OK."
