From owner-freebsd-bugs@FreeBSD.ORG Mon Aug 17 06:10:06 2009 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4CC33106568D for ; Mon, 17 Aug 2009 06:10:06 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id E8F0D8FC3D for ; Mon, 17 Aug 2009 06:10:05 +0000 (UTC) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id n7H6A5aS095887 for ; Mon, 17 Aug 2009 06:10:05 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id n7H6A5Qd095886; Mon, 17 Aug 2009 06:10:05 GMT (envelope-from gnats) Resent-Date: Mon, 17 Aug 2009 06:10:05 GMT Resent-Message-Id: <200908170610.n7H6A5Qd095886@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Michael Leun Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 696BC1065690 for ; Mon, 17 Aug 2009 06:07:40 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id 57CFE8FC41 for ; Mon, 17 Aug 2009 06:07:40 +0000 (UTC) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.3/8.14.3) with ESMTP id n7H67dmv092303 for ; Mon, 17 Aug 2009 06:07:39 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id n7H67dRQ092300; Mon, 17 Aug 2009 06:07:39 GMT (envelope-from nobody) Message-Id: <200908170607.n7H67dRQ092300@www.freebsd.org> Date: Mon, 17 Aug 2009 06:07:39 GMT From: Michael Leun To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: bin/137864: [patch] sysinstall: add possibility to shutdown/poweroff without modifying /etc/rc.conf X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 Aug 2009 06:10:06 -0000 >Number: 137864 >Category: bin >Synopsis: [patch] sysinstall: add possibility to shutdown/poweroff without modifying /etc/rc.conf >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Mon Aug 17 06:10:05 UTC 2009 >Closed-Date: >Last-Modified: >Originator: Michael Leun >Release: 7.2 >Organization: Vodafone AG & Co. KG >Environment: FreeBSD build72-64.tnd.arcor.net 7.2-RELEASE FreeBSD 7.2-RELEASE #0: Fri May 1 07:18:07 UTC 2009 root@driscoll.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC amd64 >Description: I've created customized install disks doing an unattended installation of the current (current when creating the disk) patchlevel of FreeBSD. At the end of the installation a customized package which brings some configuration files, changes some config and creates /etc/rc.conf from scratch is installed. But with unmodified sysinstall all changes made in the post install script of the custom package get clobbered / commented out. My search for a solution lead to http://lists.freebsd.org/pipermail/freebsd-questions/2005-December/107861.html This patch adds an option "shutdownNoRC" to shutdown without touching /etc/rc.conf (and also "poweroff" to just power off and "poweroffNoRC" to power off without touching rc.conf) at the end of the installation. Note: This fixes bin/69942. >How-To-Repeat: Create an custom install media which installs a package modifying /etc/rc.conf >Fix: Patch attached Adds alternate commands to quit installation, offering the possibility not to change / create /etc/rc.conf by sysinstall. Patch attached with submission follows: # Patch FreeBSD 7.2 sysinstall to have options not to touch /etc/rc.conf # originally created by Antony Mawer see # http://lists.freebsd.org/pipermail/freebsd-questions/2005-December/107861.html # # Adapted to FreeBSD 7.2 by Michael Leun on behalf of Vodafone AG & Co. KG diff -Nur usr.sbin.orig/sysinstall/dispatch.c usr.sbin/sysinstall/dispatch.c --- usr.sbin.orig/sysinstall/dispatch.c 2009-04-15 05:14:26.000000000 +0200 +++ usr.sbin/sysinstall/dispatch.c 2009-06-24 22:53:47.000000000 +0200 @@ -43,6 +43,9 @@ #include "list.h" static int dispatch_shutdown(dialogMenuItem *unused); +static int dispatch_shutdown_norc(dialogMenuItem *unused); +static int dispatch_poweroff(dialogMenuItem *unused); +static int dispatch_poweroff_norc(dialogMenuItem *unused); static int dispatch_systemExecute(dialogMenuItem *unused); static int dispatch_msgConfirm(dialogMenuItem *unused); static int dispatch_mediaOpen(dialogMenuItem *unused); @@ -113,9 +116,13 @@ { "addGroup", userAddGroup }, { "addUser", userAddUser }, { "shutdown", dispatch_shutdown }, + { "shutdownNoRC", dispatch_shutdown_norc }, + { "poweroff", dispatch_poweroff }, + { "poweroffNoRC", dispatch_poweroff_norc }, { "system", dispatch_systemExecute }, { "dumpVariables", dump_variables }, { "tcpMenuSelect", tcpMenuSelect }, + { "configCountry", configCountry }, { NULL, NULL }, }; @@ -180,6 +187,27 @@ } static int +dispatch_shutdown_norc(dialogMenuItem *unused) +{ + systemShutdownNow(0, SHUTDOWN_NO_RC_CONF); + return DITEM_FAILURE; +} + +static int +dispatch_poweroff(dialogMenuItem *unused) +{ + systemShutdownNow(0, SHUTDOWN_POWEROFF); + return DITEM_FAILURE; +} + +static int +dispatch_poweroff_norc(dialogMenuItem *unused) +{ + systemShutdownNow(0, SHUTDOWN_POWEROFF | SHUTDOWN_NO_RC_CONF); + return DITEM_FAILURE; +} + +static int dispatch_systemExecute(dialogMenuItem *unused) { char *cmd = variable_get(VAR_COMMAND); diff -Nur usr.sbin.orig/sysinstall/sysinstall.8 usr.sbin/sysinstall/sysinstall.8 --- usr.sbin.orig/sysinstall/sysinstall.8 2009-04-15 05:14:26.000000000 +0200 +++ usr.sbin/sysinstall/sysinstall.8 2009-06-24 22:51:20.000000000 +0200 @@ -835,6 +835,26 @@ .Pp .Sy Variables : None +.It shutdownNoRC +Stop the script and terminate sysinstall, but do not touch +.Pa /etc/rc.conf . +.Pp +.Sy Variables : +None +.It poweroff +The same as +.Pa shutdown , +only power off the system (if possible) rather than rebooting. +.Pp +.Sy Variables : +None +.It poweroffNoRC +The same as +.Pa shutdownNoRC , +only power off the system (if possible) rather than rebooting. +.Pp +.Sy Variables : +None .It system Execute an arbitrary command with .Xr system 3 diff -Nur usr.sbin.orig/sysinstall/sysinstall.h usr.sbin/sysinstall/sysinstall.h --- usr.sbin.orig/sysinstall/sysinstall.h 2009-04-15 05:14:26.000000000 +0200 +++ usr.sbin/sysinstall/sysinstall.h 2009-06-24 22:51:20.000000000 +0200 @@ -407,6 +407,10 @@ char extras[EXTRAS_FIELD_LEN]; } DevInfo; +/* systemShutdownNow bitfield flags */ +#define SHUTDOWN_POWEROFF 0x1 /* Power off after shutdown */ +#define SHUTDOWN_NO_RC_CONF 0x2 /* Don't attempt to update rc.conf */ + /*** Externs ***/ extern jmp_buf BailOut; /* Used to get the heck out */ @@ -838,6 +842,7 @@ /* system.c */ extern void systemInitialize(int argc, char **argv); extern void systemShutdown(int status); +extern void systemShutdownNow(int status, int shutdown_flags); extern int execExecute(char *cmd, char *name); extern int systemExecute(char *cmd); extern void systemSuspendDialog(void); diff -Nur usr.sbin.orig/sysinstall/system.c usr.sbin/sysinstall/system.c --- usr.sbin.orig/sysinstall/system.c 2009-04-15 05:14:26.000000000 +0200 +++ usr.sbin/sysinstall/system.c 2009-06-24 22:51:20.000000000 +0200 @@ -238,12 +238,20 @@ void systemShutdown(int status) { + systemShutdownNow(status, 0); +} + +void +systemShutdownNow(int status, int shutdown_flags) +{ + /* If some media is open, close it down */ if (status >=0) mediaClose(); /* write out any changes to rc.conf .. */ - configRC_conf(); + if (!(shutdown_flags & SHUTDOWN_NO_RC_CONF)) + configRC_conf(); /* Shut down the dialog library */ if (DialogActive) { @@ -264,7 +272,10 @@ #if defined(__alpha__) || defined(__sparc64__) reboot(RB_HALT); #else - reboot(RB_AUTOBOOT); + if (shutdown_flags & SHUTDOWN_POWEROFF) + reboot(RB_HALT | RB_POWEROFF); + else + reboot(RB_AUTOBOOT); #endif } else >Release-Note: >Audit-Trail: >Unformatted: