summaryrefslogtreecommitdiff
path: root/cmd/podman/generate/systemd.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/podman/generate/systemd.go')
-rw-r--r--cmd/podman/generate/systemd.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/cmd/podman/generate/systemd.go b/cmd/podman/generate/systemd.go
index 2ab33c26b..cdc103865 100644
--- a/cmd/podman/generate/systemd.go
+++ b/cmd/podman/generate/systemd.go
@@ -21,6 +21,7 @@ import (
const (
restartPolicyFlagName = "restart-policy"
timeFlagName = "time"
+ newFlagName = "new"
)
var (
@@ -53,10 +54,11 @@ func init() {
flags := systemdCmd.Flags()
flags.BoolVarP(&systemdOptions.Name, "name", "n", false, "Use container/pod names instead of IDs")
flags.BoolVarP(&files, "files", "f", false, "Generate .service files instead of printing to stdout")
+ flags.BoolVar(&systemdOptions.TemplateUnitFile, "template", false, "Make it a template file and use %i and %I specifiers. Working only for containers")
flags.UintVarP(&systemdTimeout, timeFlagName, "t", containerConfig.Engine.StopTimeout, "Stop timeout override")
_ = systemdCmd.RegisterFlagCompletionFunc(timeFlagName, completion.AutocompleteNone)
- flags.BoolVarP(&systemdOptions.New, "new", "", false, "Create a new container or pod instead of starting an existing one")
+ flags.BoolVar(&systemdOptions.New, newFlagName, false, "Create a new container or pod instead of starting an existing one")
flags.BoolVarP(&systemdOptions.NoHeader, "no-header", "", false, "Skip header generation")
containerPrefixFlagName := "container-prefix"
@@ -93,6 +95,13 @@ func systemd(cmd *cobra.Command, args []string) error {
logrus.Warnln("The generated units should be placed on your remote system")
}
+ if cmd.Flags().Changed(newFlagName) && !systemdOptions.New && systemdOptions.TemplateUnitFile {
+ return errors.New("--template cannot be set with --new=false")
+ }
+ if !systemdOptions.New && systemdOptions.TemplateUnitFile {
+ systemdOptions.New = true
+ }
+
reports, err := registry.ContainerEngine().GenerateSystemd(registry.GetContext(), args[0], systemdOptions)
if err != nil {
return err