Index: Makefile =================================================================== RCS file: /usr/share/cvs/freebsd/src/usr.sbin/Makefile,v retrieving revision 1.406 diff -u -r1.406 Makefile --- Makefile 23 Feb 2009 18:16:17 -0000 1.406 +++ Makefile 19 Mar 2009 18:34:40 -0000 @@ -162,6 +162,7 @@ ${_sa} \ ${_sade} \ ${_sendmail} \ + service \ setfib \ setfmac \ setpmac \ Index: service/Makefile =================================================================== RCS file: service/Makefile diff -N service/Makefile --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ service/Makefile 19 Mar 2009 18:37:01 -0000 @@ -0,0 +1,6 @@ +# $FreeBSD$ + +SCRIPTS= service.sh +MAN= service.8 + +.include Index: service/service.8 =================================================================== RCS file: service/service.8 diff -N service/service.8 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ service/service.8 19 Mar 2009 18:37:01 -0000 @@ -0,0 +1,53 @@ +.\" Copyright (c) 2009 Steven Kreuzer +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd March 18, 2009 +.Dt SERVICE 8 +.Os +.Sh NAME +.Nm service +.Nd abstract the management of services provided by the system +.Sh SYNOPSIS +.Nm +.Op Ar service command +.Op Fl l +.Sh DESCRIPTION +.Nm +is a simple utility to abstract the management of services provided +by the system. It can be used to start and stop services, as well as +to determine the status of services. +.Sh OPTIONS +.Bl -tag -width indent +.Pa service command +Attempt to execute a given command for a given service +.It Fl l +List all available services +.Sh SEE ALSO +.Xr rc 8 +.Xr rc.conf 5 +.Sh AUTHORS +This manual page was written by +.An Steven Kreuzer Aq skreuzer@FreeBSD.org . Index: service/service.sh =================================================================== RCS file: service/service.sh diff -N service/service.sh --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ service/service.sh 19 Mar 2009 18:37:01 -0000 @@ -0,0 +1,52 @@ +#!/bin/sh +# +# Copyright (c) 2009 Steven Kreuzer +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer +# in this position and unchanged. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# $FreeBSD$ + +. /etc/rc.subr + +RCPATH="/etc/rc.d /usr/local/etc/rc.d" + +case $1 in + -l) + for RC in $RCPATH; do + /bin/ls $RC | /usr/bin/xargs /usr/bin/basename + done + ;; + *) + if [ "$(eval $IDCMD)" != "root" ]; then + echo 1>&2 "you must be root (0) to use this function." + exit 1 + fi + for RC in $RCPATH; do + if [ -x $RC/$1 ]; then + $RC/$1 $2 + fi + done + ;; +esac