Skip to content

Commit 8fa5ab1

Browse files
committed
Fix ui start on Darwin
1 parent b029539 commit 8fa5ab1

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

client/internal/updatemanager/installer/installer_common.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ func validateTargetVersion(targetVersion string) error {
233233
}
234234

235235
func copyFile(src, dst string) error {
236+
log.Infof("copying %s to %s", src, dst)
236237
in, err := os.Open(src)
237238
if err != nil {
238239
return fmt.Errorf("open source: %w", err)

client/internal/updatemanager/installer/installer_run_darwin.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ import (
1717

1818
const (
1919
daemonName = "netbird"
20-
uiName = "netbird-ui"
2120
updaterBinary = "updater"
2221

2322
defaultTempDir = "/var/lib/netbird/tmp-install"
2423

2524
pkgDownloadURL = "https://github.com/netbirdio/netbird/releases/download/v%version/netbird_%version_darwin_%arch.pkg"
2625

27-
updaterSrcPath = "/Applications/NetBird.app/Contents/MacOS/netbird-ui"
26+
//updaterSrcPath = "/Applications/NetBird.app/Contents/MacOS/netbird-ui"
27+
updaterSrcPath = "/Users/pzoli/Desktop/NetBird.app/Contents/MacOS/netbird-ui"
2828
)
2929

3030
var (
@@ -53,6 +53,7 @@ func (u *Installer) Setup(ctx context.Context, dryRun bool, targetVersion string
5353
}()
5454

5555
if dryRun {
56+
time.Sleep(10 * time.Second)
5657
log.Infof("dry-run mode enabled, skipping actual installation")
5758
resultErr = fmt.Errorf("dry-run mode enabled")
5859
return
@@ -100,8 +101,7 @@ func (u *Installer) startDaemon(daemonFolder string) error {
100101
}
101102

102103
func (u *Installer) startUIAsUser(daemonFolder string) error {
103-
uiPath := filepath.Join(daemonFolder, uiName)
104-
log.Infof("starting netbird-ui: %s", uiPath)
104+
log.Infof("starting netbird-ui: %s", updaterSrcPath)
105105

106106
// Get the current console user
107107
cmd := exec.Command("stat", "-f", "%Su", "/dev/console")
@@ -125,8 +125,8 @@ func (u *Installer) startUIAsUser(daemonFolder string) error {
125125

126126
// Start the UI process as the console user using launchctl
127127
// This ensures the app runs in the user's context with proper GUI access
128-
launchCmd := exec.Command("launchctl", "asuser", userInfo.Uid, "sudo", "-u", username, uiPath)
129-
128+
launchCmd := exec.Command("launchctl", "asuser", userInfo.Uid, "open", "-a", updaterSrcPath)
129+
log.Infof("launchCmd: %s", launchCmd.String())
130130
// Set the user's home directory for proper macOS app behavior
131131
launchCmd.Env = append(os.Environ(), "HOME="+userInfo.HomeDir)
132132

0 commit comments

Comments
 (0)