From owner-freebsd-mobile@FreeBSD.ORG Fri Jul 5 12:52:19 2013 Return-Path: Delivered-To: freebsd-mobile@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 66096E91 for ; Fri, 5 Jul 2013 12:52:19 +0000 (UTC) (envelope-from jhs@berklix.com) Received: from slim.berklix.org (slim.berklix.org [94.185.90.68]) by mx1.freebsd.org (Postfix) with ESMTP id EFAA91B84 for ; Fri, 5 Jul 2013 12:52:18 +0000 (UTC) Received: from park.js.berklix.net (p5DCBE79D.dip0.t-ipconnect.de [93.203.231.157]) (authenticated bits=128) by slim.berklix.org (8.14.5/8.14.5) with ESMTP id r65CqAnB053186; Fri, 5 Jul 2013 14:52:10 +0200 (CEST) (envelope-from jhs@berklix.com) Received: from fire.js.berklix.net (fire.js.berklix.net [192.168.91.41]) by park.js.berklix.net (8.14.3/8.14.3) with ESMTP id r65CqGcP092814; Fri, 5 Jul 2013 14:52:16 +0200 (CEST) (envelope-from jhs@berklix.com) Received: from fire.js.berklix.net (localhost [127.0.0.1]) by fire.js.berklix.net (8.14.4/8.14.4) with ESMTP id r65Cq46b046582; Fri, 5 Jul 2013 14:52:10 +0200 (CEST) (envelope-from jhs@fire.js.berklix.net) Message-Id: <201307051252.r65Cq46b046582@fire.js.berklix.net> To: freebsd-mobile@freebsd.org Subject: Adding a hook to shutdown.c & halt (reboot.c) to call a script. From: "Julian H. Stacey" Organization: http://berklix.com BSD Linux Unix Consultancy, Munich Germany User-agent: EXMH on FreeBSD http://www.berklix.com/free/ X-URL: http://www.berklix.com/~jhs/cv/ Date: Fri, 05 Jul 2013 14:52:04 +0200 Sender: jhs@berklix.com Cc: "Julian H. Stacey" X-BeenThere: freebsd-mobile@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Mobile computing with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Jul 2013 12:52:19 -0000 Hi mobile@ I need ** my laptop to call a script before shutdown, (perhaps automaticaly too with something like 'test -e ` etc, though perhaps the default should remain with no test) I dont see any hooks in man shutdown or halt ? I could hack /usr/src/sbin/shutdown/shutdown.c & /usr/src/sbin/reboot/reboot.c # (source of halt) or does someone have a better idea ? FreeBSD has a mass of scripts etc for system start up, but seems light on close down hooks ? I seem to recall on system 5 there were table entries for up & down for lots of things, (though I never got on with 5, not lots of others here either, & am not advocating that route), but is there a better way than adding a hook to system("/some_path"); ? BTW ** What I'm calling manually before halt is my http://www.berklix.com/~jhs/bin/.sh/umountusb A combo of umounts of USB sticks/disks with plain dos & ufs + also mdconfig -d & gbde detach for encrypted file system on both hard disk & USB sticks. (When I forget to call it before halt, the laptop hangs on USB.) Cheers, Julian -- Julian Stacey, BSD Unix Linux C Sys Eng Consultant, Munich http://berklix.com Reply below not above, like a play script. Indent old text with "> ". Send plain text. No quoted-printable, HTML, base64, multipart/alternative. From owner-freebsd-mobile@FreeBSD.ORG Fri Jul 5 13:04:55 2013 Return-Path: Delivered-To: freebsd-mobile@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 15C9B3AB for ; Fri, 5 Jul 2013 13:04:55 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from mx1.stack.nl (relay02.stack.nl [IPv6:2001:610:1108:5010::104]) by mx1.freebsd.org (Postfix) with ESMTP id D472C1C3B for ; Fri, 5 Jul 2013 13:04:54 +0000 (UTC) Received: from snail.stack.nl (snail.stack.nl [IPv6:2001:610:1108:5010::131]) by mx1.stack.nl (Postfix) with ESMTP id 42B263592DB; Fri, 5 Jul 2013 15:04:53 +0200 (CEST) Received: by snail.stack.nl (Postfix, from userid 1677) id 22BE328493; Fri, 5 Jul 2013 15:04:53 +0200 (CEST) Date: Fri, 5 Jul 2013 15:04:53 +0200 From: Jilles Tjoelker To: "Julian H. Stacey" Subject: Re: Adding a hook to shutdown.c & halt (reboot.c) to call a script. Message-ID: <20130705130452.GB13495@stack.nl> References: <201307051252.r65Cq46b046582@fire.js.berklix.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201307051252.r65Cq46b046582@fire.js.berklix.net> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: freebsd-mobile@freebsd.org X-BeenThere: freebsd-mobile@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Mobile computing with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Jul 2013 13:04:55 -0000 On Fri, Jul 05, 2013 at 02:52:04PM +0200, Julian H. Stacey wrote: > Hi mobile@ > I need ** my laptop to call a script before shutdown, > (perhaps automaticaly too with something like 'test -e ` etc, > though perhaps the default should remain with no test) > I dont see any hooks in man shutdown or halt ? > I could hack > /usr/src/sbin/shutdown/shutdown.c & > /usr/src/sbin/reboot/reboot.c # (source of halt) > or does someone have a better idea ? > FreeBSD has a mass of scripts etc for system start up, but seems light > on close down hooks ? I seem to recall on system 5 there were table > entries for up & down for lots of things, (though I never got > on with 5, not lots of others here either, & am not advocating that route), > but is there a better way than adding a hook to system("/some_path"); ? > BTW ** What I'm calling manually before halt is my > http://www.berklix.com/~jhs/bin/.sh/umountusb > A combo of umounts of USB sticks/disks with plain dos & ufs + also > mdconfig -d & gbde detach for encrypted file system on both hard > disk & USB sticks. (When I forget to call it before halt, the > laptop hangs on USB.) shutdown(8) signals init (unless -o is given), which will run /etc/rc.shutdown from multi-user mode. The same applies to ctrl+alt+del, kernel-controlled overheating shutdown, etc. reboot(8) and halt(8) do not involve init and do not run any shutdown scripts. I think they should be changed to signal init (except reboot -q, halt -q) and should not be used until then. However, there are apparently some problems with that. The incorrect umount order should perhaps be fixed in the kernel. -- Jilles Tjoelker From owner-freebsd-mobile@FreeBSD.ORG Fri Jul 5 16:04:51 2013 Return-Path: Delivered-To: freebsd-mobile@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id AAD10B71 for ; Fri, 5 Jul 2013 16:04:51 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from mail-ie0-f177.google.com (mail-ie0-f177.google.com [209.85.223.177]) by mx1.freebsd.org (Postfix) with ESMTP id 7D08615BE for ; Fri, 5 Jul 2013 16:04:51 +0000 (UTC) Received: by mail-ie0-f177.google.com with SMTP id aq17so5588929iec.22 for ; Fri, 05 Jul 2013 09:04:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:subject:mime-version:content-type:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to:x-mailer :x-gm-message-state; bh=Dx2QQtce2fTDwcWfaCm4Apwkrq/JpHlvi4YpOFRUIrk=; b=Ye44ObiIQCgUd8/xLCRg7zRO2AMAr/jowj0H8FXppjhaXrlzK7zikivrbxlod4lrUW U9uT/ToFzIncT9ZTh1yHgKW9uGMww8hlDF57Eambv9DutBXj7XYBQE+dNZq7XhQdY2aQ gp82ShrIbZ9aptAz5iM/iU2q5buTpUAcPfwApwz6QhVRakjDLGn1sS2h3BJMb/lqMHqk 69UgiUYKLAolCJIwtjKyKP8QOcYbJMGBtQw94bluD222tQe+7caRxIbaMkYP1aq7xq9U oJPrF3a3mkjrg9Gouj9O0iMVlKUG3JJZVtfBfthB+NEPYncsmS59uESX8hjlwAgNb+H1 QFhQ== X-Received: by 10.50.77.80 with SMTP id q16mr28702461igw.3.1373040290485; Fri, 05 Jul 2013 09:04:50 -0700 (PDT) Received: from 53.imp.bsdimp.com (50-78-194-198-static.hfc.comcastbusiness.net. [50.78.194.198]) by mx.google.com with ESMTPSA id t10sm702586igz.9.2013.07.05.09.04.48 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 05 Jul 2013 09:04:49 -0700 (PDT) Sender: Warner Losh Subject: Re: Adding a hook to shutdown.c & halt (reboot.c) to call a script. Mime-Version: 1.0 (Apple Message framework v1085) Content-Type: text/plain; charset=us-ascii From: Warner Losh In-Reply-To: <20130705130452.GB13495@stack.nl> Date: Fri, 5 Jul 2013 10:04:47 -0600 Content-Transfer-Encoding: quoted-printable Message-Id: <2E491218-DFE8-417D-A41E-5DA27BFC94B3@bsdimp.com> References: <201307051252.r65Cq46b046582@fire.js.berklix.net> <20130705130452.GB13495@stack.nl> To: Jilles Tjoelker X-Mailer: Apple Mail (2.1085) X-Gm-Message-State: ALoCoQmWlsDYCciGvdUGECjHMnyR3h6narhcxCIZaT4DucHlS/wqxml03n5O58JzKRgJcHGqHPEK Cc: "Julian H. Stacey" , freebsd-mobile@freebsd.org X-BeenThere: freebsd-mobile@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Mobile computing with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Jul 2013 16:04:51 -0000 On Jul 5, 2013, at 7:04 AM, Jilles Tjoelker wrote: > On Fri, Jul 05, 2013 at 02:52:04PM +0200, Julian H. Stacey wrote: >> Hi mobile@ >> I need ** my laptop to call a script before shutdown,=20 >> (perhaps automaticaly too with something like 'test -e ` etc, >> though perhaps the default should remain with no test) >=20 >> I dont see any hooks in man shutdown or halt ? =20 >> I could hack >> /usr/src/sbin/shutdown/shutdown.c & >> /usr/src/sbin/reboot/reboot.c # (source of halt) >> or does someone have a better idea ? >=20 >> FreeBSD has a mass of scripts etc for system start up, but seems = light >> on close down hooks ? I seem to recall on system 5 there were table >> entries for up & down for lots of things, (though I never got >> on with 5, not lots of others here either, & am not advocating that = route),=20 >> but is there a better way than adding a hook to system("/some_path"); = ? >=20 >> BTW ** What I'm calling manually before halt is my >> http://www.berklix.com/~jhs/bin/.sh/umountusb >> A combo of umounts of USB sticks/disks with plain dos & ufs + also >> mdconfig -d & gbde detach for encrypted file system on both hard >> disk & USB sticks. (When I forget to call it before halt, the >> laptop hangs on USB.) >=20 > shutdown(8) signals init (unless -o is given), which will run > /etc/rc.shutdown from multi-user mode. The same applies to = ctrl+alt+del, > kernel-controlled overheating shutdown, etc. >=20 > reboot(8) and halt(8) do not involve init and do not run any shutdown > scripts. I think they should be changed to signal init (except reboot > -q, halt -q) and should not be used until then. However, there are > apparently some problems with that. I think so too. fasthalt/fastreboot is what I'd call it, but I've come = around to thinking that you're right here. It will be a small hassle for = some people to adapt to the new system, but I think it will be worth it. > The incorrect umount order should perhaps be fixed in the kernel. Agreed. Warner From owner-freebsd-mobile@FreeBSD.ORG Fri Jul 5 23:44:42 2013 Return-Path: Delivered-To: freebsd-mobile@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id AE748179 for ; Fri, 5 Jul 2013 23:44:42 +0000 (UTC) (envelope-from jhs@berklix.com) Received: from land.berklix.org (land.berklix.org [144.76.10.75]) by mx1.freebsd.org (Postfix) with ESMTP id 424381AFA for ; Fri, 5 Jul 2013 23:44:41 +0000 (UTC) Received: from park.js.berklix.net (p57BCF0AC.dip0.t-ipconnect.de [87.188.240.172]) (authenticated bits=128) by land.berklix.org (8.14.5/8.14.5) with ESMTP id r65MZZfN013189; Fri, 5 Jul 2013 22:35:36 GMT (envelope-from jhs@berklix.com) Received: from fire.js.berklix.net (fire.js.berklix.net [192.168.91.41]) by park.js.berklix.net (8.14.3/8.14.3) with ESMTP id r65MZS9W096392; Sat, 6 Jul 2013 00:35:30 +0200 (CEST) (envelope-from jhs@berklix.com) Received: from fire.js.berklix.net (localhost [127.0.0.1]) by fire.js.berklix.net (8.14.4/8.14.4) with ESMTP id r65MZ27H028531; Sat, 6 Jul 2013 00:35:23 +0200 (CEST) (envelope-from jhs@fire.js.berklix.net) Message-Id: <201307052235.r65MZ27H028531@fire.js.berklix.net> To: Jilles Tjoelker Subject: Re: Adding a hook to shutdown.c & halt (reboot.c) to call a script. From: "Julian H. Stacey" Organization: http://berklix.com BSD Unix Linux Consultancy, Munich Germany User-agent: EXMH on FreeBSD http://berklix.com/free/ X-URL: http://www.berklix.com In-reply-to: Your message "Fri, 05 Jul 2013 15:04:53 +0200." <20130705130452.GB13495@stack.nl> Date: Sat, 06 Jul 2013 00:35:02 +0200 Sender: jhs@berklix.com Cc: freebsd-mobile@freebsd.org X-BeenThere: freebsd-mobile@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Mobile computing with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Jul 2013 23:44:42 -0000 > shutdown(8) signals init (unless -o is given), which will run > /etc/rc.shutdown from multi-user mode. The same applies to ctrl+alt+del, > kernel-controlled overheating shutdown, etc. Thanks Jilles, So I appended to my rc.shutdown # -x not -f below to also allow a symbolic link to work. if [ -x "/etc/rc.shutmedia" ]; then /etc/rc.shutmedia & renamed my URL to http://www.berklix.com/~jhs/bin/.sh/rc.shutmedia > reboot(8) and halt(8) do not involve init and do not run any shutdown > scripts. I think they should be changed to signal init (except reboot > -q, halt -q) and should not be used until then. However, there are > apparently some problems with that. > > The incorrect umount order should perhaps be fixed in the kernel. Yes, bad enough for a local laptop to hang, if it was a remote server, very nasty. Cheers, Julian -- Julian Stacey, BSD Unix Linux C Sys Eng Consultant, Munich http://berklix.com Reply below not above, like a play script. Indent old text with "> ". Send plain text. No quoted-printable, HTML, base64, multipart/alternative.