diff options
author | jlam <jlam@pkgsrc.org> | 2001-05-08 18:13:51 +0000 |
---|---|---|
committer | jlam <jlam@pkgsrc.org> | 2001-05-08 18:13:51 +0000 |
commit | 5f9dd5a24ffbeb7d8c7a768be0994582fd7717c5 (patch) | |
tree | d55e7743c6d7c233190fccaaf6f6685e2d1aaf17 /www/apache6 | |
parent | a7a1b31121492116dee3cc5407984f0f5c14b785 (diff) | |
download | pkgsrc-5f9dd5a24ffbeb7d8c7a768be0994582fd7717c5.tar.gz |
Improve rc.d-style startup script. It now respects settings in
/etc/rc.conf (apache=YES/NO and apache_start=startssl) if it exists.
Diffstat (limited to 'www/apache6')
-rw-r--r-- | www/apache6/files/apache.sh | 86 |
1 files changed, 51 insertions, 35 deletions
diff --git a/www/apache6/files/apache.sh b/www/apache6/files/apache.sh index 5bb2bd66153..870057d3638 100644 --- a/www/apache6/files/apache.sh +++ b/www/apache6/files/apache.sh @@ -1,16 +1,17 @@ -#! /bin/sh +#!/bin/sh # -# $NetBSD: apache.sh,v 1.7 2001/04/29 21:21:13 jlam Exp $ +# $NetBSD: apache.sh,v 1.8 2001/05/08 18:13:52 jlam Exp $ # # PROVIDE: apache # REQUIRE: DAEMON +# KEYWORD: shutdown +# +# To start apache at startup, copy this script to /etc/rc.d and set +# apache=YES in /etc/rc.conf. name="apache" -ctl_command="@PREFIX@/sbin/apachectl" -command="@PREFIX@/sbin/httpd" -pidfile="/var/run/httpd.pid" - -apache_start="start" +rcvar=$name +command="@PREFIX@/sbin/apachectl" if [ -f @APACHE_SYSCONFDIR@/apache_start.conf ] then @@ -18,38 +19,53 @@ then . @APACHE_SYSCONFDIR@/apache_start.conf fi -cmd=${1:-start} - -if [ -x ${ctl_command} -a -x ${command} ] -then - case ${cmd} in - start) - echo "Starting ${name}." - ${ctl_command} ${apache_start} > /dev/null - ;; - - stop) - if [ -f ${pidfile} ] - then - echo "Stopping ${name}." - ${ctl_command} ${cmd} > /dev/null - fi - ;; +apache_doit() +{ + action=$1 - restart) - ( $0 stop ) - sleep 5 - $0 start - ;; + case ${action} in + start) echo -n "Starting ${name}: "; action=${apache_start} ;; + stop) echo -n "Stopping ${name}: " ;; + restart) echo -n "Restarting ${name}: " ;; + esac - status) - ${ctl_command} ${cmd} - ;; + ${command} ${command_args} ${action} +} +checkyesno() +{ + eval _value=\$${1} + case $_value in + [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) return 0 ;; + [Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0) return 1 ;; *) - echo 1>&2 "Usage: $0 [restart|start|stop|status]" - exit 1 + echo "\$${1} is not set properly." + return 1 ;; esac +} + +if [ -r /etc/rc.conf ] +then + . /etc/rc.conf +else + eval ${rcvar}=YES +fi + +if checkyesno ${rcvar} +then + cmd=${1:-start} + + if [ -x ${command} ] + then + case ${cmd} in + restart|start|stop|status) + ${rcvar}_doit ${cmd} + ;; + *) + echo 1>&2 "Usage: $0 [restart|start|stop|status]" + exit 1 + ;; + esac + fi fi -exit 0 |