code.flowtr.dev/mirrors/u-root@v1.0.0/examples/uinit/uinit.go (about) 1 // Copyright 2012-2017 the u-root Authors. All rights reserved 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // This is a basic init script. 6 package main 7 8 import ( 9 "log" 10 "os" 11 "os/exec" 12 "strings" 13 ) 14 15 var ( 16 commands = []string{ 17 "/bbin/date", 18 "/bbin/dhclient -ipv6=false", 19 "/bbin/ip a", 20 "/bbin/elvish", 21 "/bbin/rush", 22 "/bbin/shutdown halt", 23 } 24 ) 25 26 func main() { 27 for _, line := range commands { 28 log.Printf("Executing Command: %v", line) 29 cmdSplit := strings.Split(line, " ") 30 if len(cmdSplit) == 0 { 31 continue 32 } 33 34 cmd := exec.Command(cmdSplit[0], cmdSplit[1:]...) 35 cmd.Stdin = os.Stdin 36 cmd.Stderr = os.Stderr 37 cmd.Stdout = os.Stdout 38 if err := cmd.Run(); err != nil { 39 log.Print(err) 40 } 41 42 } 43 log.Print("Uinit Done!") 44 }