From b026318d3c699555d8b5c45bdc14243b3bfd5e6d Mon Sep 17 00:00:00 2001 From: jlam Date: Wed, 26 Dec 2001 22:03:38 +0000 Subject: Vastly simplify this script by using /etc/rc.subr. Provide minimal start functionality on pre-1.5 platforms, as apachectl may always be used instead for the full control interface. --- www/apache/files/apache.sh | 79 ++++++++++------------------------------------ 1 file changed, 17 insertions(+), 62 deletions(-) (limited to 'www/apache') diff --git a/www/apache/files/apache.sh b/www/apache/files/apache.sh index 3bd20dd9e7e..7e5db5799bc 100644 --- a/www/apache/files/apache.sh +++ b/www/apache/files/apache.sh @@ -1,6 +1,6 @@ #!/bin/sh # -# $NetBSD: apache.sh,v 1.14 2001/11/26 07:34:06 jlam Exp $ +# $NetBSD: apache.sh,v 1.15 2001/12/26 22:03:38 jlam Exp $ # # PROVIDE: apache # REQUIRE: DAEMON @@ -9,9 +9,15 @@ # To start apache at startup, copy this script to /etc/rc.d and set # apache=YES in /etc/rc.conf. +if [ -e /etc/rc.subr ] +then + . /etc/rc.subr +fi + name="apache" rcvar=$name -command="@PREFIX@/sbin/apachectl" +command="@PREFIX@/sbin/httpd" +ctl_command="@PREFIX@/sbin/apachectl" apache_start=start if [ -f @PKG_SYSCONFDIR@/apache_start.conf ] @@ -20,66 +26,15 @@ then . @PKG_SYSCONFDIR@/apache_start.conf fi -# set defaults -if [ -r /etc/rc.conf ] -then - . /etc/rc.conf -else - eval ${rcvar}=YES -fi +required_files="@PKG_SYSCONFDIR@/httpd.conf" +start_cmd="${ctl_command} ${apache_start}" +stop_cmd="${ctl_command} stop" +restart_cmd="${ctl_command} restart" -# $flags from environment overrides ${rcvar}_flags -if [ -n "${flags}" ] +if [ -e /etc/rc.subr ] then - eval ${rcvar}_flags="${flags}" -fi - -apache_doit() -{ - action=$1 - - case ${action} in - start) echo -n "Starting ${name}: "; action=${apache_start} ;; - stop) echo -n "Stopping ${name}: " ;; - restart) echo -n "Restarting ${name}: " ;; - esac - - ${command} ${apache_flags} ${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} is not set properly." - return 1 - ;; - esac -} - -cmd=${1:-start} -case ${cmd} in -force*) - cmd=${cmd#force} - eval ${rcvar}=YES - ;; -esac - -if checkyesno ${rcvar} -then - 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 + load_rc_config $name + run_rc_command "$1" +else + ${start_cmd} fi -- cgit v1.2.3