]> git.pld-linux.org Git - packages/SysVinit.git/commitdiff
- add "ask for confirmation on reboot" option
authorshadzik <shadzik@pld-linux.org>
Wed, 20 Aug 2008 12:52:00 +0000 (12:52 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
Changed files:
    sysvinit-rebootconfirmation.patch -> 1.1

sysvinit-rebootconfirmation.patch [new file with mode: 0644]

diff --git a/sysvinit-rebootconfirmation.patch b/sysvinit-rebootconfirmation.patch
new file mode 100644 (file)
index 0000000..833ed0c
--- /dev/null
@@ -0,0 +1,61 @@
+--- src/halt.c-dupa    2008-08-20 14:45:39.019976250 +0200
++++ src/halt.c 2008-08-20 14:49:35.418750250 +0200
+@@ -64,7 +64,7 @@
+  */
+ void usage(void)
+ {
+-      fprintf(stderr, "usage: %s [-n] [-w] [-d] [-f] [-h] [-i]%s\n",
++      fprintf(stderr, "usage: %s [-n] [-w] [-d] [-f] [-h] [-i] [-c]%s\n",
+               progname, strcmp(progname, "halt") ? "" : " [-p]");
+       fprintf(stderr, "\t-n: don't sync before halting the system\n");
+       fprintf(stderr, "\t-w: only write a wtmp reboot record and exit.\n");
+@@ -72,6 +72,7 @@
+       fprintf(stderr, "\t-f: force halt/reboot, don't call shutdown.\n");
+       fprintf(stderr, "\t-h: put harddisks in standby mode.\n");
+       fprintf(stderr, "\t-i: shut down all network interfaces.\n");
++      fprintf(stderr, "\t-c: aks for confirmation.\n");
+       if (!strcmp(progname, "halt"))
+               fprintf(stderr, "\t-p: power down the system (if possible, otherwise halt).\n");
+       exit(1);
+@@ -172,8 +173,10 @@
+       int do_ifdown = 0;
+       int do_hddown = 0;
+       int do_poweroff = 0;
++      int do_confirm = 0;
+       int c;
+       char *tm = NULL;
++      char answer = 'n';
+       /*
+        *      Find out who we are
+@@ -190,7 +193,7 @@
+       /*
+        *      Get flags
+        */
+-      while((c = getopt(argc, argv, ":ihdfnpwt:")) != EOF) {
++      while((c = getopt(argc, argv, ":ihdfnpwct:")) != EOF) {
+               switch(c) {
+                       case 'n':
+                               do_sync = 0;
+@@ -214,6 +217,9 @@
+                       case 'p':
+                               do_poweroff = 1;
+                               break;
++                      case 'c':
++                              do_confirm = 1;
++                              break;
+                       case 't':
+                               tm = optarg;
+                               break;
+@@ -231,6 +237,11 @@
+       (void)chdir("/");
+       if (!do_hard && !do_nothing) {
++              if (do_confirm) {
++                      fprintf(stderr, "Are you sure you want to reboot? N/y.\n");
++                      scanf("%c", &answer);
++                      if (tolower(answer) != 'y') exit(1);
++              }
+               /*
+                *      See if we are in runlevel 0 or 6.
+                */
This page took 0.124638 seconds and 4 git commands to generate.