#!/bin/bash
local_ip=`/sbin/ifconfig |grep ‘inet addr:‘|grep -Ev ‘127.0.0.1‘ | cut -d: -f2|awk ‘{print $1}‘|head -n 1`
#install epel repo
rpm -Uvh http://apt.sw.be/redhat/el6/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
#install require software
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 echoping httpd httpd-devel gcc make wget libxml2-devel libpng-devel glib pango pango-devel freetype freetype-devel fontconfig cairo cairo-devel libart_lgpl libart_lgpl-devel mod_fastcgi wqy-zenhei-fonts
#install smokeping
wget http://oss.oetiker.ch/smokeping/pub/smokeping-2.6.8.tar.gz
tar zxvf smokeping-2.6.8.tar.gz
cd smokeping-2.6.8
./configure --prefix=/usr/local/smokeping
./setup/build-perl-modules.sh /usr/local/smokeping/thirdparty
./configure --prefix=/usr/local/smokeping
/usr/bin/gmake install
#modiy smokeping
cd /usr/local/smokeping
mkdir cache data var
touch /var/log/smokeping.log
chown apache:apache cache data var
chown apache:apache /var/log/smokeping.log
cd /usr/local/smokeping/htdocs/
mv smokeping.fcgi.dist smokeping.fcgi
cd /usr/local/smokeping/etc
wget -nc http://software-server.autoclouds.net/smokeping/config
sed -i ‘[email protected] = *@cgiurl = http://‘$local_ip‘/[email protected]‘ config
chmod 600 /usr/local/smokeping/etc/smokeping_secrets.dist
echo "admin:vD2G06D1xPoMQ">/usr/local/smokeping/htdocs/htpasswd
chmod 644 /usr/local/smokeping/htdocs/htpasswd
chown -R apache:apache /usr/local/smokeping
echo "/usr/local/smokeping/bin/smokeping --logfile=/var/log/smokeping.log 2>&1 &" >> /etc/rc.local
/usr/local/smokeping/bin/smokeping --logfile=/var/log/smokeping.log 2>&1 &
cat >>/etc/httpd/conf/httpd.conf<<EOF
ServerTokens Prod
ServerSignature Off
Alias /cache "/usr/local/smokeping/cache/"
Alias /cropper "/usr/local/smokeping/htdocs/cropper/"
Alias /smokeping "/usr/local/smokeping/htdocs/smokeping.fcgi"
<Directory "/usr/local/smokeping">
AllowOverride None
Options All
AddHandler cgi-script .fcgi .cgi
AllowOverride AuthConfig
Order allow,deny
Allow from all
AuthName "Smokeping"
AuthType Basic
AuthUserFile /usr/local/smokeping/htdocs/htpasswd
Require valid-user
DirectoryIndex smokeping.fcgi
</Directory>
EOF
/etc/init.d/httpd start
#ntpdate
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
ntpdate us.pool.ntp.org