summaryrefslogtreecommitdiffstats
path: root/sbin/shutdown
diff options
context:
space:
mode:
authormsmith <msmith@FreeBSD.org>1998-12-10 23:54:02 +0000
committermsmith <msmith@FreeBSD.org>1998-12-10 23:54:02 +0000
commit005aaf0be2a507e0a02172bab090b6b2622105b8 (patch)
tree776d5d138bdfe88e1c673c95c6b4aca333e25ec3 /sbin/shutdown
parent7d1e74642f2be2e9df7df646316352c0f6f6a788 (diff)
downloadFreeBSD-src-005aaf0be2a507e0a02172bab090b6b2622105b8.zip
FreeBSD-src-005aaf0be2a507e0a02172bab090b6b2622105b8.tar.gz
Add a '-p' flag to shutdown which corresponds to the '-p' flag to halt,
requesting a system power-off after shutdown.
Diffstat (limited to 'sbin/shutdown')
-rw-r--r--sbin/shutdown/shutdown.84
-rw-r--r--sbin/shutdown/shutdown.c24
2 files changed, 21 insertions, 7 deletions
diff --git a/sbin/shutdown/shutdown.8 b/sbin/shutdown/shutdown.8
index 0d40c1c..5a070b0 100644
--- a/sbin/shutdown/shutdown.8
+++ b/sbin/shutdown/shutdown.8
@@ -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
diff --git a/sbin/shutdown/shutdown.c b/sbin/shutdown/shutdown.c
index 025a1c6..a2d487d 100644
--- a/sbin/shutdown/shutdown.c
+++ b/sbin/shutdown/shutdown.c
@@ -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);
OpenPOWER on IntegriCloud