From owner-freebsd-hackers@FreeBSD.ORG Fri Aug 8 03:33:22 2008 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DFB321065674 for ; Fri, 8 Aug 2008 03:33:22 +0000 (UTC) (envelope-from kozlov@ravenloft.kiev.ua) Received: from istc.kiev.ua (wolf.istc.kiev.ua [193.108.236.1]) by mx1.freebsd.org (Postfix) with ESMTP id 9BC778FC0C for ; Fri, 8 Aug 2008 03:33:22 +0000 (UTC) (envelope-from kozlov@ravenloft.kiev.ua) Received: from [91.123.146.100] (helo=ravenloft.kiev.ua) by istc.kiev.ua with esmtp (Exim 4.52) id 1KRIj8-0002iH-1g; Fri, 08 Aug 2008 06:33:20 +0300 Date: Fri, 8 Aug 2008 06:33:17 +0300 From: Alex Kozlov To: Mike Meyer , hackers@freebsd.org, spam@rm-rf.kiev.ua Message-ID: <20080808033317.GA96397@ravenloft.kiev.ua> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Score: 0.0 (/) X-Spam-Report: Content analysis detailz: (0.0 points, 10.0 required) Cc: Subject: Re: Idea for FreeBSD X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Aug 2008 03:33:23 -0000 On Thu, Aug 07, 2008 at 11:25:39AM -0400, Mike Meyer wrote: > On Thu, 7 Aug 2008 09:15:00 +0300 Alex Kozlov wrote: > > [1]: > > $cat /usr/local/bin/service > > Basically what I had in mind, but it can be made more portable across > FreeBSD configurations. > [...] > > And here's where you go wrong. What you want now is: Yes. This is more correct: #!/bin/sh name=$1 cmd=$2 if [ -z "${name}" -o -z "${cmd}" ]; then echo ${0##*/} service_name command exit 3 fi . /etc/rc.subr load_rc_config ${name} for dir in /etc/rc.d ${local_startup}; do if [ -r "${dir}/${name}" ]; then run_rc_script "${dir}/${name}" ${cmd} exit 0 fi if [ -r "${dir}/${name}.sh" ]; then run_rc_script "${dir}/${name}.sh" ${cmd} exit 0 fi done echo "service '${name}' not found" exit 2 -- Adios