close
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
轉載網址:http://forum.icst.org.tw/phpbb/viewtopic.php?t=14852
官方Demo網址:http://bandwidthd.sourceforge.net/demo/
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
echo -e "\033[31m"
echo -e " BandWidthD 2.0.1 Install Shell Script (CentOS 5.1) "
echo -e " by lu 2008/04/17 "
echo -e "\033[0m"


DEBUG=n

if [ "`cat /proc/version | grep centos | grep el5`" != "" ]; then
  OS="CentOS 5.x"
  echo "Detection your OS is CentOS 5.x"
else
  echo "[ERROR] Only Support CentOS 5.x"
  exit
fi

echo -e "\033[31m"
echo -e "############# Step ###############"
echo -e " ntpdate tick.stdtime.gov.tw "
echo -e "####################################"
echo -e "\033[0m"

echo -e "\033[32mKill nptd on running...\033[0m"
ProcessID="`ps aux | grep ntpd | awk '{print $2}' `"
for i in $ProcessID
do
  echo $i
  kill -9 $i
done
ntpdate tick.stdtime.gov.tw
if [ "$DEBUG" == "y" ]; then echo "Press any key to continue..." ; read ; fi

echo -e "\033[31m"
echo -e "############# Step ###############"
echo -e " yum -y install something"
echo -e "####################################"
echo -e "\033[0m"


echo -e "\033[32mKill yum on running...\033[0m"
ProcessID="`ps aux | grep yum | awk '{print $2}' `"
for i in $ProcessID
do
  echo $i
  kill -9 $i
done
echo -e "\033[32mCheck : libpcap-devel libpng-devel gd-devel gcc httpd \033[0m"

YUMARGS=""

if [ "`rpm -q libpcap-devel | grep not`" != "" ]; then
  YUMARGS="$YUMARGS libpcap-devel"
  echo "libpcap-devel not installed"
else     
  echo "libpcap-devel installed" 
fi 

if [ "`rpm -q libpng-devel | grep not`" != "" ]; then
  YUMARGS="$YUMARGS libpng-devel"
  echo "libpng-devel not installed"
else
  echo "libpng-devel installed" 
fi 

if [ "`rpm -q gd-devel | grep not `" != "" ]; then
  YUMARGS="$YUMARGS gd-devel"
  echo "gd-devel not installed"
else 
  echo "gd-devel installed"
fi 

if [ "`rpm -q gcc | grep not `" != "" ]; then
  YUMARGS="$YUMARGS gcc"
  echo "gcc not installed"
else
  echo "gcc installed" 
fi

if [ "`rpm -q httpd | grep not`" != "" ]; then
  YUMARGS="$YUMARGS httpd"
  echo "httpd not installed"
else
  echo "httpd installed" 
fi

#echo $YUMARGS

if [ ! "$YUMARGS" == "" ]; then
  rm -fr /var/cache/yum
  echo -e "\033[32myum -y install $YUMARGS \033[0m" 
  yum -y install $YUMARGS
fi

echo -e "\033[31m"
echo -e "############# Step ###############"
echo -e " Install and Set BandWidthD"
echo -e "####################################"
echo -e "\033[0m"

if [ ! -s bandwidthd-2.0.1.gz ]; then
  echo "bandwidth-2.0.1.gz not found ! Please download from http://bandwidthd.sourceforge.net/ "
  exit
else
  echo "bandwidth-2.0.1.gz found !"
  echo " "
fi

echo -e "\033[32mtar zxvf bandwidthd-2.0.1.gz \033[0m"
tar zxvf bandwidthd-2.0.1.gz

echo -e "\033[32mcd bandwidthd-2.0.1 \033[0m"
cd bandwidthd-2.0.1
pwd

echo -e "\033[32m./configure \033[0m"
./configure

echo -e "\033[32mmake \033[0m"
make

echo -e "\033[32mmake install \033[0m"
make install

echo -e "\033[32mvi /etc/httpd/conf.d/bandwidthd.conf \033[0m"

echo "Alias /bandwidthd /usr/local/bandwidthd/htdocs"  >  /etc/httpd/conf.d/bandwidthd.conf
echo "<Location /bandwidthd>"  >>  /etc/httpd/conf.d/bandwidthd.conf
echo "    Order deny,allow"  >>  /etc/httpd/conf.d/bandwidthd.conf
echo "#    Deny from all"  >>  /etc/httpd/conf.d/bandwidthd.conf
echo "    Allow from 127.0.0.1"  >>  /etc/httpd/conf.d/bandwidthd.conf
echo "    Allow from ::1"  >>  /etc/httpd/conf.d/bandwidthd.conf
echo "    # Allow from .example.com"  >>  /etc/httpd/conf.d/bandwidthd.conf
echo "</Location>"  >>  /etc/httpd/conf.d/bandwidthd.conf

if [ "$DEBUG" == "y" ]; then echo "Press any key to continue..." ; read ; fi

echo -e "\033[31m"
echo -e "############# Step ###############"
echo -e " Run bandwidthd "
echo -e "####################################"
echo -e "\033[0m"

echo -e "\033[32mchkconfig httpd on \033[0m"
chkconfig httpd on
echo -e "\033[32mservice httpd start \033[0m"
service httpd start
echo

echo -e "\033[32mBandWidthD Config : /usr/local/bandwidthd/etc/bandwidthd.conf \033[0m"
echo -e "\033[32m                    modify subnet \033[0m"
echo -e "\033[32mhttpd Config : /etc/httpd/conf.d/bandwidthd.conf \033[0m"
echo

echo -e "\033[32mkillall bandwidthd \033[0m"
killall bandwidthd

echo -e "\033[32mcd /usr/local/bandwidthd \033[0m"
# You must run bandwidthd on special directory, else index.html will be generated on other directory
cd /usr/local/bandwidthd
pwd
echo -e "\033[32m/usr/local/bandwidthd/bandwidthd \033[0m"
/usr/local/bandwidthd/bandwidthd

echo -e "\033[32mfirefox http://localhost/bandwidthd & \033[0m"
firefox http://localhost/bandwidthd &
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 里歐 的頭像
    里歐

    里歐's 布拉格

    里歐 發表在 痞客邦 留言(0) 人氣()