diff options
| author | Joey Hess <joey@kitenet.net> | 2014-04-08 19:31:03 -0400 |
|---|---|---|
| committer | Joey Hess <joey@kitenet.net> | 2014-04-08 19:31:03 -0400 |
| commit | a52a2a89dfe92d7bed4a6446101657a288fd3bae (patch) | |
| tree | 207f98df36a858276269dcf87926566ea082018b /Propellor/Property/Service.hs | |
| parent | 7561ee0443a33ffc0574dc6b606c9128da3fba4f (diff) | |
serviceInstalledRunning
Diffstat (limited to 'Propellor/Property/Service.hs')
| -rw-r--r-- | Propellor/Property/Service.hs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/Propellor/Property/Service.hs b/Propellor/Property/Service.hs new file mode 100644 index 00000000..2fb3e0c6 --- /dev/null +++ b/Propellor/Property/Service.hs @@ -0,0 +1,25 @@ +module Propellor.Property.Service where + +import Propellor +import Utility.SafeCommand + +type ServiceName = String + +-- | Ensures that a service is running. Does not ensure that +-- any package providing that service is installed. See +-- Apt.serviceInstalledRunning +-- +-- 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. +running :: ServiceName -> Property +running svc = Property ("running " ++ svc) $ do + void $ ensureProperty $ + scriptProperty ["service " ++ shellEscape svc ++ " start >/dev/null 2>&1 || true"] + return NoChange + +restarted :: ServiceName -> Property +restarted svc = Property ("restarted " ++ svc) $ do + void $ ensureProperty $ + scriptProperty ["service " ++ shellEscape svc ++ " restart >/dev/null 2>&1 || true"] + return NoChange |
