From owner-freebsd-questions@FreeBSD.ORG Fri Apr 4 23:34:45 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 755DC106564A for ; Fri, 4 Apr 2008 23:34:45 +0000 (UTC) (envelope-from andrew@farnborough.darq.net) Received: from farnborough.darq.net (fab.darq.net [82.136.41.2]) by mx1.freebsd.org (Postfix) with ESMTP id 21F128FC1E for ; Fri, 4 Apr 2008 23:34:44 +0000 (UTC) (envelope-from andrew@farnborough.darq.net) Received: from localhost (localhost [127.0.0.1]) by farnborough.darq.net (Postfix) with ESMTP id 6918C1D126; Sat, 5 Apr 2008 00:38:10 +0100 (BST) X-Virus-Scanned: amavisd-new at darq.net Received: from farnborough.darq.net ([127.0.0.1]) by localhost (farnborough.darq.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ZY1wDUJY+0y3; Sat, 5 Apr 2008 00:38:06 +0100 (BST) Received: by farnborough.darq.net (Postfix, from userid 1057) id E54D81D180; Sat, 5 Apr 2008 00:38:06 +0100 (BST) Date: Sat, 5 Apr 2008 00:38:06 +0100 From: Andrew Cid To: Rance Hall Message-ID: <20080404233806.GA24899@farnborough.darq.net> References: <845c0f80804041321j44439881yb67458980edab102@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <845c0f80804041321j44439881yb67458980edab102@mail.gmail.com> User-Agent: Mutt/1.5.11 Cc: freebsd-questions@freebsd.org Subject: Re: need a shell script that can be executed manually or as part of the rc process. How can the script detect WHERE it is being called from to know how to handle various options. X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Apr 2008 23:34:45 -0000 Hi Rance, > I have a sh script im working on that is going to be able to run by > the init/rc process. That same script can also be run after the > system is started. > > I need a way to have the sh script detect WHERE in the boot process > the server is when it is being executed. You can control when your rc script runs with #REQUIRE: and #BEFORE: Checkout the practical rc.d scripting article [1], chapter 7 has an example. Use rcorder(8) to see what runs when: $ rcorder /etc/rc.d/* Hope this helps, Andrew [1] http://www.freebsd.org/doc/en/articles/rc-scripting/index.html -- andrew@accid.net