diff options
author | jlam <jlam@pkgsrc.org> | 2001-12-26 22:03:38 +0000 |
---|---|---|
committer | jlam <jlam@pkgsrc.org> | 2001-12-26 22:03:38 +0000 |
commit | 049ae3fcc4a93a6b7e632e1a14aeac982644d5fe (patch) | |
tree | 2c0985b616cb167cea278ebb415d36d7f9e3e809 /www | |
parent | da525c873fde86ade30d8a9ca981391369e5a302 (diff) | |
download | pkgsrc-049ae3fcc4a93a6b7e632e1a14aeac982644d5fe.tar.gz |
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.
Diffstat (limited to 'www')
-rw-r--r-- | www/apache/files/apache.sh | 79 | ||||
-rw-r--r-- | www/apache6/files/apache.sh | 79 |
2 files changed, 34 insertions, 124 deletions
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 diff --git a/www/apache6/files/apache.sh b/www/apache6/files/apache.sh index d8a2a50c68c..5c56ae0dd06 100644 --- a/www/apache6/files/apache.sh +++ b/www/apache6/files/apache.sh @@ -1,6 +1,6 @@ #!/bin/sh # -# $NetBSD: apache.sh,v 1.10 2001/11/26 07:34:07 jlam Exp $ +# $NetBSD: apache.sh,v 1.11 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 |