From 4dd87ff9ce5cdb0966136070451af7e4a8aebc58 Mon Sep 17 00:00:00 2001 From: jlam Date: Tue, 8 May 2001 18:13:51 +0000 Subject: Improve rc.d-style startup script. It now respects settings in /etc/rc.conf (apache=YES/NO and apache_start=startssl) if it exists. --- www/apache/files/apache.sh | 86 +++++++++++++++++++++++++++------------------- 1 file changed, 51 insertions(+), 35 deletions(-) (limited to 'www/apache/files') diff --git a/www/apache/files/apache.sh b/www/apache/files/apache.sh index a7f00f27aa0..75dd6c8b500 100644 --- a/www/apache/files/apache.sh +++ b/www/apache/files/apache.sh @@ -1,16 +1,17 @@ -#! /bin/sh +#!/bin/sh # -# $NetBSD: apache.sh,v 1.11 2001/04/29 20:42:29 jlam Exp $ +# $NetBSD: apache.sh,v 1.12 2001/05/08 18:13:51 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 -- cgit v1.2.3