Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 9 Jun 2009 22:16:56 +0100
From:      RW <rwmaillists@googlemail.com>
To:        ports@freebsd.org
Subject:   Re: Port of "service" command
Message-ID:  <20090609221656.752e9c8f@gumby.homeunix.com>
In-Reply-To: <4A2EB864.1060006@FreeBSD.org>
References:  <17ca67550906091046t15dfa574i95e432a09e60d379@mail.gmail.com> <1d3ed48c0906091140t37fbdd4eq84a1153348db7a53@mail.gmail.com> <4A2EB864.1060006@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 09 Jun 2009 12:30:44 -0700
Doug Barton <dougb@FreeBSD.org> wrote:

> Kevin Downey wrote:
> > I have a similar shell function I am rather fond of:
> > 
> > rc(){
> >     find /etc/rc.d/"$1" /usr/local/etc/rc.d/"$1" -exec sudo {} `echo
> > "$*"|cut -f 2- -d \ ` \;
> > }
> 
> Wow, that's painful. :) The only reason you don't notice how painful
> is because those two directories have only a few files. Much much more
> efficient would be something like:
> 
> rc () {
> 	local script=$1
> 	shift
> 
> 	if [ -x "/etc/rc.d/$script" ]; then
> 		/etc/rc.d/$script $*
> 	elif [ -x "/usr/local/etc/rc.d/$script" ]; then
> 		/usr/local/etc/rc.d/$script $*
> 	else
> 		echo "$script does not exist in /etc/rc.d or"
> 		echo "/usr/local/etc/rc.d"
> 		return 1
> 	fi
> }

This kind of thing is already implemented by the
sysutils/bsdadminscripts port.




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20090609221656.752e9c8f>