From 4ea2771b69617bc537687f9b2fec4b0a32880de5 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 8 Apr 2014 17:10:52 -0400 Subject: propellor spin --- Propellor/Property/Cmd.hs | 11 ++++++++++- Propellor/Property/OpenId.hs | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'Propellor/Property') diff --git a/Propellor/Property/Cmd.hs b/Propellor/Property/Cmd.hs index dc5073d3..f661cf81 100644 --- a/Propellor/Property/Cmd.hs +++ b/Propellor/Property/Cmd.hs @@ -4,6 +4,7 @@ module Propellor.Property.Cmd ( scriptProperty, userScriptProperty, serviceRunning, + serviceRestarted, ) where import Control.Monad @@ -47,13 +48,21 @@ userScriptProperty user script = cmdProperty "su" ["-c", shellcmd, user] where shellcmd = intercalate " ; " ("set -e" : "cd" : script) +type ServiceName = String + -- | 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 :: ServiceName -> Property serviceRunning svc = Property ("running " ++ svc) $ do void $ ensureProperty $ scriptProperty ["service " ++ shellEscape svc ++ " start >/dev/null 2>&1 || true"] return NoChange + +serviceRestarted :: ServiceName -> Property +serviceRestarted svc = Property ("restarted " ++ svc) $ do + void $ ensureProperty $ + scriptProperty ["service " ++ shellEscape svc ++ " restart >/dev/null 2>&1 || true"] + return NoChange diff --git a/Propellor/Property/OpenId.hs b/Propellor/Property/OpenId.hs index 4ebf18f0..0f207a53 100644 --- a/Propellor/Property/OpenId.hs +++ b/Propellor/Property/OpenId.hs @@ -9,6 +9,8 @@ providerFor users = propertyList ("openid provider") $ [ serviceRunning "apache2" `requires` Apt.installed ["apache2"] , Apt.installed ["simpleid"] + `onChange` serviceRestarted "apache2" + , serviceRestarted "apache2" ] ++ map identfile users where identfile u = File.hasPrivContent $ concat -- cgit v1.2.3