mirror of
https://github.com/fleetdm/fleet
synced 2026-04-21 21:47:20 +00:00
* Orbit: Add Fleet Desktop support to Windows * Rename workflow, fix linux build * Do not compile systray on linux * nolint on unused * Fix lint properly * nolint both checkers * Fix monitor logic in desktopRunner * Fix interrupt and execute order
34 lines
771 B
Go
34 lines
771 B
Go
package execuser
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"os/exec"
|
|
)
|
|
|
|
// run uses macOS open command to start application as the current login user.
|
|
func run(path string, opts eopts) error {
|
|
info, err := os.Stat(path)
|
|
if err != nil {
|
|
return fmt.Errorf("stat path %q: %w", path, err)
|
|
}
|
|
|
|
if !info.IsDir() {
|
|
return fmt.Errorf("path is not an .app directory: %s", path)
|
|
}
|
|
var arg []string
|
|
if opts.stderrPath != "" {
|
|
arg = append(arg, "--stderr", opts.stderrPath)
|
|
}
|
|
for _, nv := range opts.env {
|
|
arg = append(arg, "--env", fmt.Sprintf("%s=%s", nv[0], nv[1]))
|
|
}
|
|
arg = append(arg, path)
|
|
cmd := exec.Command("open", arg...)
|
|
cmd.Stderr = os.Stderr
|
|
cmd.Stdout = os.Stdout
|
|
if err := cmd.Run(); err != nil {
|
|
return fmt.Errorf("open path %q: %w", path, err)
|
|
}
|
|
return nil
|
|
}
|