From owner-freebsd-questions@FreeBSD.ORG Sat Feb 21 01:53:01 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5BFB616A4CE for ; Sat, 21 Feb 2004 01:53:01 -0800 (PST) Received: from mail010.syd.optusnet.com.au (mail010.syd.optusnet.com.au [211.29.132.56]) by mx1.FreeBSD.org (Postfix) with ESMTP id 762E643D41 for ; Sat, 21 Feb 2004 01:53:00 -0800 (PST) (envelope-from tfrank@optushome.com.au) Received: from marvin.home.local (c211-28-241-189.eburwd5.vic.optusnet.com.au [211.28.241.189])i1L9qrl23235; Sat, 21 Feb 2004 20:52:53 +1100 Received: by marvin.home.local (Postfix, from userid 1001) id 901F93FF; Sat, 21 Feb 2004 20:52:52 +1100 (EST) Date: Sat, 21 Feb 2004 20:52:52 +1100 From: Tony Frank To: Dominic Bishop Message-ID: <20040221095252.GF98919@marvin.home.local> References: <20040220133519.0025743D1F@mx1.FreeBSD.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040220133519.0025743D1F@mx1.FreeBSD.org> User-Agent: Mutt/1.4.2.1i cc: freebsd-questions@freebsd.org Subject: Re: Custom startup+shutdown scripts X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Feb 2004 09:53:01 -0000 Hi there, On Fri, Feb 20, 2004 at 01:38:39PM -0000, Dominic Bishop wrote: > I am shortly going to try and install a Belkin universal UPS on one of my > FreeBSD machines running 5.2 using the nut utility. Something I've been thinking of doing for many months now. > Due to a failing in the Belkin protocol it requires some custom > startup/shutdown scripting to make it work in an unsupervised recovery, [ snip ] > > The startup script needs to be run before disks are mounted in read/write > and before filesystem checks for similar reasons. > > I've looked through some of the rc scripts, namely rc.shutdown and a few > others but really aren't sure as to where I should make these changes so > they execute at the correct time in the boot/shutdown process. Could anyone > tell me where I should be making these additions? I'm in a 4.9-STABLE world and there I think it would be fairly straightforward: Based on my understanding - init(8) is a good place to start - init will run /etc/rc.shutdown before it finally powers off/reboots during a shutdown. It currently does not unmount local filesystems, but you could add to the rc.shutdown script at the end to unmount the local filesystems and then perform your extra actions. At startup you have a standard hook that will call /etc/rc.early if it exists. You should be able to add whatever extra functions you need in here. Note that this will be before filesystem checks are done etc. Root will be mounted ro at this point. I understand the rc system has changed a lot with 5.2 so I dont know how much this will help you. Regards, Tony