From 90f86b8b2bb7f0a3c834387827c9ec2e1876f342 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 1 Apr 2014 01:12:05 -0400 Subject: not quite working docker container interface --- Propellor/Property/Cmd.hs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'Propellor/Property/Cmd.hs') diff --git a/Propellor/Property/Cmd.hs b/Propellor/Property/Cmd.hs index 88a84968..3e496b82 100644 --- a/Propellor/Property/Cmd.hs +++ b/Propellor/Property/Cmd.hs @@ -1,7 +1,8 @@ module Propellor.Property.Cmd ( cmdProperty, cmdProperty', - scriptProperty + scriptProperty, + serviceRunning, ) where import Control.Applicative @@ -35,3 +36,12 @@ scriptProperty :: [String] -> Property scriptProperty script = cmdProperty "sh" ["-c", shellcmd] where shellcmd = intercalate " ; " ("set -e" : script) + +-- | Ensures that a service is running. +-- +-- Note that due to the general poor state of init scripts, the best +-- we can do is try to start the service, and if it fails, assume +-- this means it's already running. +serviceRunning :: String -> Property +serviceRunning svc = scriptProperty + ["service " ++ shellEscape svc ++ " start >/dev/null 2>&1 || true"] -- cgit v1.2.3