Created
March 3, 2016 15:28
-
-
Save alvarow/03ea1047d6f16276b562 to your computer and use it in GitHub Desktop.
Apache init script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
# | |
### BEGIN INIT INFO | |
# Provides: Apache | |
# Required-Start: $network | |
# Required-Stop: | |
# Default-Start: 3 5 | |
# Default-Stop: | |
# Description: Apache Web Server | |
### END INIT INFO | |
# Shell functions sourced from /etc/rc.status: | |
# rc_check check and set local and overall rc status | |
# rc_status check and set local and overall rc status | |
# rc_status -v ditto but be verbose in local rc status | |
# rc_status -v -r ditto and clear the local rc status | |
# rc_failed set local and overall rc status to failed | |
# rc_failed <num> set local and overall rc status to <num><num> | |
# rc_reset clear local rc status (overall remains) | |
# rc_exit exit appropriate to overall rc status | |
. /etc/rc.status | |
# First reset status of this service | |
rc_reset | |
# Return values acc. to LSB for all commands but status: | |
# 0 - success | |
# 1 - generic or unspecified error | |
# 2 - invalid or excess argument(s) | |
# 3 - unimplemented feature (e.g. "reload") | |
# 4 - insufficient privilege | |
# 5 - program is not installed | |
# 6 - program is not configured | |
# 7 - program is not running | |
case "$1" in | |
start) | |
echo -n "Starting Apache Webserver (/opt/apache) " | |
#chattr -R +A /opt/apache/htdocs/ | |
/opt/apache/bin/apachectl start | |
rc_status -v -r | |
;; | |
startssl) | |
echo -n "Starting Apache Webserver with SSL (/opt/apache) " | |
#chattr -R +A /opt/apache/htdocs/ | |
/opt/apache/bin/apachectl startssl | |
rc_status -v -r | |
;; | |
stop) | |
echo -n "Shutting down Apache Webserver " | |
/opt/apache/bin/apachectl stop | |
rc_status -v -r | |
;; | |
reload|restart) | |
echo -n "Reloading Apache Webserver (graceful)" | |
/opt/apache/bin/apachectl graceful | |
rc_status -v -r | |
;; | |
status) | |
# this requires lynx installed | |
/opt/apache/bin/apachectl status | |
;; | |
configtest) | |
/opt/apache/bin/apachectl configtest | |
;; | |
*) | |
echo "Usage: $0 {start|startssl|stop|status|reload|configtest}" | |
exit 3 | |
;; | |
esac | |
rc_exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment