script for Nagios installation

#!/bin/bash
dir=/usr/local/nagios
wget http://osdn.dl.sourceforge.net/sourceforge/nagios/nagios-3.0.6.tar.gz
wget http://osdn.dl.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.11.tar.gz
mkdir -p $dir
grep -i “red hat” /etc/issue>/dev/null2>&1
if [ `echo $? ` = 0 ];then
useradd nagios
else
groupadd nagios
useradd -G nagios nagios
fi
tar xzf nagios-plugins-1.4.11.tar.gz
cd nagios-plugins-1.4.11
./configure –prefix=/usr/local/nagios –enable-redhat-pthread-workaround
make
make install
cd ..
tar xzf nagios-3.0.6.tar.gz
cd nagios-3.0.6
./configure –prefix=/usr/local/nagios
make install
make install-init
make install-config
make install-commandmode
make install-webconf
# make sure xinetd is installed.
echo ” nrpe      5666/tcp      #nrpe” >> /etc/services
chown -R nagios.nagios /usr/local/nagios
service xinetd restart
test=`/usr/local/nagios/libexec/check_nrpe -H 127.0.0.1`
teststr=”NRPE v2.8.1″
if [ "$test"="$teststr" ] ;then
echo -e “install success!!”
else
echo -e “install error!!!”
fi