(c *cli.Context)
| 171 | } |
| 172 | |
| 173 | func uninstallLaunchd(c *cli.Context) error { |
| 174 | log := logger.CreateLoggerFromContext(c, logger.EnableTerminalLog) |
| 175 | |
| 176 | if isRootUser() { |
| 177 | log.Info().Msg("Uninstalling cloudflared as a system launch daemon") |
| 178 | } else { |
| 179 | log.Info().Msg("Uninstalling cloudflared as a user launch agent") |
| 180 | } |
| 181 | installPath, err := installPath() |
| 182 | if err != nil { |
| 183 | return errors.Wrap(err, "error determining install path") |
| 184 | } |
| 185 | stdoutPath, err := stdoutPath() |
| 186 | if err != nil { |
| 187 | return errors.Wrap(err, "error determining stdout path") |
| 188 | } |
| 189 | stderrPath, err := stderrPath() |
| 190 | if err != nil { |
| 191 | return errors.Wrap(err, "error determining stderr path") |
| 192 | } |
| 193 | launchdTemplate := newLaunchdTemplate(installPath, stdoutPath, stderrPath) |
| 194 | plistPath, err := launchdTemplate.ResolvePath() |
| 195 | if err != nil { |
| 196 | log.Err(err).Msg("error resolving launchd template path") |
| 197 | return err |
| 198 | } |
| 199 | err = runCommand("launchctl", "unload", plistPath) |
| 200 | if err != nil { |
| 201 | log.Err(err).Msg("error unloading launchd") |
| 202 | return err |
| 203 | } |
| 204 | |
| 205 | err = launchdTemplate.Remove() |
| 206 | if err == nil { |
| 207 | log.Info().Msg("Launchd for cloudflared was uninstalled successfully") |
| 208 | } |
| 209 | return err |
| 210 | } |
| 211 | |
| 212 | func userHomeDir() (string, error) { |
| 213 | // This returns the home dir of the executing user using OS-specific method |
nothing calls this directly
no test coverage detected