Skip to content

Commit da20120

Browse files
committed
Improve reboot function and add an arg for them
1 parent f26a8e4 commit da20120

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ Argument options will be applied before the config fil
5555
5656
-nokeymap Don't config the keymap for the new system
5757
58+
-noreboot Don't reboot the system after the prosess
5859
`
5960

6061
func PrintHelp() {
@@ -85,6 +86,7 @@ func main() {
8586
src.Keymap()
8687
src.ConfigRootPasswd()
8788
src.FinalCmds()
89+
src.Reboot()
8890
case "pacstrap":
8991
src.Wifi()
9092
src.PacmanConf()

src/src.go

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"os"
77
"os/exec"
88
"strings"
9+
"time"
910

1011
"github.com/Tom5521/ArchLinuxInstaller/data"
1112
"github.com/Tom5521/CmdRunTools/command"
@@ -262,7 +263,7 @@ func Wifi() {
262263
fmGreen("Connected to " + wifi.Name)
263264
}
264265
} else {
265-
Error("Warning: Adaptator not found")
266+
Warn("Adaptator not found")
266267
}
267268
wifi_pkg = "networkmanger iwd"
268269
}
@@ -389,10 +390,25 @@ func FinalCmds() {
389390
Error("Error using arch-chroot.")
390391
}
391392
}
392-
if conf.Reboot {
393+
394+
}
395+
396+
func Reboot() {
397+
if strings.Contains(args, "-noreboot") {
398+
return
399+
}
400+
var err error
401+
if !conf.Reboot {
393402
err = sh.SetAndRun("reboot")
394403
if err != nil {
395404
Error("Error in... in... Reboot? wtf")
405+
for i := 5; i != 0; i-- {
406+
time.Sleep(1 * time.Second)
407+
fmt.Print(f("\rRetrying in...%v seconds", i))
408+
if i == 1 {
409+
Reboot()
410+
}
411+
}
396412
}
397413
}
398414
}

0 commit comments

Comments
 (0)