{"id":3305,"date":"2014-07-06T11:05:33","date_gmt":"2014-07-06T03:05:33","guid":{"rendered":"http:\/\/rmohan.com\/?p=3305"},"modified":"2014-07-06T11:05:33","modified_gmt":"2014-07-06T03:05:33","slug":"redhat-init-script-for-apache","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=3305","title":{"rendered":"Redhat init Script  for apache"},"content":{"rendered":"<pre style=\"color: #000000; text-transform: none; line-height: normal; text-indent: 0px; letter-spacing: normal; font-style: normal; font-variant: normal; font-weight: normal; word-spacing: 0px; white-space: pre-wrap; -ms-word-wrap: break-word; -webkit-text-stroke-width: 0px;\">#!\/bin\/sh\r\n#\r\n# Startup script for the Apache Web Server\r\n#\r\n# chkconfig: - 85 15\r\n# description: Apache is a World Wide Web server.  It is used to serve \\\r\n#              HTML files and CGI.\r\n# processname: httpd\r\n# pidfile: \/var\/run\/httpd.pid\r\n# config: \/etc\/httpd\/conf\/access.conf\r\n# config: \/etc\/httpd\/conf\/httpd.conf\r\n# config: \/etc\/httpd\/conf\/srm.conf\r\n\r\nulimit -HSn 32768\r\n\r\n# Source function library.\r\n. \/usr\/local\/etc\/rc.d\/functions\r\n\r\n# This will prevent initlog from swallowing up a pass-phrase prompt if\r\n# mod_ssl needs a pass-phrase from the user.\r\nINITLOG_ARGS=\"\"\r\n\r\n# Path to the apachectl script, server binary, and short-form for messages.\r\napachectl=\/usr\/sbin\/apachectl\r\nhttpd=\/usr\/sbin\/httpd\r\nprog=httpd\r\nRETVAL=0\r\nPIDFILE=\/var\/run\/httpd.pid\r\n\r\n# check for 1.3 configuration\r\ncheck13 () {\r\n        CONFFILE=\/etc\/httpd\/conf\/httpd.conf\r\n        GONE=\"(ServerType|BindAddress|Port|AddModule|ClearModuleList|\"\r\n        GONE=\"${GONE}AgentLog|RefererLog|RefererIgnore|FancyIndexing|\"\r\n        GONE=\"${GONE}AccessConfig|ResourceConfig)\"\r\n        if grep -Eiq \"^[[:space:]]*($GONE)\" $CONFFILE; then\r\n                echo\r\n                echo 1&gt;&amp;2 \" Apache 1.3 configuration directives found\"\r\n                echo 1&gt;&amp;2 \" please read @docdir@\/migration.html\"\r\n                failure \"Apache 1.3 config directives test\"\r\n                echo\r\n                exit 1\r\n        fi\r\n}\r\n\r\n# The semantics of these two functions differ from the way apachectl does\r\n# things -- attempting to start while running is a failure, and shutdown\r\n# when not running is also a failure.  So we just do it the way init scripts\r\n# are expected to behave here.\r\nstart() {\r\n        echo -n \"Starting $prog: \"\r\n\tcheck13 || exit 1\r\n        daemon $httpd -k start -DSSL\r\n        RETVAL=$?\r\n        if [ $RETVAL = 0 ] &amp;&amp; touch \/var\/spool\/lock\/httpd\r\n        then\r\n                echo -e \"\\t[ OK ]\";\r\n        else\r\n                echo -e \"\\t[ FAILED ]\";\r\n        fi\r\n        return $RETVAL\r\n}\r\nwaitforexit() {\r\n        count=${2:-30}\r\n        while [ 0$count -gt 0 ]\r\n        do\r\n                PIDS=`ps -ax | grep -v grep | grep -c \/usr\/sbin\/httpd` || break\r\n                echo Remaining processes: $PIDS\r\n                stop\r\n                sleep 2\r\n                count=`expr $count - 1`\r\n        done\r\n        if [ 0$count -eq 0 ];\r\n        then\r\n                echo Remaining processes: $PIDS\r\n                return 1\r\n        fi\r\n        return 0\r\n}\r\nstop() {\r\n        echo -n \"Stopping $prog: \"\r\n        killall $prog 2&gt; \/dev\/null\r\n        RETVAL=$?\r\n        if [ $RETVAL = 0 ] &amp;&amp; rm -f \/var\/spool\/lock\/httpd $PIDFILE\r\n        then\r\n                echo -e \"\\t[ OK ]\";\r\n        else\r\n                echo -e \"\\t[ FAILED ]\";\r\n        fi\r\n}\r\nreload() {\r\n        echo -n \"Reloading $prog: \"\r\n\tcheck13 || exit 1\r\n        killall -HUP $prog\r\n        RETVAL=$?\r\n        if [ $RETVAL = 0 ]\r\n        then\r\n                echo -e \"\\t[ OK ]\";\r\n        else\r\n                echo -e \"\\t[ FAILED ]\";\r\n        fi\r\n}\r\n\r\n# See how we were called.\r\ncase \"$1\" in\r\n  start)\r\n        start\r\n        ;;\r\n  stop)\r\n        stop\r\n        ;;\r\n  status)\r\n        status $httpd\r\n        RETVAL=$?\r\n        ;;\r\n  restart)\r\n        stop\r\n\twaitforexit \"httpd\" 20\r\n        start\r\n        ;;\r\n  condrestart)\r\n        if [ -f $PIDFILE ] ; then\r\n                stop\r\n                start\r\n        fi\r\n        ;;\r\n  reload)\r\n        reload\r\n        ;;\r\n  help|configtest|graceful|fullstatus)\r\n        $apachectl $@\r\n        RETVAL=$?\r\n        ;;\r\n  test)\r\n        echo `moduleargs`;\r\n        ;;\r\n  *)\r\n        echo $\"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}\"\r\n        exit 1\r\nesac\r\n\r\nexit $RETVAL\r\n<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>#!\/bin\/sh # # Startup script for the Apache Web Server # # chkconfig: &#8211; 85 15 # description: Apache is a World Wide Web server. It is used to serve \\ # HTML files and CGI. # processname: httpd # pidfile: \/var\/run\/httpd.pid # config: \/etc\/httpd\/conf\/access.conf # config: \/etc\/httpd\/conf\/httpd.conf # config: \/etc\/httpd\/conf\/srm.conf ulimit -HSn 32768 # [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,47],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/3305"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3305"}],"version-history":[{"count":1,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/3305\/revisions"}],"predecessor-version":[{"id":3306,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/3305\/revisions\/3306"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3305"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3305"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3305"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}