0.51pre
* Erik Andersen -- added env applet
* Erik Andersen -- Split utility.c into libbb
- * <fixme>
+ * Andreas Neuhaus <andy@fasta.fh-dortmund.de> -- fix for merging
+ kernel command line environment variables into child environment
+ for init.c
+ * Matt Kraai -- Added a new 'shutdown' action to busybox init. Now
+ you can specify arbitrary behavior for 'ctrlaltdel' without that
+ behavior needing to be a reboot.
-Erik Andersen, not yet released
"\n" \
" ::sysinit:/etc/init.d/rcS\n" \
" ::askfirst:/bin/sh\n" \
+" ::ctrlaltdel:/sbin/reboot\n" \
+" ::shutdown:/sbin/swapoff -a\n" \
+" ::shutdown:/bin/umount -a -r\n" \
"\n" \
"if it detects that /dev/console is _not_ a serial console, it will also run:\n" \
"\n" \
" tty2::askfirst:/bin/sh\n" \
+" tty3::askfirst:/bin/sh\n" \
+" tty4::askfirst:/bin/sh\n" \
"\n" \
"If you choose to use an /etc/inittab file, the inittab entry format is as follows:\n" \
"\n" \
" <action>: \n" \
"\n" \
" Valid actions include: sysinit, respawn, askfirst, wait, \n" \
-" once, and ctrlaltdel.\n" \
+" once, ctrlaltdel, and shutdown.\n" \
"\n" \
" The available actions can be classified into two groups: actions\n" \
" that are run only once, and actions that are re-run when the specified\n" \
" 'wait' actions, like 'sysinit' actions, cause init to wait until\n" \
" the specified task completes. 'once' actions are asyncronous,\n" \
" therefore, init does not wait for them to complete. 'ctrlaltdel'\n" \
-" actions are run immediately before init causes the system to reboot\n" \
-" (unmounting filesystems with a 'ctrlaltdel' action is a very good\n" \
-" idea).\n" \
+" actions are run when the system detects that someone on the system\n" \
+" console has pressed the CTRL-ALT-DEL key combination. Typically one\n" \
+" wants to run 'reboot' at this point to cause the system to reboot.\n" \
+" Finally the 'shutdown' action specifies the actions to taken when\n" \
+" init is told to reboot. Unmounting filesystems and disabling swap\n" \
+" is a very good here\n" \
"\n" \
" Run repeatedly actions:\n" \
"\n" \
" #::respawn:/sbin/getty 57600 ttyS2\n" \
" \n" \
" # Stuff to do before rebooting\n" \
-" ::ctrlaltdel:/bin/umount -a -r\n" \
-" ::ctrlaltdel:/sbin/swapoff -a\n"
+" ::ctrlaltdel:/sbin/reboot\n" \
+" ::shutdown:/bin/umount -a -r\n" \
+" ::shutdown:/sbin/swapoff -a\n"
#define insmod_trivial_usage \
"[OPTION]... MODULE [symbol=value]..."
::sysinit:/etc/init.d/rcS
::askfirst:/bin/sh
+ ::ctrlaltdel:/sbin/reboot
+ ::shutdown:/sbin/swapoff -a
+ ::shutdown:/bin/umount -a -r
if it detects that /dev/console is _not_ a serial console, it will also run:
tty2::askfirst:/bin/sh
+ tty3::askfirst:/bin/sh
+ tty4::askfirst:/bin/sh
If you choose to use an /etc/inittab file, the inittab entry format is as follows:
<action>:
Valid actions include: sysinit, respawn, askfirst, wait,
- once, and ctrlaltdel.
+ once, ctrlaltdel, and shutdown.
The available actions can be classified into two groups: actions
that are run only once, and actions that are re-run when the specified
'wait' actions, like 'sysinit' actions, cause init to wait until
the specified task completes. 'once' actions are asyncronous,
therefore, init does not wait for them to complete. 'ctrlaltdel'
- actions are run immediately before init causes the system to reboot
- (unmounting filesystems with a 'ctrlaltdel' action is a very good
- idea).
+ actions are run when the system detects that someone on the system
+ console has pressed the CTRL-ALT-DEL key combination. Typically one
+ wants to run 'reboot' at this point to cause the system to reboot.
+ Finally the 'shutdown' action specifies the actions to taken when
+ init is told to reboot. Unmounting filesystems and disabling swap
+ is a very good here.
Run repeatedly actions:
tty4::respawn:/sbin/getty 38400 tty5
tty5::respawn:/sbin/getty 38400 tty6
-
-
- ::ctrlaltdel:/bin/umount -a -r
- ::ctrlaltdel:/sbin/swapoff -a
+ ::ctrlaltdel:/sbin/reboot
+ ::shutdown:/bin/umount -a -r
+ ::shutdown:/sbin/swapoff -a
-------------------------------
=cut
-# $Id: busybox.pod,v 1.92 2001/03/15 21:20:25 markw Exp $
+# $Id: busybox.pod,v 1.93 2001/04/03 18:01:51 andersen Exp $
"\n" \
" ::sysinit:/etc/init.d/rcS\n" \
" ::askfirst:/bin/sh\n" \
+" ::ctrlaltdel:/sbin/reboot\n" \
+" ::shutdown:/sbin/swapoff -a\n" \
+" ::shutdown:/bin/umount -a -r\n" \
"\n" \
"if it detects that /dev/console is _not_ a serial console, it will also run:\n" \
"\n" \
" tty2::askfirst:/bin/sh\n" \
+" tty3::askfirst:/bin/sh\n" \
+" tty4::askfirst:/bin/sh\n" \
"\n" \
"If you choose to use an /etc/inittab file, the inittab entry format is as follows:\n" \
"\n" \
" <action>: \n" \
"\n" \
" Valid actions include: sysinit, respawn, askfirst, wait, \n" \
-" once, and ctrlaltdel.\n" \
+" once, ctrlaltdel, and shutdown.\n" \
"\n" \
" The available actions can be classified into two groups: actions\n" \
" that are run only once, and actions that are re-run when the specified\n" \
" 'wait' actions, like 'sysinit' actions, cause init to wait until\n" \
" the specified task completes. 'once' actions are asyncronous,\n" \
" therefore, init does not wait for them to complete. 'ctrlaltdel'\n" \
-" actions are run immediately before init causes the system to reboot\n" \
-" (unmounting filesystems with a 'ctrlaltdel' action is a very good\n" \
-" idea).\n" \
+" actions are run when the system detects that someone on the system\n" \
+" console has pressed the CTRL-ALT-DEL key combination. Typically one\n" \
+" wants to run 'reboot' at this point to cause the system to reboot.\n" \
+" Finally the 'shutdown' action specifies the actions to taken when\n" \
+" init is told to reboot. Unmounting filesystems and disabling swap\n" \
+" is a very good here\n" \
"\n" \
" Run repeatedly actions:\n" \
"\n" \
" #::respawn:/sbin/getty 57600 ttyS2\n" \
" \n" \
" # Stuff to do before rebooting\n" \
-" ::ctrlaltdel:/bin/umount -a -r\n" \
-" ::ctrlaltdel:/sbin/swapoff -a\n"
+" ::ctrlaltdel:/sbin/reboot\n" \
+" ::shutdown:/bin/umount -a -r\n" \
+" ::shutdown:/sbin/swapoff -a\n"
#define insmod_trivial_usage \
"[OPTION]... MODULE [symbol=value]..."
ASKFIRST,
WAIT,
ONCE,
- CTRLALTDEL
+ CTRLALTDEL,
+ SHUTDOWN
} initActionEnum;
/* A mapping between "inittab" action name strings and action type codes. */
{"wait", WAIT},
{"once", ONCE},
{"ctrlaltdel", CTRLALTDEL},
+ {"shutdown", SHUTDOWN},
{0, 0}
};
}
/* Run all commands to be run right before halt/reboot */
-static void run_lastAction(void)
+static void run_actions(initActionEnum action)
{
initAction *a, *tmp;
for (a = initActionList; a; a = tmp) {
tmp = a->nextPtr;
- if (a->action == CTRLALTDEL) {
+ if (a->action == action) {
waitfor(a->process, a->console, FALSE);
delete_initAction(a);
}
sleep(1);
/* run everything to be run at "ctrlaltdel" */
- run_lastAction();
+ run_actions(SHUTDOWN);
sync();
if (kernelVersion > 0 && kernelVersion <= KERNEL_VERSION(2,2,11)) {
exit(0);
}
+static void ctrlaltdel_signal(int sig)
+{
+ run_actions(CTRLALTDEL);
+}
+
#endif /* ! DEBUG_INIT */
static void new_initAction(initActionEnum action, char *process, char *cons)
if (file == NULL) {
/* No inittab file -- set up some default behavior */
#endif
+ /* Reboot on Ctrl-Alt-Del */
+ new_initAction(CTRLALTDEL, "/sbin/reboot", console);
/* Swapoff on halt/reboot */
- new_initAction(CTRLALTDEL, "/sbin/swapoff -a", console);
+ new_initAction(SHUTDOWN, "/sbin/swapoff -a", console);
/* Umount all filesystems on halt/reboot */
- new_initAction(CTRLALTDEL, "/bin/umount -a -r", console);
+ new_initAction(SHUTDOWN, "/bin/umount -a -r", console);
/* Askfirst shell on tty1 */
new_initAction(ASKFIRST, SHELL, console);
/* Askfirst shell on tty2 */
* clear all of these in run() */
signal(SIGUSR1, halt_signal);
signal(SIGUSR2, halt_signal);
- signal(SIGINT, reboot_signal);
+ signal(SIGINT, ctrlaltdel_signal);
signal(SIGTERM, reboot_signal);
/* Turn off rebooting via CTL-ALT-DEL -- we get a
ASKFIRST,
WAIT,
ONCE,
- CTRLALTDEL
+ CTRLALTDEL,
+ SHUTDOWN
} initActionEnum;
/* A mapping between "inittab" action name strings and action type codes. */
{"wait", WAIT},
{"once", ONCE},
{"ctrlaltdel", CTRLALTDEL},
+ {"shutdown", SHUTDOWN},
{0, 0}
};
}
/* Run all commands to be run right before halt/reboot */
-static void run_lastAction(void)
+static void run_actions(initActionEnum action)
{
initAction *a, *tmp;
for (a = initActionList; a; a = tmp) {
tmp = a->nextPtr;
- if (a->action == CTRLALTDEL) {
+ if (a->action == action) {
waitfor(a->process, a->console, FALSE);
delete_initAction(a);
}
sleep(1);
/* run everything to be run at "ctrlaltdel" */
- run_lastAction();
+ run_actions(SHUTDOWN);
sync();
if (kernelVersion > 0 && kernelVersion <= KERNEL_VERSION(2,2,11)) {
exit(0);
}
+static void ctrlaltdel_signal(int sig)
+{
+ run_actions(CTRLALTDEL);
+}
+
#endif /* ! DEBUG_INIT */
static void new_initAction(initActionEnum action, char *process, char *cons)
if (file == NULL) {
/* No inittab file -- set up some default behavior */
#endif
+ /* Reboot on Ctrl-Alt-Del */
+ new_initAction(CTRLALTDEL, "/sbin/reboot", console);
/* Swapoff on halt/reboot */
- new_initAction(CTRLALTDEL, "/sbin/swapoff -a", console);
+ new_initAction(SHUTDOWN, "/sbin/swapoff -a", console);
/* Umount all filesystems on halt/reboot */
- new_initAction(CTRLALTDEL, "/bin/umount -a -r", console);
+ new_initAction(SHUTDOWN, "/bin/umount -a -r", console);
/* Askfirst shell on tty1 */
new_initAction(ASKFIRST, SHELL, console);
/* Askfirst shell on tty2 */
* clear all of these in run() */
signal(SIGUSR1, halt_signal);
signal(SIGUSR2, halt_signal);
- signal(SIGINT, reboot_signal);
+ signal(SIGINT, ctrlaltdel_signal);
signal(SIGTERM, reboot_signal);
/* Turn off rebooting via CTL-ALT-DEL -- we get a
{
#ifdef BB_FEATURE_LINUXRC
/* don't assume init's pid == 1 */
- return(kill(*(find_pid_by_name("init")), SIGINT));
+ return(kill(*(find_pid_by_name("init")), SIGTERM));
#else
- return(kill(1, SIGINT));
+ return(kill(1, SIGTERM));
#endif
}
{
#ifdef BB_FEATURE_LINUXRC
/* don't assume init's pid == 1 */
- return(kill(*(find_pid_by_name("init")), SIGINT));
+ return(kill(*(find_pid_by_name("init")), SIGTERM));
#else
- return(kill(1, SIGINT));
+ return(kill(1, SIGTERM));
#endif
}
"\n" \
" ::sysinit:/etc/init.d/rcS\n" \
" ::askfirst:/bin/sh\n" \
+" ::ctrlaltdel:/sbin/reboot\n" \
+" ::shutdown:/sbin/swapoff -a\n" \
+" ::shutdown:/bin/umount -a -r\n" \
"\n" \
"if it detects that /dev/console is _not_ a serial console, it will also run:\n" \
"\n" \
" tty2::askfirst:/bin/sh\n" \
+" tty3::askfirst:/bin/sh\n" \
+" tty4::askfirst:/bin/sh\n" \
"\n" \
"If you choose to use an /etc/inittab file, the inittab entry format is as follows:\n" \
"\n" \
" <action>: \n" \
"\n" \
" Valid actions include: sysinit, respawn, askfirst, wait, \n" \
-" once, and ctrlaltdel.\n" \
+" once, ctrlaltdel, and shutdown.\n" \
"\n" \
" The available actions can be classified into two groups: actions\n" \
" that are run only once, and actions that are re-run when the specified\n" \
" 'wait' actions, like 'sysinit' actions, cause init to wait until\n" \
" the specified task completes. 'once' actions are asyncronous,\n" \
" therefore, init does not wait for them to complete. 'ctrlaltdel'\n" \
-" actions are run immediately before init causes the system to reboot\n" \
-" (unmounting filesystems with a 'ctrlaltdel' action is a very good\n" \
-" idea).\n" \
+" actions are run when the system detects that someone on the system\n" \
+" console has pressed the CTRL-ALT-DEL key combination. Typically one\n" \
+" wants to run 'reboot' at this point to cause the system to reboot.\n" \
+" Finally the 'shutdown' action specifies the actions to taken when\n" \
+" init is told to reboot. Unmounting filesystems and disabling swap\n" \
+" is a very good here\n" \
"\n" \
" Run repeatedly actions:\n" \
"\n" \
" #::respawn:/sbin/getty 57600 ttyS2\n" \
" \n" \
" # Stuff to do before rebooting\n" \
-" ::ctrlaltdel:/bin/umount -a -r\n" \
-" ::ctrlaltdel:/sbin/swapoff -a\n"
+" ::ctrlaltdel:/sbin/reboot\n" \
+" ::shutdown:/bin/umount -a -r\n" \
+" ::shutdown:/sbin/swapoff -a\n"
#define insmod_trivial_usage \
"[OPTION]... MODULE [symbol=value]..."