Skip to content

Commit

Permalink
Merge pull request u-root#124 from systemboot/interactive
Browse files Browse the repository at this point in the history
uinit: Add interactive mode
  • Loading branch information
Zaolin committed Jun 5, 2019
2 parents e50761f + 1695fcd commit 74360c9
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions uinit/main.go
Expand Up @@ -5,15 +5,17 @@ import (
"log"
"os"
"os/exec"
"os/signal"
"time"

"github.com/systemboot/systemboot/pkg/booter"
)

var (
doQuiet = flag.Bool("q", false, "Disable verbose output")
interval = flag.Int("I", 1, "Interval in seconds before looping to the next boot command")
noDefaultBoot = flag.Bool("nodefault", false, "Do not attempt default boot entries if regular ones fail")
allowInteractive = flag.Bool("i", true, "Allow user to interrupt boot process and run commands")
doQuiet = flag.Bool("q", false, "Disable verbose output")
interval = flag.Int("I", 1, "Interval in seconds before looping to the next boot command")
noDefaultBoot = flag.Bool("nodefault", false, "Do not attempt default boot entries if regular ones fail")
)

var defaultBootsequence = [][]string{
Expand All @@ -32,13 +34,18 @@ func main() {
|____/ \__, |___/\__\___|_| |_| |_|_.__/ \___/ \___/ \__|
|___/
`)
log.Printf("**************************************************************************")
log.Print("Starting boot sequence, press CTRL-C within 5 seconds to drop into a shell")
log.Printf("**************************************************************************")
time.Sleep(5 * time.Second)

sleepInterval := time.Duration(*interval) * time.Second

if *allowInteractive {
log.Printf("**************************************************************************")
log.Print("Starting boot sequence, press CTRL-C within 5 seconds to drop into a shell")
log.Printf("**************************************************************************")
time.Sleep(5 * time.Second)
} else {
signal.Ignore()
}

// Get and show boot entries
bootEntries := booter.GetBootEntries()
log.Printf("BOOT ENTRIES:")
Expand Down

0 comments on commit 74360c9

Please sign in to comment.