summaryrefslogtreecommitdiff
path: root/Propellor/Property/Apt.hs
diff options
context:
space:
mode:
authorJoey Hess2014-04-08 19:31:03 -0400
committerJoey Hess2014-04-08 19:31:03 -0400
commita52a2a89dfe92d7bed4a6446101657a288fd3bae (patch)
tree207f98df36a858276269dcf87926566ea082018b /Propellor/Property/Apt.hs
parent7561ee0443a33ffc0574dc6b606c9128da3fba4f (diff)
serviceInstalledRunning
Diffstat (limited to 'Propellor/Property/Apt.hs')
-rw-r--r--Propellor/Property/Apt.hs12
1 files changed, 9 insertions, 3 deletions
diff --git a/Propellor/Property/Apt.hs b/Propellor/Property/Apt.hs
index ac1d9a12..ff9b3de9 100644
--- a/Propellor/Property/Apt.hs
+++ b/Propellor/Property/Apt.hs
@@ -8,6 +8,7 @@ import Control.Monad
import Propellor
import qualified Propellor.Property.File as File
+import qualified Propellor.Property.Service as Service
import Propellor.Property.File (Line)
sourcesList :: FilePath
@@ -149,9 +150,7 @@ autoRemove = runApt ["-y", "autoremove"]
unattendedUpgrades :: RevertableProperty
unattendedUpgrades = RevertableProperty enable disable
where
- enable = setup True
- `before` installed ["cron"]
- `before` serviceRunning "cron"
+ enable = setup True `before` Service.running "cron"
disable = setup False
setup enabled = (if enabled then installed else removed) ["unattended-upgrades"]
@@ -176,3 +175,10 @@ reConfigure package vals = reconfigure `requires` setselections
hPutStrLn h $ unwords [package, template, tmpltype, value]
hClose h
reconfigure = cmdProperty "dpkg-reconfigure" ["-fnone", package]
+
+-- | Ensures that a service is installed and running.
+--
+-- Assumes that there is a 1:1 mapping between service names and apt
+-- package names.
+serviceInstalledRunning :: Package -> Property
+serviceInstalledRunning svc = Service.running svc `requires` installed [svc]