码迷,mamicode.com
首页 > Web开发 > 详细

shell脚本   http源码启动脚本

时间:2016-08-06 07:10:18      阅读:196      评论:0      收藏:0      [点我收藏+]

标签:http启动脚本

源码包http启动脚本,仅供参考......下面有文本的。

技术分享技术分享技术分享

技术分享

#!/bin/bash

#Author: wangergui              Email:291131893@qq.com         Date:2016-06-01

#Function: source apache start script

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root:/bin

export PATH

[ -f /etc/rc.d/init.d/functions ] && . /etc/rc.d/init.d/functions || exit 2

APACHE=/usr/local/apache2/bin/apachectl

PIDFILE=/usr/local/apache2/logs/httpd.pid

CODE=$(curl -I -s http://localhost |awk ‘NR==1 {print $2}‘)

function mystart () {

if [ ${CODE} -eq 200 -a -f ${PIDFILE} ];then 

   echo " httpd is aready running!"

 else

   rm -rf ${PIDFILE} && ${APACHE} && [ $? -eq 0 ] && echo "httpd start sucellfully!" || exit 3

fi


}

function mystop () {

wget -q http://localhost >/dev/null 2>&1

if [ $? -eq 0 -a -f ${PIDFILE} ];then

   killall -9 httpd 

   [ $? -eq 0 ] && echo "httpd stop ok"

 else

   rm -rf ${PIDFILE} && echo "httpd stop failed!"


fi

}

function myrestart () {


mystart

sleep 2

mystop



}

function myreload () {


wget -q http://localhost >/dev/null 2>&1


[ $? -eq 0 -f ${PIDFILE} ] && killall -s HUP ${APACHE} || exit 4


[ $? -ne 0 ] && echo "httpd service is not starting!"


}

function mystatus () {


wget -q http://localhost >/dev/null 2>&1


[ $? -eq 0 -a -f ${PIDFILE} ] && echo "httpd is running" || echo "httpd stop"



}

case $1 in


    "start")

           mystart

           ;;

                

    "stop")

           mystop

           ;;


    "restart")

           myrestart

           ;;


    "reload")

           myreload

           ;;


    "status")

           mystatus

           ;;


      "*")

          echo $"Usage: $0 {start|stop|restart|reload|status|}"

           exit 8

           ;;


esac


本文出自 “linux相关技术” 博客,谢绝转载!

shell脚本   http源码启动脚本

标签:http启动脚本

原文地址:http://wangergui.blog.51cto.com/8504247/1834888

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!