mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-12-04 05:58:57 +00:00
reboot: Implement -D from nextboot
Implement -D from nextboot.sh which deletes the nextboot.conf file and exists. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D43822
This commit is contained in:
parent
cfeedadfbd
commit
2c47954811
@ -36,16 +36,16 @@
|
||||
.Nd stopping and restarting the system
|
||||
.Sh SYNOPSIS
|
||||
.Nm halt
|
||||
.Op Fl flNnpq
|
||||
.Op Fl DflNnpq
|
||||
.Op Fl k Ar kernel
|
||||
.Nm
|
||||
.Op Fl cdflNnpqr
|
||||
.Op Fl cDdflNnpqr
|
||||
.Op Fl k Ar kernel
|
||||
.Nm fasthalt
|
||||
.Op Fl flNnpq
|
||||
.Op Fl DflNnpq
|
||||
.Op Fl k Ar kernel
|
||||
.Nm fastboot
|
||||
.Op Fl dflNnpq
|
||||
.Op Fl dDflNnpq
|
||||
.Op Fl k Ar kernel
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
@ -77,6 +77,10 @@ driver implements the power cycle functionality and only on hardware
|
||||
with a BMC that supports power cycling.
|
||||
Unlike power off, the amount of hardware that supports power cycling
|
||||
is small.
|
||||
.It Fl D
|
||||
Delete existing
|
||||
.Nm nextboot
|
||||
configuration and exit.
|
||||
.It Fl d
|
||||
The system is requested to create a crash dump.
|
||||
This option is
|
||||
|
@ -95,7 +95,7 @@ main(int argc, char *argv[])
|
||||
struct utmpx utx;
|
||||
const struct passwd *pw;
|
||||
int ch, howto, i, sverrno;
|
||||
bool fflag, lflag, nflag, qflag, Nflag;
|
||||
bool Dflag, fflag, lflag, Nflag, nflag, qflag;
|
||||
uint64_t pageins;
|
||||
const char *user, *kernel = NULL;
|
||||
|
||||
@ -104,12 +104,15 @@ main(int argc, char *argv[])
|
||||
howto = RB_HALT;
|
||||
} else
|
||||
howto = 0;
|
||||
fflag = lflag = nflag = qflag = Nflag = false;
|
||||
while ((ch = getopt(argc, argv, "cdk:lNnpqr")) != -1)
|
||||
Dflag = fflag = lflag = Nflag = nflag = qflag = false;
|
||||
while ((ch = getopt(argc, argv, "cDdk:lNnpqr")) != -1)
|
||||
switch(ch) {
|
||||
case 'c':
|
||||
howto |= RB_POWERCYCLE;
|
||||
break;
|
||||
case 'D':
|
||||
Dflag = true;
|
||||
break;
|
||||
case 'd':
|
||||
howto |= RB_DUMP;
|
||||
break;
|
||||
@ -148,6 +151,8 @@ main(int argc, char *argv[])
|
||||
if (argc != 0)
|
||||
usage();
|
||||
|
||||
if (Dflag && ((howto & ~RB_HALT) != 0 || kernel != NULL))
|
||||
errx(1, "cannot delete existing nextboot config and do anything else");
|
||||
if ((howto & (RB_DUMP | RB_HALT)) == (RB_DUMP | RB_HALT))
|
||||
errx(1, "cannot dump (-d) when halting; must reboot instead");
|
||||
if (Nflag && (howto & RB_NOSYNC) != 0)
|
||||
@ -163,6 +168,12 @@ main(int argc, char *argv[])
|
||||
err(1, NULL);
|
||||
}
|
||||
|
||||
if (Dflag) {
|
||||
if (unlink(PATH_NEXTBOOT) != 0)
|
||||
err(1, "unlink %s", PATH_NEXTBOOT);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (qflag) {
|
||||
reboot(howto);
|
||||
err(1, NULL);
|
||||
|
Loading…
Reference in New Issue
Block a user