网络质量监控软件smokeping一键安装脚本
#!/bin/bash#--变量
err_echo(){
echo -e "\\033: $1 \\033[0m"
exit 1
}
info_echo(){
echo -e "\\033: $1 \\033[0m"
}
warn_echo(){
echo -e "\\033: $1 \\033[0m"
}
check_exit(){
if [ $? -ne 0 ]; then
err_echo "$1"
exit 1
fi
}
#临时关闭selinux
info_echo "disabled selinux...."
setenforce 0
#配置yum源
info_echo "config yum source....."
rpm -Uvh http://apt.sw.be/redhat/el6/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm 1>/dev/null
info_echo "setup tool pakeages...."
yum -y install wget1>/dev/null
check_exit
yum -y install perl perl-Net-Telnet perl-Net-DNS perl-LDAP perl-libwww-perl perl-RadiusPerl perl-IO-Socket-SSL perl-Socket6 perl-CGI-SpeedyCGI perl-FCGI perl-CGI-SpeedCGI perl-Time-HiRes perl-ExtUtils-MakeMaker perl-RRD-Simple rrdtool rrdtool-perl curl fping echopinghttpd httpd-devel gcc makewget libxml2-devel libpng-devel glib pango pango-devel freetype freetype-devel fontconfig cairo cairo-devel libart_lgpl libart_lgpl-devel mod_fastcgi 1>/dev/null
check_exit
if [ -f /root/smokeping-2.6.9.tar.gz ]; then
warn_echo "/root/smokeping-2.6.9.tar.gz is exist"
else
info_echo "download smokeping...."
wget http://oss.oetiker.ch/smokeping/pub/smokeping-2.6.9.tar.gz 1>/dev/null
fi
check_exit
if [ -f /usr/local/src/smokeping-2.6.9 ]; then
rm -rf /usr/local/src/smokeping-2.6.9
fi
info_echo "tar smokeping to /usr/local/src"
tar -xvf smokeping-2.6.9.tar.gz -C /usr/local/src1>/dev/null
if [ -f /usr/local/smokeping ]; then
mv /usr/local/smokepingsmokeping_back
fi
cd /usr/local/src/smokeping-2.6.9
info_echo "set up smokeping....."
./configure -prefix=/usr/local/smokeping 1>/dev/null
if [ $? -ne 0 ];then
echo -e "\\033[33m first setup faild \\033[0m"
info_echo " per handle symbiosis......"
./setup/build-perl-modules.sh /usr/local/smokeping/thirdparty1>/dev/null
check_exit
info_echo "full install smokeping....."
./configure -prefix=/usr/local/smokeping 1>/dev/null
/usr/bin/gmake install1>/dev/null
else
/usr/bin/gmake install1>/dev/null
check_exit
fi
cd /usr/local/smokeping
mkdir cache data var 1>/dev/null
check_exit
info_echo "chomod dir permission"
#修改目录权限
chown -R apache:apache cache data var htdocs
mv /usr/local/smokeping/htdocs/smokeping.fcgi.dist/usr/local/smokeping/htdocs/smokeping.fcgi
mv /usr/local/smokeping/etc/config.dist/usr/local/smokeping/etc/config
cp -f /usr/local/smokeping/etc/config /usr/local/smokeping/etc/config.back
info_echo "edit smokeping config....."
#修改smokeping配置文件
IP=`/sbin/ifconfig|sed -n '/inet addr/s/^[^:]*:\(\{7,15\}\) .*/\1/1p'|sed -n '1p'`
sed -i "/cgiurl/c cgiurl = http:\/\/$IP/smokeping.cgi" /usr/local/smokeping/etc/config
sed -i "/imgurl/c imgurl = http:\/\/$IP/cache"/usr/local/smokeping/etc/config
chmod 600 /usr/local/smokeping/etc/smokeping_secrets.dist
info_echo "edit httpd config....."
#修改apache配置文件
cp -rf /etc/httpd/conf/httpd.conf/etc/httpd/conf/httpd.conf.back
cat >> /etc/httpd/conf/httpd.conf
页:
[1]