cmd/tailscaled: remove tailscaled binary on uninstall-system-daemon
@@ -73,9 +73,18 @@ func uninstallSystemDaemonDarwin(args []string) (ret error) {
}
}
- err = os.Remove(sysPlist)
+ if err := os.Remove(sysPlist); err != nil {
if os.IsNotExist(err) {
err = nil
+ }
+ if ret == nil {
+ ret = err
+ }
+ }
+ if err := os.Remove(targetBin); err != nil {
+ if os.IsNotExist(err) {
+ err = nil
+ }
if ret == nil {
ret = err
}
@@ -93,6 +102,9 @@ func installSystemDaemonDarwin(args []string) (err error) {
}
}()
+ // Best effort:
+ uninstallSystemDaemonDarwin(nil)
+
// Copy ourselves to /usr/local/bin/tailscaled.
if err := os.MkdirAll(filepath.Dir(targetBin), 0755); err != nil {
return err
@@ -127,9 +139,6 @@ func installSystemDaemonDarwin(args []string) (err error) {
return err
}
- // Best effort:
- uninstallSystemDaemonDarwin(nil)
-
if err := ioutil.WriteFile(sysPlist, []byte(darwinLaunchdPlist), 0700); err != nil {
return err
}
