[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: sysvinit package sources



Il giorno gio, 15/09/2005 alle 19.00 +0200, Klaus Knopper ha scritto:
> On Thu, Sep 15, 2005 at 04:12:21PM +0200, Alessandro Iurlano wrote:
> > Hello.
> > I want to create a custom version of knoppix. I can successfully create
> > a cd with my software and my customizations. But I've got problems with
> > reboot. I've tried to hack /etc/init.d/knoppix-reboot but without
> > success.
> > The init program that is used when noprompt is no (the one that ask the
> > user to press enter) works correctly.
> > The other init program (noprompt=yes) hangs the pc just after the
> > "preparing for reboot" print.
> > I'd like to have the sources of the sysvinit package to hack the version
> > of init that works to let the pc reboot without user.
> > I've looked at the knoppix website and found the link
> > http://www.knopper.net/download/knoppix/ but it points to
> > http://developer.linuxtag.net/knoppix/ which contains outdated packages
> > that I can't get to compile.
> > 
> > Anyone can help me?
> 
> Sorry, the Knoppix repository at LinuxTag is abandoned since I do not
> have access anymore. I'm currently rebuilding it at packages.debian.org,
> but it will take some time until completion.
> 
> For a quick response, attached it the currentmost source of the package
> directly from my mastering system.
> 
> Regards
> -Klaus Knopper

Thanks a lot. I managed to get the reboot to work correctly.
I've created a patch for this problem in case someone else is
interested. I've made it pass NOEJECT and NOPROMPT as environment
variables to the halt.c code to make it behave as expected.
I've made it with hurry in my mind, so maybe I've missed something,
although I hope I don't.

Thanks again for the quick response.
Alessandro
diff -Naur sysvinit-knoppix-2.84/debian/etc/init.d/knoppix-halt sysvinit-knoppix-2.84-new/debian/etc/init.d/knoppix-halt
--- sysvinit-knoppix-2.84/debian/etc/init.d/knoppix-halt	2005-08-29 05:34:05.000000000 +0200
+++ sysvinit-knoppix-2.84-new/debian/etc/init.d/knoppix-halt	2005-09-19 20:28:31.078867400 +0200
@@ -246,5 +246,7 @@
 
 echo "$message"
 
+export NOEJECT
+export NOPROMPT
 # Now halt or reboot.
 exec $FINALCMD $options
diff -Naur sysvinit-knoppix-2.84/src/halt.c sysvinit-knoppix-2.84-new/src/halt.c
--- sysvinit-knoppix-2.84/src/halt.c	2005-04-08 14:41:22.000000000 +0200
+++ sysvinit-knoppix-2.84-new/src/halt.c	2005-09-19 20:26:13.419794760 +0200
@@ -267,31 +267,49 @@
 
 	/* KNOPPIX: Umount /KNOPPIX, unload/eject CD-Rom */
 	/* All these are really syscalls */
-	for(c=1;c<=3;c++) /* Attempt to umount this many times */
-	 {
-	  if(UMOUNT("/KNOPPIX")==0)
-	   {
-	    char *msg1="Please remove CD, close cdrom drive and hit return.";
-	    char *msg2="\rShutdown complete.";
-	    /* missing in linux/module.h */
-	    extern int delete_module(const char *);
-	    usleep(250000); delete_module("cloop"); usleep(250000);
-	    if(UMOUNT("/cdrom")!=EBUSY)
-	     {write(2,msg1,strlen(msg1)); tcflush(1,TCIFLUSH); getchar();
-	      write(2,msg2,strlen(msg2)); usleep(250000);}
-	    break;
-	   }
-	  else
-	   {
-	    if(errno==EBUSY)
-	     {
-	      char *msg=c<3?"Can't unmount CD yet...\n":
-	                "Can't unmount CD, please reset.\n";
-	      write(2,msg,strlen(msg));
-	     }
-	    sleep(3);
-	   }
-	 }
+
+	/* check the environment variable NOEJECT */
+	{
+	  char * noeject=NULL;
+	  noeject = getenv("NOEJECT") ;
+	  /* if it is not defined or not equal to "yes" then we eject */
+	  if ( ( ! noeject ) || ( strcmp (noeject,"yes") ) ) {
+	    
+	    for(c=1;c<=3;c++) /* Attempt to umount this many times */
+	      {
+		if(UMOUNT("/KNOPPIX")==0)
+		  {
+		    char *msg1="Please remove CD, close cdrom drive and hit return.";
+		    char *msg2="\rShutdown complete.";
+		    /* missing in linux/module.h */
+		    extern int delete_module(const char *);
+		    usleep(250000); delete_module("cloop"); usleep(250000);
+		    if(UMOUNT("/cdrom")!=EBUSY)
+		      {
+			char * noprompt=NULL;
+			noprompt = getenv ( "NOPROMPT" );
+			/* if it is not defined or not equal to "yes" then we eject */
+			if ( ( ! noprompt ) || ( strcmp (noprompt,"yes") ) ) {
+			  write(2,msg1,strlen(msg1)); tcflush(1,TCIFLUSH); getchar();
+			  write(2,msg2,strlen(msg2));
+			  usleep(250000);
+			}
+		      }
+		    break;
+		  }
+		else
+		  {
+		    if(errno==EBUSY)
+		      {
+			char *msg=c<3?"Can't unmount CD yet...\n":
+			  "Can't unmount CD, please reset.\n";
+			write(2,msg,strlen(msg));
+		      }
+		    sleep(3);
+		  }
+	      }
+	  }
+	}
 
 	if (do_reboot) {
 		init_reboot(BMAGIC_REBOOT);

Attachment: signature.asc
Description: This is a digitally signed message part


Reply to: