Chinaunix首页 | 论坛 | 博客
  • 博客访问: 711049
  • 博文数量: 160
  • 博客积分: 8847
  • 博客等级: 中将
  • 技术积分: 1656
  • 用 户 组: 普通用户
  • 注册时间: 2010-11-25 16:46
个人简介

。。。。。。。。。。。。。。。。。。。。。。

文章分类

全部博文(160)

文章存档

2015年(1)

2013年(1)

2012年(4)

2011年(26)

2010年(14)

2009年(36)

2008年(38)

2007年(39)

2006年(1)

分类: LINUX

2007-04-18 13:56:23

   简单部署脚本:

#!/bin/sh

echo "

#Include conf/extra/daily.conf

#Include conf/extra/emegency.conf" >> /usr/local/apache2/conf/httpd.conf

 

mkdir /usr/local/apache2/htdocs/daily

mkdir /usr/local/apache2/htdocs/emegency

 

touch /usr/local/apache2/conf/extra/daily.conf

touch /usr/local/apache2/conf/extra/emegency.conf

 

echo "

RewriteLog /usr/local/apache2/logs/rewrite.log

RewriteLoglevel 5

RewriteEngine on

RewriteRule ^/(.*)$ /usr/local/apache2/htdocs/daily/index.html" > /usr/local/apache2/conf/extra/daily.conf

 

echo "

RewriteLog /usr/local/apache2/logs/rewrite.log

RewriteLoglevel 3

RewriteEngine on

RewriteRule ^/(.*)$ /usr/local/apache2/htdocs/emegency/index.html" > /usr/local/apache2/conf/extra/emegency.conf

 

touch /usr/local/apache2/htdocs/daily/index.html

touch /usr/local/apache2/htdocs/emegency/index.html

 

/usr/local/apache2/bin/apachectl configtest

echo "daily page." > /usr/local/apache2/htdocs/daily/index.html

echo "emegency page." > /usr/local/apache2/htdocs/emegency/index.html

 

     切换脚本

 

#!/bin/sh

#This is used to Switch apache page for (daily/emergency/default)

 

Apache_dir="/usr/local/apacheweb";

BIN_dir="/usr/local/apacheweb/bin";

CONF_dir="/usr/local/apacheweb/conf";

#Date_time=`date +'%Y%m%d%H%M%S'`;

 

cp $CONF_dir/httpd.conf $CONF_dir/extra/httpd.conf.bak

 

#Timer()

#{

#s=0;

#while [ "$s" -lt 60 ]

#do

#        s=`expr $s + 1`;

#        sleep 1;

#        echo "remaining... $s seconds";

#done

#}

 

emegency_conf=`grep "Include conf/extra/emegency.conf" $CONF_dir/httpd.conf`;

daily_conf=`grep "Include conf/extra/daily.conf" $CONF_dir/httpd.conf`;

 

while [ -z "$emegency_conf" ] || [ -z "$daily_conf" ]

do

        if  [ -z "$emegency_conf" ]

        then

                echo "emegency_conf is not in $CONF_dir/httpd.conf";

                echo "Are you sure ADD following into $CONF_dir/httpd.conf(y/n)";

                echo "#Include conf/extra/emegency.conf";

                Timer;

                read yn;

                if [ $yn = 'y' ]

                then

                        echo "#Include conf/extra/emegency.conf" >> $CONF_dir/httpd.conf;

                fi

 

                if [ $yn = 'n' ]

                then

                        exit 0;

                fi

        fi

 

        if [ -z "$daily_conf" ]

        then

                echo "daily_conf is not in $CONF_dir/httpd.conf";

                echo "Are you sure ADD following into $CONF_dir/httpd.conf(y/n)";

                echo "#Include conf/extra/daily.conf";

                Timer;

                read yn;

                if [ $yn = 'y' ]

                then

                        echo "#Include conf/extra/daily.conf" >> $CONF_dir/httpd.conf;

                fi

 

                if [ $yn = 'n' ]

                then

                        exit 0;

                fi

        fi

 

        emegency_conf=`grep "Include conf/extra/emegency.conf" $CONF_dir/httpd.conf`;

        daily_conf=`grep "Include conf/extra/daily.conf" $CONF_dir/httpd.conf`;

done

 

Apache_conf_check()

