2014-04-08 23:31:03 +00:00
|
|
|
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
|
2014-04-18 07:59:06 +00:00
|
|
|
running svc = property ("running " ++ svc) $ do
|
2014-04-10 05:46:33 +00:00
|
|
|
void $ ensureProperty $
|
|
|
|
scriptProperty ["service " ++ shellEscape svc ++ " start >/dev/null 2>&1 || true"]
|
|
|
|
return NoChange
|
2014-04-08 23:31:03 +00:00
|
|
|
|
|
|
|
restarted :: ServiceName -> Property
|
2014-04-18 07:59:06 +00:00
|
|
|
restarted svc = property ("restarted " ++ svc) $ do
|
2014-04-08 23:31:03 +00:00
|
|
|
void $ ensureProperty $
|
|
|
|
scriptProperty ["service " ++ shellEscape svc ++ " restart >/dev/null 2>&1 || true"]
|
|
|
|
return NoChange
|
2014-04-10 05:46:33 +00:00
|
|
|
|
|
|
|
reloaded :: ServiceName -> Property
|
2014-04-18 07:59:06 +00:00
|
|
|
reloaded svc = property ("reloaded " ++ svc) $ do
|
2014-04-10 05:46:33 +00:00
|
|
|
void $ ensureProperty $
|
|
|
|
scriptProperty ["service " ++ shellEscape svc ++ " reload >/dev/null 2>&1 || true"]
|
|
|
|
return NoChange
|