Add a '-p' flag to shutdown which corresponds to the '-p' flag to halt,
requesting a system power-off after shutdown.
This commit is contained in:
parent
ada2efda3a
commit
dca1101494
@ -30,7 +30,7 @@
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" @(#)shutdown.8 8.1 (Berkeley) 6/5/93
|
||||
.\" $Id$
|
||||
.\" $Id: shutdown.8,v 1.4 1998/08/03 06:22:43 charnier Exp $
|
||||
.\"
|
||||
.Dd June 5, 1993
|
||||
.Dt SHUTDOWN 8
|
||||
@ -71,6 +71,8 @@ system multi-user with logins disabled (for all but super-user).
|
||||
Prevent the normal
|
||||
.Xr sync 2
|
||||
before stopping.
|
||||
.It Fl p
|
||||
The system will turn the power off after shutdown if it can.
|
||||
.It Fl r
|
||||
.Nm Shutdown
|
||||
executes
|
||||
|
@ -42,7 +42,7 @@ static const char copyright[] =
|
||||
static char sccsid[] = "@(#)shutdown.c 8.2 (Berkeley) 2/16/94";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$Id$";
|
||||
"$Id: shutdown.c,v 1.13 1998/08/03 06:22:43 charnier Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -93,7 +93,7 @@ struct interval {
|
||||
#undef S
|
||||
|
||||
static time_t offset, shuttime;
|
||||
static int dohalt, doreboot, killflg, mbuflen;
|
||||
static int dohalt, dopower, doreboot, killflg, mbuflen;
|
||||
static char *nosync, *whom, mbuf[BUFSIZ];
|
||||
|
||||
void badtime __P((void));
|
||||
@ -121,7 +121,7 @@ main(argc, argv)
|
||||
#endif
|
||||
nosync = NULL;
|
||||
readstdin = 0;
|
||||
while ((ch = getopt(argc, argv, "-hknr")) != -1)
|
||||
while ((ch = getopt(argc, argv, "-hknpr")) != -1)
|
||||
switch (ch) {
|
||||
case '-':
|
||||
readstdin = 1;
|
||||
@ -135,6 +135,9 @@ main(argc, argv)
|
||||
case 'n':
|
||||
nosync = "-n";
|
||||
break;
|
||||
case 'p':
|
||||
dopower = 1;
|
||||
break;
|
||||
case 'r':
|
||||
doreboot = 1;
|
||||
break;
|
||||
@ -148,8 +151,8 @@ main(argc, argv)
|
||||
if (argc < 1)
|
||||
usage();
|
||||
|
||||
if (doreboot && dohalt) {
|
||||
warnx("incompatible switches -h and -r");
|
||||
if ((doreboot + dohalt + dopower) > 1) {
|
||||
warnx("incompatible switches -h, -p and -r");
|
||||
usage();
|
||||
}
|
||||
getoffset(*argv++);
|
||||
@ -326,7 +329,8 @@ die_you_gravy_sucking_pig_dog()
|
||||
char *empty_environ[] = { NULL };
|
||||
|
||||
syslog(LOG_NOTICE, "%s by %s: %s",
|
||||
doreboot ? "reboot" : dohalt ? "halt" : "shutdown", whom, mbuf);
|
||||
doreboot ? "reboot" : dohalt ? "halt" : dopower ? "power-down" :
|
||||
"shutdown", whom, mbuf);
|
||||
(void)sleep(2);
|
||||
|
||||
(void)printf("\r\nSystem shutdown time has arrived\007\007\r\n");
|
||||
@ -339,6 +343,8 @@ die_you_gravy_sucking_pig_dog()
|
||||
(void)printf("reboot");
|
||||
else if (dohalt)
|
||||
(void)printf("halt");
|
||||
else if (dopower)
|
||||
(void)printf("power-down");
|
||||
if (nosync)
|
||||
(void)printf(" no sync");
|
||||
(void)printf("\nkill -HUP 1\n");
|
||||
@ -355,6 +361,12 @@ die_you_gravy_sucking_pig_dog()
|
||||
syslog(LOG_ERR, "shutdown: can't exec %s: %m.", _PATH_HALT);
|
||||
warn(_PATH_HALT);
|
||||
}
|
||||
else if (dopower) {
|
||||
execle(_PATH_HALT, "halt", "-l", "-p", nosync,
|
||||
(char *)NULL, empty_environ);
|
||||
syslog(LOG_ERR, "shutdown: can't exec %s: %m.", _PATH_HALT);
|
||||
warn(_PATH_HALT);
|
||||
}
|
||||
(void)kill(1, SIGTERM); /* to single user */
|
||||
#endif
|
||||
finish(0);
|
||||
|
Loading…
Reference in New Issue
Block a user