wok-current rev 18429
busybox: add shutdown
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Mon Sep 21 17:56:57 2015 +0200 (2015-09-21) |
parents | 68bd2134ab54 |
children | 0179b7504010 |
files | busybox/receipt busybox/stuff/busybox-1.23-shutdown.u |
line diff
1.1 --- a/busybox/receipt Mon Sep 21 13:17:35 2015 +0000 1.2 +++ b/busybox/receipt Mon Sep 21 17:56:57 2015 +0200 1.3 @@ -46,6 +46,7 @@ 1.4 cpio.u 1.5 ftpd.u 1.6 dpkgxz.u 1.7 +shutdown.u 1.8 EOT 1.9 cp $stuff/$PACKAGE-${VERSION%.*}.config .config 1.10 }
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/busybox/stuff/busybox-1.23-shutdown.u Mon Sep 21 17:56:57 2015 +0200 2.3 @@ -0,0 +1,63 @@ 2.4 +--- busybox-1.23/init/halt.c 2.5 ++++ busybox-1.23/init/halt.c 2.6 +@@ -10,6 +10,7 @@ 2.7 + //applet:IF_HALT(APPLET(halt, BB_DIR_SBIN, BB_SUID_DROP)) 2.8 + //applet:IF_HALT(APPLET_ODDNAME(poweroff, halt, BB_DIR_SBIN, BB_SUID_DROP, poweroff)) 2.9 + //applet:IF_HALT(APPLET_ODDNAME(reboot, halt, BB_DIR_SBIN, BB_SUID_DROP, reboot)) 2.10 ++//applet:IF_HALT(APPLET_ODDNAME(shutdown, halt, BB_DIR_SBIN, BB_SUID_DROP, shutdown)) 2.11 + 2.12 + //kbuild:lib-$(CONFIG_HALT) += halt.o 2.13 + 2.14 +@@ -65,6 +66,15 @@ 2.15 + //usage: "\n -d SEC Delay interval" 2.16 + //usage: "\n -n Do not sync" 2.17 + //usage: "\n -f Force (don't go through init)" 2.18 ++//usage: 2.19 ++//usage:#define shutdown_trivial_usage 2.20 ++//usage: "[-rhHP]" 2.21 ++//usage:#define shutdown_full_usage "\n\n" 2.22 ++//usage: "Bring the system down\n" 2.23 ++//usage: "\n -r Do reboot" 2.24 ++//usage: "\n -h Do poweroff" 2.25 ++//usage: "\n -H Do halt" 2.26 ++//usage: "\n -P Do poweroff" 2.27 + 2.28 + #include "libbb.h" 2.29 + #include "reboot.h" 2.30 +@@ -98,6 +108,7 @@ 2.31 + int halt_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 2.32 + int halt_main(int argc UNUSED_PARAM, char **argv) 2.33 + { 2.34 ++ enum { HALT=0, POWEROFF=1, REBOOT=2, SHUTDOWN=3 }; 2.35 + static const int magic[] = { 2.36 + RB_HALT_SYSTEM, 2.37 + RB_POWER_OFF, 2.38 +@@ -109,9 +120,19 @@ 2.39 + int which, flags, rc; 2.40 + 2.41 + /* Figure out which applet we're running */ 2.42 +- for (which = 0; "hpr"[which] != applet_name[0]; which++) 2.43 ++ for (which = 0; "hprs"[which] != applet_name[0]; which++) 2.44 + continue; 2.45 + 2.46 ++ if (which == SHUTDOWN) { 2.47 ++ which = REBOOT; 2.48 ++ switch (getopt32(argv, "rhPH")) { 2.49 ++ case 2: 2.50 ++ case 4: which = POWEROFF; break; 2.51 ++ case 8: which = HALT; 2.52 ++ } 2.53 ++ flags = 0; 2.54 ++ } 2.55 ++ else { 2.56 + /* Parse and handle arguments */ 2.57 + opt_complementary = "d+"; /* -d N */ 2.58 + /* We support -w even if !ENABLE_FEATURE_WTMP, 2.59 +@@ -119,6 +140,7 @@ 2.60 + * -i (shut down network interfaces) is ignored. 2.61 + */ 2.62 + flags = getopt32(argv, "d:nfwi", &delay); 2.63 ++ } 2.64 + 2.65 + sleep(delay); 2.66 +