summaryrefslogtreecommitdiff
path: root/src/Propellor/Property/Systemd.hs
diff options
context:
space:
mode:
authorJoey Hess2015-05-29 10:09:22 -0400
committerJoey Hess2015-05-29 10:09:22 -0400
commitc8f9e11779609dffd9f1480e39b2d28814a00212 (patch)
tree009283ccecc4150a8d6504128f1d1de3dc0312df /src/Propellor/Property/Systemd.hs
parent5b0c4d1f1a3f8e61ff2d44dcef39ccd553463920 (diff)
parent8d98d4351b33c0df716dbaf269f5b5ac9db4a39a (diff)
Merge branch 'joeyconfig'
Diffstat (limited to 'src/Propellor/Property/Systemd.hs')
-rw-r--r--src/Propellor/Property/Systemd.hs20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/Propellor/Property/Systemd.hs b/src/Propellor/Property/Systemd.hs
index 78a99963..c698f780 100644
--- a/src/Propellor/Property/Systemd.hs
+++ b/src/Propellor/Property/Systemd.hs
@@ -215,15 +215,19 @@ enterScript c@(Container name _ _) = setup <!> teardown
where
setup = combineProperties ("generated " ++ enterScriptFile c)
[ scriptfile `File.hasContent`
- [ "#!/bin/sh"
+ [ "#!/usr/bin/perl"
, "# Generated by propellor"
- , "pid=\"$(machinectl show " ++ shellEscape name ++ " -p Leader | cut -d= -f2)\" || true"
- , "if [ -n \"$pid\" ]; then"
- , "\tnsenter -p -u -n -i -m -t \"$pid\" \"$@\""
- , "else"
- , "\techo container not running >&2"
- , "\texit 1"
- , "fi"
+ , "my $pid=`machinectl show " ++ shellEscape name ++ " -p Leader | cut -d= -f2`;"
+ , "chomp $pid;"
+ , "if (length $pid) {"
+ , "\tforeach my $var (keys %ENV) {"
+ , "\t\tdelete $ENV{$var} unless $var eq 'PATH' || $var eq 'TERM';"
+ , "\t}"
+ , "\texec('nsenter', '-p', '-u', '-n', '-i', '-m', '-t', $pid, @ARGV);"
+ , "} else {"
+ , "\tdie 'container not running';"
+ , "}"
+ , "exit(1);"
]
, scriptfile `File.mode` combineModes (readModes ++ executeModes)
]