Date: Sun, 18 Dec 2005 20:18:12 +1100 From: Antony Mawer <fbsd-questions@mawer.org> To: Josh Endries <josh@endries.org> Cc: freebsd-questions@freebsd.org Subject: Re: Adding lines to /etc/rc.conf during sysinstall wihout being "REMOVED" Message-ID: <43A52954.8020805@mawer.org> In-Reply-To: <43A2F7CE.2010603@endries.org> References: <43A2F7CE.2010603@endries.org>
next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format. --------------090102060806060403060802 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit On 17/12/2005 4:22 AM, Josh Endries wrote: > Does anyone know the correct way to add lines to rc.conf without > sysinstall commenting them out and prepending "REMOVED" to them, > during an automated install.cfg routine? Currently I have a pkg I > made that adds stuff like ntp.conf and rc.conf, but all the lines in > my custom rc.conf are removed after the script finishes. > > I looked through the code for sysinstall but didn't see any way to > disable this behavior (my C isn't very good). What would be the > correct way to do this? I'm now having my pkg install a rc.d script > which cat's >> /etc/rc.conf... I hit this same problem in building a custom installation disc, and wound up extending sysinstall to have a shutdownNoRC that would function the same as the "shutdown" statement in an install.cfg, only without touching the rc.conf. This was useful for us, as we installed a custom rc.conf and did not want sysinstall to touch it. I also added a "poweroff" and "poweroffNoRC" methods that function the same as the "shutdown" statement, only power off the machine instead. This can be quite handy in a production line environment, when used in conjunction with the cdcontrol(1) command to eject the CD, prior to powering off the completed system. I've attached the patch if anyone is interested... perhaps if there is sufficient interest then someone could see about getting this committed. The attached patch is against 6.0-RELEASE. Regards Antony --------------090102060806060403060802 Content-Type: text/plain; name="sysinstall.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="sysinstall.diff" Index: usr.sbin/sysinstall/dispatch.c =================================================================== RCS file: /home/ncvs/src/usr.sbin/sysinstall/dispatch.c,v retrieving revision 1.47 diff -u -r1.47 dispatch.c --- usr.sbin/sysinstall/dispatch.c 30 Aug 2004 21:03:09 -0000 1.47 +++ usr.sbin/sysinstall/dispatch.c 18 Nov 2005 02:11:20 -0000 @@ -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_mediaClose(dialogMenuItem *unused); @@ -111,6 +114,9 @@ { "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 }, @@ -178,6 +184,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); Index: usr.sbin/sysinstall/sysinstall.8 =================================================================== RCS file: /home/ncvs/src/usr.sbin/sysinstall/sysinstall.8,v retrieving revision 1.69.2.1 diff -u -r1.69.2.1 sysinstall.8 --- usr.sbin/sysinstall/sysinstall.8 9 Oct 2005 03:48:42 -0000 1.69.2.1 +++ usr.sbin/sysinstall/sysinstall.8 18 Nov 2005 01:55:58 -0000 @@ -813,6 +813,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 Index: usr.sbin/sysinstall/sysinstall.h =================================================================== RCS file: /home/ncvs/src/usr.sbin/sysinstall/sysinstall.h,v retrieving revision 1.264.2.1 diff -u -r1.264.2.1 sysinstall.h --- usr.sbin/sysinstall/sysinstall.h 7 Oct 2005 15:56:30 -0000 1.264.2.1 +++ usr.sbin/sysinstall/sysinstall.h 18 Nov 2005 02:09:31 -0000 @@ -395,6 +395,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 */ @@ -808,6 +812,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); Index: usr.sbin/sysinstall/system.c =================================================================== RCS file: /home/ncvs/src/usr.sbin/sysinstall/system.c,v retrieving revision 1.124.2.1 diff -u -r1.124.2.1 system.c --- usr.sbin/sysinstall/system.c 17 Aug 2005 13:32:29 -0000 1.124.2.1 +++ usr.sbin/sysinstall/system.c 18 Nov 2005 02:10:32 -0000 @@ -235,12 +235,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) { @@ -261,7 +269,10 @@ #if defined(__alpha__) || defined(__sparc64__) reboot(RB_HALT); #else - reboot(0); + if (shutdown_flags & SHUTDOWN_POWEROFF) + reboot(RB_HALT | RB_POWEROFF); + else + reboot(0); #endif } else --------------090102060806060403060802--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?43A52954.8020805>