{

        /usr/local/apacheweb/bin/apachectl configtest >/dev/null 2>&1;

        sytax_apache=$?;

        if [ "$sytax_apache" == "0" ]

        then

                return 0;

        else

                return 1;

        fi

}

 

Switch_e()

{

        Apache_conf_check;

        if [ "$?" == "0" ]

        then

                echo "$CONF_dir/httpd.conf's sytax is OK!"

                echo "Now,Apache will switch emegency page...";

                sed  -i 's/^#.*Include conf\/extra\/emegency.conf$/Include conf\/extra\/emegency.conf/' $CONF_dir/httpd.conf;

                sed  -i 's/^Include conf\/extra\/daily.conf$/#Include conf\/extra\/daily.conf/' $CONF_dir/httpd.conf;

                Apache_conf_check;

                if [ "$?" == "0" ]

                then

                        $BIN_dir/apachectl restart;

                        sleep 2;echo "Switch sucessful!!";

                else

                        echo "Apache' sytax is BAD.";

                fi

 

        else

                echo "$CONF_dir/httpd.conf's sytax is BAD,check it.

                      COMMAND: /usr/local/apacheweb/bin/apachectl configtest";

                mv $CONF_dir/extra/httpd.conf.bak $CONF_dir/httpd.conf;

                echo "Error:Not Switch";

        fi

}

 

Switch_d()

{

        Apache_conf_check;

        if [ "$?" == "0" ]

        then

                echo "$CONF_dir/httpd.conf's sytax is OK!"

                echo "Now,Apache will switch daily page...";

                sed  -i 's/^Include conf\/extra\/emegency.conf$/#Include conf\/extra\/emegency.conf/' $CONF_dir/httpd.conf;

                sed  -i 's/^#.*Include conf\/extra\/daily.conf$/Include conf\/extra\/daily.conf/' $CONF_dir/httpd.conf;

                Apache_conf_check;

                if [ "$?" == "0" ]

                then

                        $BIN_dir/apachectl restart;

                        sleep 2;echo "Switch sucessful!!";

                else

                        echo "Apache' sytax is BAD.";

                fi

 

        else

                echo "$CONF_dir/httpd.conf's sytax is BAD,check it.

                      COMMAND: /usr/local/apacheweb/bin/apachectl configtest";

                mv $CONF_dir/extra/httpd.conf.bak $CONF_dir/httpd.conf;

                echo "Error:Not Switch";

        fi

}

 

Switch_default()

{

        Apache_conf_check;

 

 

        if [ "$?" == "0" ]

        then

                echo "$CONF_dir/httpd.conf's sytax is OK!"

                echo "Now,Apache will switch default page...";

                sed  -i 's/^Include conf\/extra\/emegency.conf$/#Include conf\/extra\/emegency.conf/' $CONF_dir/httpd.conf;

                sed  -i 's/^Include conf\/extra\/daily\.conf$/#Include conf\/extra\/daily.conf/' $CONF_dir/httpd.conf;

                Apache_conf_check;

 

                if [ "$?" == "0" ]

                then

                        $BIN_dir/apachectl restart;

                        sleep 2;echo "Switch sucessful!!";

                else

                        echo "Apache' sytax is BAD.";

                fi

 

        else

                echo "$CONF_dir/httpd.conf's sytax is BAD,check it.

                      COMMAND: /usr/local/apacheweb/bin/apachectl configtest";

       

                mv $CONF_dir/extra/httpd.conf.bak $CONF_dir/httpd.conf;

                echo "Error:Not Switch";

        fi

 

}

case "$1" in

        e|emergency)

                Switch_e

        ;;

 

        d|daily)

                Switch_d;

        ;;

 

        default)

                Switch_default;

        ;;

 

        *)

                echo

                echo "Usge: Switch_apache.sh [e | d |default]";

                echo

                echo "----------------------switch----------------------";

                echo "1) ./Switch_apache.sh e/emergency (e:emergency page)";

                echo "2) ./Switch_apache.sh d/daily     (d:daily page)";

                echo "3) ./Switch_apache.sh default     (default:default page)";

                echo "--------------------------------------------------";

        exit 1;

esac

 

  在主控机上部署下面的脚本(这台机器到其他机器无密码登陆)

[root@fx-scr12 bin]# vi /export/home/dljroot/jhfsys/bin/Switch.sh

#!/bin/sh

 

IP_list="

10.9.30.11

10.9.30.12

10.9.30.13

10.9.30.14

10.9.30.15

10.9.30.16

10.9.30.21

10.9.30.41

10.9.30.42";

 

Front_ip="

10.9.30.11

10.9.30.12

10.9.30.13

10.9.30.14

10.9.30.15

10.9.30.16";

 

Mobile_ip="

10.9.30.41

10.9.30.42";

 

if [ "$1" != "" ]

then

        Stop_ip=$1;

else

#        echo "Usge: ./Switch.sh {[all | front | mobile | 10.9.30.x ]} {[e | d | default]}";

echo "./Switch.sh 10.9.30.x > "

echo "Example:"

echo "1)Switch default page!!"

echo " "

echo "./Switch.sh all default"

echo "./Switch.sh front default"

echo "./Switch.sh mobile default"

echo "./Switch.sh 10.9.30.x default"

echo " "

echo "2)Switch daily page!!"

echo " "

echo "./Switch.sh all d"

echo "./Switch.sh front d"

echo "./Switch.sh mobile d"

echo "./Switch.sh 10.9.30.x d"

echo " "

echo "3)switch emegency page!!"

echo " "

echo "./Switch.sh all e"

echo "./Switch.sh front e"

echo "./Switch.sh mobile e"

echo "./Switch.sh 10.9.30.x e"

        exit 1;

fi

 

if [ "$2" != "" ]

then

        Stop_type=$2;

else

        echo "Please use a Switch page:emegency?daily?OR default page.";

        echo "Example:";

        echo "1)./Switch 10.9.30.11 e";

        echo "2)./Switch.sh all e/emergency (e:emergency page)";

        echo "3)./Switch.sh mobile d/daily     (d:daily page)";

        echo "4)./Switch.sh front default     (default:default page)";

        exit 1;

fi

 

case "$Stop_ip" in

        all)

        for ip in $IP_list

        do

                echo "$ip is Switching... to $Stop_type";

                ssh dljroot@$ip -- "sh /export/home/dljroot/jhfsys/bin/Switch_apache.sh $Stop_type";

                if [ "$?" = "0" ]

                then

                        echo "$ip========================================>OK";

                else

                        echo "$ip========================================>FALSE";

                fi

        done

        ;;

       

        front)

        for ip in $Front_ip

        do

                echo "$ip is Switching... to $Stop_type";

                ssh dljroot@$ip -- "sh /export/home/dljroot/jhfsys/bin/Switch_apache.sh $Stop_type";

                if [ "$?" = "0" ]

                then

                        echo "$ip========================================>OK";

                else

                        echo "$ip========================================>FALSE";

                fi

        done

        ;;

 

        mobile)

        for ip in $Mobile_ip

        do

                echo "$ip is Switching... to $Stop_type";

                ssh dljroot@$ip -- "sh /export/home/dljroot/jhfsys/bin/Switch_apache.sh $Stop_type";

                if [ "$?" = "0" ]

                then

                        echo "$ip========================================>OK";

                else

                        echo "$ip========================================>FALSE";

                fi

        done

        ;;

 

        10.9.30.11|10.9.30.12|10.9.30.13|10.9.30.14|10.9.30.15|10.9.30.16|10.9.30.41|10.9.30.42)

        for ip in $Stop_ip

        do

                echo "$ip is Switching... to $Stop_type";

                ssh dljroot@$ip -- "sh /export/home/dljroot/jhfsys/bin/Switch_apache.sh $Stop_type";

                if [ "$?" = "0" ]

                then

                        echo "$ip========================================>OK";

                else

                        echo "$ip========================================>FALSE";

                fi

        done

        ;;

 

        *)

        echo "Please use a Switch page:emegency?daily?OR default page.";

        echo "Example:";

        echo "1)./Switch 10.9.30.11 e";

        echo "2)./Switch.sh all e/emergency (e:emergency page)";

        echo "3)./Switch.sh mobile d/daily     (d:daily page)";

        echo "4)./Switch.sh front default     (default:default page)";

        exit 0;

        ;;

esac

阅读(1816) | 评论(0) | 转发(0) |
0

上一篇:AS4上安装Oracle 9i

下一篇:Oracle 9i R2 Import

给主人留下些什么吧!~~