Skip to content

Commit ee5d44e

Browse files
committed
Support executing post-install scripts on UNIX systems
EXPERIMENTAL support for post_install.sh scripts need to understand how to handle sudo requests on Linux host
1 parent 131ac90 commit ee5d44e

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

tools/download.go

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -430,22 +430,24 @@ func extractTarGz(body []byte, location string) (string, error) {
430430
}
431431

432432
func (t *Tools) installDrivers(location string) error {
433-
if runtime.GOOS == "windows" {
434-
if _, err := os.Stat(filepath.Join(location, "post_install.bat")); err == nil {
435-
t.Logger.Println("Installing drivers")
436-
ok := MessageBox("Installing drivers", "We are about to install some drivers needed to use Arduino/Genuino boards\nDo you want to continue?")
437-
t.Logger.Println(ok)
438-
if ok == 6 {
439-
os.Chdir(location)
440-
oscmd := exec.Command("post_install.bat")
441-
TellCommandNotToSpawnShell(oscmd)
442-
t.Logger.Println(oscmd)
443-
err = oscmd.Run()
444-
t.Logger.Println(err)
445-
return err
446-
} else {
447-
return errors.New("Could not install drivers")
448-
}
433+
extension := ".bat"
434+
if runtime.GOOS != "windows" {
435+
extension = ".sh"
436+
}
437+
if _, err := os.Stat(filepath.Join(location, "post_install"+extension)); err == nil {
438+
t.Logger.Println("Installing drivers")
439+
ok := MessageBox("Installing drivers", "We are about to install some drivers needed to use Arduino/Genuino boards\nDo you want to continue?")
440+
t.Logger.Println(ok)
441+
if ok == 6 {
442+
os.Chdir(location)
443+
oscmd := exec.Command("post_install.bat")
444+
TellCommandNotToSpawnShell(oscmd)
445+
t.Logger.Println(oscmd)
446+
err = oscmd.Run()
447+
t.Logger.Println(err)
448+
return err
449+
} else {
450+
return errors.New("Could not install drivers")
449451
}
450452
}
451453
return nil

0 commit comments

Comments
 (0)