wslkd/wslkd.go
xiaoqidun 41e3700859
All checks were successful
continuous-integration/drone/push Build is passing
feat(升级依赖): 升级依赖
2022-11-23 21:59:00 +08:00

45 lines
881 B
Go

package main
import (
"flag"
"github.com/xiaoqidun/gowsl"
"log"
"os"
"strings"
"sync"
"syscall"
)
func main() {
var d string
flag.StringVar(&d, "d", "Debian", "distribution")
flag.Parse()
waitGroup := &sync.WaitGroup{}
distroList := strings.Split(d, ",")
for i := 0; i < len(distroList); i++ {
distro := strings.TrimSpace(distroList[i])
if distro == "" {
continue
}
waitGroup.Add(1)
go exec(waitGroup, distro)
}
waitGroup.Wait()
}
func exec(done *sync.WaitGroup, distro string) {
defer done.Done()
if !gowsl.Registered(distro) {
log.Printf("%v does not exist\n", distro)
return
}
cmd := gowsl.Command(distro, "", "/bin/bash")
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true}
if err := cmd.Run(); err != nil {
log.Printf("%v cmd run err: %v", distro, err)
}
}