diff --git a/sbin/reboot/reboot.8 b/sbin/reboot/reboot.8 index 0a2fb91b6b0b..e53de69e97ae 100644 --- a/sbin/reboot/reboot.8 +++ b/sbin/reboot/reboot.8 @@ -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 diff --git a/sbin/reboot/reboot.c b/sbin/reboot/reboot.c index 74f8cf01b3b7..d91fc6c97b0f 100644 --- a/sbin/reboot/reboot.c +++ b/sbin/reboot/reboot.c @@ -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);