From 12548bae3d8feecce6a322162d91b827289ae824 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 5 Dec 2015 17:52:43 -0400 Subject: 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. --- src/Propellor/Property/Systemd.hs | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to 'src/Propellor/Property/Systemd.hs') 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 -- cgit v1.3-2-g0d8e