Tag v0.1.0
This commit is contained in:
+17
-8
@@ -8,6 +8,7 @@ import (
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
"g.fc.run/ai/byre/internal/tailscale"
|
||||
)
|
||||
@@ -69,19 +70,27 @@ func installCmd() {
|
||||
}
|
||||
fmt.Println("wrote", plistPath)
|
||||
|
||||
domain := fmt.Sprintf("gui/%d", os.Getuid())
|
||||
service := domain + "/" + serviceLabel
|
||||
if exec.Command("launchctl", "print", service).Run() == nil {
|
||||
run("launchctl", "bootout", service)
|
||||
}
|
||||
run("launchctl", "bootstrap", domain, plistPath)
|
||||
fmt.Println("started", service, "running", exe)
|
||||
|
||||
url, err := tailscale.ServeRoot(context.Background(), "http://"+defaultListen)
|
||||
if err != nil {
|
||||
fatal("tailscale serve", "err", err)
|
||||
}
|
||||
fmt.Println("byre is at", url)
|
||||
|
||||
domain := fmt.Sprintf("gui/%d", os.Getuid())
|
||||
service := domain + "/" + serviceLabel
|
||||
if exec.Command("launchctl", "print", service).Run() != nil {
|
||||
run("launchctl", "bootstrap", domain, plistPath)
|
||||
fmt.Println("started", service, "running", exe)
|
||||
return
|
||||
}
|
||||
// bootout kills every process the service started, which includes this one when an agent runs it.
|
||||
reload := exec.Command("/bin/sh", "-c", `launchctl bootout "$1"; launchctl bootstrap "$2" "$3"`, "sh", service, domain, plistPath)
|
||||
reload.SysProcAttr = &syscall.SysProcAttr{Setsid: true}
|
||||
err = reload.Start()
|
||||
if err != nil {
|
||||
fatal("restart service", "err", err)
|
||||
}
|
||||
fmt.Println("restarting", service, "on", exe)
|
||||
}
|
||||
|
||||
func run(name string, args ...string) {
|
||||
|
||||
Reference in New Issue
Block a user