mirror of
https://github.com/containers/podman.git
synced 2025-06-18 15:39:08 +08:00

Short description in man pages: * Use imperative form Command help (cobra.Command.Short): * Capitalize first letter * Use imperative form * Remove ending full stop when the short description only contains one sentence without any commas Command help (cobra.Command.Long): * Capitalize first letter unless the sentence starts with a command "podman command ..." * Use imperative form when the long description is identical or almost identical to the short description. This modification was only done in a few places. Command tables: * Use imperative form in the "Description" column [NO NEW TESTS NEEDED] Signed-off-by: Erik Sjölund <erik.sjolund@gmail.com>
60 lines
1.6 KiB
Go
60 lines
1.6 KiB
Go
//go:build darwin
|
|
// +build darwin
|
|
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"os/exec"
|
|
"path/filepath"
|
|
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var uninstallCmd = &cobra.Command{
|
|
Use: "uninstall",
|
|
Short: "Uninstall the podman helper agent",
|
|
Long: "Uninstall the podman helper agent, which manages the /var/run/docker.sock link",
|
|
PreRun: silentUsage,
|
|
RunE: uninstall,
|
|
}
|
|
|
|
func init() {
|
|
addPrefixFlag(uninstallCmd)
|
|
rootCmd.AddCommand(uninstallCmd)
|
|
}
|
|
|
|
func uninstall(cmd *cobra.Command, args []string) error {
|
|
userName, _, _, err := getUser()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
labelName := fmt.Sprintf("com.github.containers.podman.helper-%s", userName)
|
|
fileName := filepath.Join("/Library", "LaunchDaemons", labelName+".plist")
|
|
|
|
if err = runDetectErr("launchctl", "unload", fileName); err != nil {
|
|
// Try removing the service by label in case the service is half uninstalled
|
|
if rerr := runDetectErr("launchctl", "remove", labelName); rerr != nil {
|
|
// Exit code 3 = no service to remove
|
|
if exitErr, ok := rerr.(*exec.ExitError); !ok || exitErr.ExitCode() != 3 {
|
|
fmt.Fprintf(os.Stderr, "Warning: service unloading failed: %s\n", err.Error())
|
|
fmt.Fprintf(os.Stderr, "Warning: remove also failed: %s\n", rerr.Error())
|
|
}
|
|
}
|
|
}
|
|
|
|
if err := os.Remove(fileName); err != nil {
|
|
if !os.IsNotExist(err) {
|
|
return fmt.Errorf("could not remove plist file: %s", fileName)
|
|
}
|
|
}
|
|
|
|
helperPath := filepath.Join(installPrefix, "podman", "helper", userName)
|
|
if err := os.RemoveAll(helperPath); err != nil {
|
|
return fmt.Errorf("could not remove helper binary path: %s", helperPath)
|
|
}
|
|
return nil
|
|
}
|