summaryrefslogtreecommitdiff
path: root/src/Propellor/Property/Systemd.hs
diff options
context:
space:
mode:
authorJoey Hess2015-12-05 17:52:43 -0400
committerJoey Hess2015-12-05 17:53:16 -0400
commit12548bae3d8feecce6a322162d91b827289ae824 (patch)
tree45f5ec5131817aab5133c9c1e4dbcf3364953e76 /src/Propellor/Property/Systemd.hs
parentb816e40e2618a8932144bceb7c7039adc5c44c11 (diff)
UncheckedProperty for cmdProperty et al
* Properties that run an arbitrary command, such as cmdProperty and scriptProperty are converted to use UncheckedProperty, since they cannot tell on their own if the command truely made a change or not. (API Change) Transition guide: - When GHC complains about an UncheckedProperty, add: `assume` MadeChange - Since these properties used to always return MadeChange, that change is always safe to make. - Or, if you know that the command should modifiy a file, use: `changesFile` filename * A few properties have had their Result improved, for example Apt.buldDep and Apt.autoRemove now check if a change was made or not.
Diffstat (limited to 'src/Propellor/Property/Systemd.hs')
-rw-r--r--src/Propellor/Property/Systemd.hs32
1 files changed, 21 insertions, 11 deletions
diff --git a/src/Propellor/Property/Systemd.hs b/src/Propellor/Property/Systemd.hs
index 42ff8e57..04ce3b48 100644
--- a/src/Propellor/Property/Systemd.hs
+++ b/src/Propellor/Property/Systemd.hs
@@ -71,12 +71,14 @@ instance PropAccum Container where
-- Note that this does not configure systemd to start the service on boot,
-- it only ensures that the service is currently running.
started :: ServiceName -> Property NoInfo
-started n = trivial $ cmdProperty "systemctl" ["start", n]
+started n = cmdProperty "systemctl" ["start", n]
+ `assume` NoChange
`describe` ("service " ++ n ++ " started")
-- | Stops a systemd service.
stopped :: ServiceName -> Property NoInfo
-stopped n = trivial $ cmdProperty "systemctl" ["stop", n]
+stopped n = cmdProperty "systemctl" ["stop", n]
+ `assume` NoChange
`describe` ("service " ++ n ++ " stopped")
-- | Enables a systemd service.
@@ -84,30 +86,35 @@ stopped n = trivial $ cmdProperty "systemctl" ["stop", n]
-- This does not ensure the service is started, it only configures systemd
-- to start it on boot.
enabled :: ServiceName -> Property NoInfo
-enabled n = trivial $ cmdProperty "systemctl" ["enable", n]
+enabled n = cmdProperty "systemctl" ["enable", n]
+ `assume` NoChange
`describe` ("service " ++ n ++ " enabled")
-- | Disables a systemd service.
disabled :: ServiceName -> Property NoInfo
-disabled n = trivial $ cmdProperty "systemctl" ["disable", n]
+disabled n = cmdProperty "systemctl" ["disable", n]
+ `assume` NoChange
`describe` ("service " ++ n ++ " disabled")
-- | Masks a systemd service.
masked :: ServiceName -> RevertableProperty NoInfo
masked n = systemdMask <!> systemdUnmask
where
- systemdMask = trivial $ cmdProperty "systemctl" ["mask", n]
- `describe` ("service " ++ n ++ " masked")
- systemdUnmask = trivial $ cmdProperty "systemctl" ["unmask", n]
- `describe` ("service " ++ n ++ " unmasked")
+ systemdMask = cmdProperty "systemctl" ["mask", n]
+ `assume` NoChange
+ `describe` ("service " ++ n ++ " masked")
+ systemdUnmask = cmdProperty "systemctl" ["unmask", n]
+ `assume` NoChange
+ `describe` ("service " ++ n ++ " unmasked")
-- | Ensures that a service is both enabled and started
running :: ServiceName -> Property NoInfo
-running n = trivial $ started n `requires` enabled n
+running n = started n `requires` enabled n
-- | Restarts a systemd service.
restarted :: ServiceName -> Property NoInfo
-restarted n = trivial $ cmdProperty "systemctl" ["restart", n]
+restarted n = cmdProperty "systemctl" ["restart", n]
+ `assume` NoChange
`describe` ("service " ++ n ++ " restarted")
-- | The systemd-networkd service.
@@ -123,7 +130,9 @@ persistentJournal :: Property NoInfo
persistentJournal = check (not <$> doesDirectoryExist dir) $
combineProperties "persistent systemd journal"
[ cmdProperty "install" ["-d", "-g", "systemd-journal", dir]
+ `assume` MadeChange
, cmdProperty "setfacl" ["-R", "-nm", "g:adm:rx,d:g:adm:rx", dir]
+ `assume` MadeChange
, started "systemd-journal-flush"
]
`requires` Apt.installed ["acl"]
@@ -154,7 +163,8 @@ configured cfgfile option value = combineProperties desc
-- | Causes systemd to reload its configuration files.
daemonReloaded :: Property NoInfo
-daemonReloaded = trivial $ cmdProperty "systemctl" ["daemon-reload"]
+daemonReloaded = cmdProperty "systemctl" ["daemon-reload"]
+ `assume` NoChange
-- | Configures journald, restarting it so the changes take effect.
journaldConfigured :: Option -> String -> Property NoInfo