MCPcopy
hub / github.com/cloudflare/cloudflared / uninstallLaunchd

Function uninstallLaunchd

cmd/cloudflared/macos_service.go:173–210  ·  view source on GitHub ↗
(c *cli.Context)

Source from the content-addressed store, hash-verified

171}
172
173func 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
212func userHomeDir() (string, error) {
213 // This returns the home dir of the executing user using OS-specific method

Callers

nothing calls this directly

Calls 10

CreateLoggerFromContextFunction · 0.92
isRootUserFunction · 0.85
installPathFunction · 0.85
stdoutPathFunction · 0.85
stderrPathFunction · 0.85
newLaunchdTemplateFunction · 0.85
ResolvePathMethod · 0.80
runCommandFunction · 0.70
RemoveMethod · 0.65
ErrMethod · 0.45

Tested by

no test coverage detected