Date: Thu, 7 Aug 2008 11:25:39 -0400 From: Mike Meyer <mwm@mired.org> To: Alex Kozlov <spam@rm-rf.kiev.ua> Cc: Michael B Allen <ioplex@gmail.com>, hackers@freebsd.org, spam@rm-rf.kiev.ua, Mike Meyer <mwm-keyword-freebsdhackers2.e313df@mired.org> Subject: Re: Idea for FreeBSD Message-ID: <20080807112539.65380404@mbook.local> In-Reply-To: <20080807061500.GA23109@ravenloft.kiev.ua> References: <20080807061500.GA23109@ravenloft.kiev.ua>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 7 Aug 2008 09:15:00 +0300 Alex Kozlov <spam@rm-rf.kiev.ua> wrote: > [1]: > $cat /usr/local/bin/service Basically what I had in mind, but it can be made more portable across FreeBSD configurations. > #!/bin/sh > > name=$1 > cmd=$2 > > . /etc/rc.subr > if [ -z "${name}" -o -z "${cmd}" ] > then > echo ${0##*/} service_name command > exit 3 > fi > > > if [ -r "/etc/rc.d/${name}" ] > then > run_rc_script "/etc/rc.d/${name}" ${cmd} > exit 0 > fi And here's where you go wrong. What you want now is: for dir in $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 Thanks, <mike -- Mike Meyer <mwm@mired.org> http://www.mired.org/consulting.html Independent Network/Unix/Perforce consultant, email for more information. O< ascii ribbon campaign - stop html mail - www.asciiribbon.org
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080807112539.65380404>