diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-05-02 22:33:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-02 22:33:09 +0200 |
commit | b5e5585ada50a887f439e513c5deae30c89648de (patch) | |
tree | 795c9e94db4d51012f40ccd0287504d39a4de83b /pkg/adapter/containers.go | |
parent | 6bcbb88715fd9cab45eb668bba5ba83228e16883 (diff) | |
parent | c18ad2bfd9034fe6b80e3f33c076af731be6778b (diff) | |
download | podman-b5e5585ada50a887f439e513c5deae30c89648de.tar.gz podman-b5e5585ada50a887f439e513c5deae30c89648de.tar.bz2 podman-b5e5585ada50a887f439e513c5deae30c89648de.zip |
Merge pull request #2985 from baude/generatesystemd
Generate Systemd
Diffstat (limited to 'pkg/adapter/containers.go')
-rw-r--r-- | pkg/adapter/containers.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/pkg/adapter/containers.go b/pkg/adapter/containers.go index eb90ab50e..d575bc9b0 100644 --- a/pkg/adapter/containers.go +++ b/pkg/adapter/containers.go @@ -18,6 +18,7 @@ import ( "github.com/containers/libpod/cmd/podman/shared" "github.com/containers/libpod/libpod" "github.com/containers/libpod/pkg/adapter/shortcuts" + "github.com/containers/libpod/pkg/systemdgen" "github.com/containers/storage" "github.com/pkg/errors" "github.com/sirupsen/logrus" @@ -940,3 +941,20 @@ func (r *LocalRuntime) Port(c *cliconfig.PortValues) ([]*Container, error) { } return portContainers, nil } + +// GenerateSystemd creates a unit file for a container +func (r *LocalRuntime) GenerateSystemd(c *cliconfig.GenerateSystemdValues) (string, error) { + ctr, err := r.Runtime.LookupContainer(c.InputArgs[0]) + if err != nil { + return "", err + } + timeout := int(ctr.StopTimeout()) + if c.StopTimeout >= 0 { + timeout = int(c.StopTimeout) + } + name := ctr.ID() + if c.Name { + name = ctr.Name() + } + return systemdgen.CreateSystemdUnitAsString(name, ctr.ID(), c.RestartPolicy, ctr.Config().StaticDir, timeout) +} |