Remove -f option as rc_fast is not set in invocation mode.
Do the load_rc_config *after* option parsing. Catch conflicting -e + -l option specs.
This commit is contained in:
parent
a37502b2b6
commit
baf9344e28
@ -1,5 +1,5 @@
|
||||
#!/bin/sh
|
||||
# $NetBSD: service,v 1.3 2015/03/22 22:39:05 wiz Exp $
|
||||
# $NetBSD: service,v 1.4 2015/03/23 23:28:55 ast Exp $
|
||||
# service -- run or list system services
|
||||
#
|
||||
# Taken from FreeBSD: releng/10.1/usr.sbin/service/service.sh 268098
|
||||
@ -31,21 +31,17 @@
|
||||
|
||||
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
|
||||
|
||||
. /etc/rc.subr
|
||||
load_rc_config 'XXX'
|
||||
|
||||
usage ()
|
||||
{
|
||||
local me=${0##*/}
|
||||
echo "usage: ${me} [-elv]"
|
||||
echo " ${me} [-ev] rc_script_name [rc_script_name2 [...]]"
|
||||
echo " ${me} [-fv] rc_script_name action"
|
||||
echo " ${me} [-v] rc_script_name action"
|
||||
echo " -e: List enabled scripts; check if given scripts are enabled"
|
||||
echo " -f: Set rc_fast=yes when running rc_script_name action"
|
||||
echo " -l: List all scripts in rcorder"
|
||||
echo " -v: Verbose (mention in which directory script is found)"
|
||||
echo "rc_directories is currently set to ${rc_directories}"
|
||||
return 0
|
||||
exit 1
|
||||
}
|
||||
|
||||
rc_files()
|
||||
@ -57,16 +53,20 @@ rc_files()
|
||||
return 0
|
||||
}
|
||||
|
||||
while getopts elvf o; do
|
||||
while getopts elv o; do
|
||||
case $o in
|
||||
e) ENABLED=1 ;;
|
||||
l) LIST=1 ;;
|
||||
v) VERBOSE=1 ;;
|
||||
e) ENABLED=1 ;;
|
||||
f) rc_fast=yes ;;
|
||||
*) usage ; exit 1 ;;
|
||||
*) usage ;;
|
||||
esac
|
||||
done
|
||||
shift $(( ${OPTIND} - 1 ))
|
||||
shift $( expr $OPTIND - 1 )
|
||||
|
||||
[ -n "${ENABLED}" -a -n "${LIST}" ] && usage
|
||||
|
||||
. /etc/rc.subr
|
||||
load_rc_config :
|
||||
|
||||
if [ -n "${ENABLED}" ]; then
|
||||
[ -n "${VERBOSE}" ] && echo "rc_directories is ${rc_directories}" >&2
|
||||
@ -97,7 +97,6 @@ if [ $# -eq 2 ]; then
|
||||
arg=$2
|
||||
else
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for dir in ${rc_directories}; do
|
||||
|
@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: service.8,v 1.2 2015/03/22 22:38:19 wiz Exp $
|
||||
.\" $NetBSD: service.8,v 1.3 2015/03/23 23:28:55 ast Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 2009 Douglas Barton
|
||||
.\" All rights reserved.
|
||||
@ -37,7 +37,7 @@
|
||||
.Op Fl ev
|
||||
.Ar rc_script_name Op Ar rc_script_name2 Op Ar ...
|
||||
.Nm
|
||||
.Op Fl fv
|
||||
.Op Fl v
|
||||
.Ar rc_script_name action
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
@ -54,7 +54,7 @@ scripts,
|
||||
.Nm
|
||||
will set the same environment that is used at boot time.
|
||||
.Pp
|
||||
The following options are supported:
|
||||
The options are as follows:
|
||||
.Bl -tag -width F1
|
||||
.It Fl e
|
||||
List services that are enabled.
|
||||
@ -72,12 +72,6 @@ are specified, only those are checked.
|
||||
The
|
||||
.Ar rc_script_name
|
||||
arguments are always specified without a path prefix.
|
||||
.It Fl f
|
||||
Set
|
||||
.Sy rc_fast=yes
|
||||
to speed up the
|
||||
.Ev rc.d script; that is, run it as it is run during
|
||||
.Sq autoboot .
|
||||
.It Fl l
|
||||
List all files in
|
||||
.Pa /etc/rc.d
|
||||
@ -128,20 +122,23 @@ or any other argument supported by the
|
||||
These are typical usages of the
|
||||
.Nm
|
||||
command:
|
||||
.Pp
|
||||
.Dl "# service sshd restart"
|
||||
.Dl "Stopping sshd."
|
||||
.Dl "Starting sshd."
|
||||
.Pp
|
||||
.Dl "$ service -v inetd status"
|
||||
.Dl "inetd is located in /etc/rc.d"
|
||||
.Dl "inetd is running as pid 1713."
|
||||
.Pp
|
||||
.Dl "$ service -vfe ccd motd hostapd my_pkg"
|
||||
.Dl "rc_directories is /etc/rc.d /usr/pkg/etc/rc.d"
|
||||
.Dl "/etc/rc.d/ccd"
|
||||
.Dl "/usr/pkg/etc/rc.d/my_pkg"
|
||||
.Dl "/etc/rc.d/motd"
|
||||
.Bd -literal
|
||||
# service sshd restart
|
||||
Stopping sshd.
|
||||
Starting sshd.
|
||||
.Ed
|
||||
.Bd -literal
|
||||
$ service -v inetd status
|
||||
inetd is located in /etc/rc.d
|
||||
inetd is running as pid 1713.
|
||||
.Ed
|
||||
.Bd -literal
|
||||
$ service -ve ccd motd hostapd my_pkg
|
||||
rc_directories is /etc/rc.d /usr/pkg/etc/rc.d
|
||||
/etc/rc.d/ccd
|
||||
/usr/pkg/etc/rc.d/my_pkg
|
||||
/etc/rc.d/motd
|
||||
.Ed
|
||||
.Pp
|
||||
In the last example,
|
||||
.Xr hostapd 8
|
||||
|
Loading…
Reference in New Issue
Block a user