cmd/tailscaled: remove tailscaled binary on uninstall-system-daemon

Signed-off-by: Maisem Ali <maisem@tailscale.com>
This commit is contained in:
Maisem Ali 2021-03-31 15:33:44 -07:00 committed by Maisem Ali
parent db13b2d0c8
commit 1c98c5f103

View File

@ -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
}