summaryrefslogtreecommitdiff
path: root/src/Propellor/Property
diff options
context:
space:
mode:
authorJoey Hess2016-03-26 21:51:13 -0400
committerJoey Hess2016-03-26 21:51:13 -0400
commit76a8e806102e13669fa4e64342189084099ec306 (patch)
tree9da7b27752ebfbf86faba17d637919ea67900593 /src/Propellor/Property
parente2522c851b600f16148509992a98e63a4dd9b4f7 (diff)
more porting
Diffstat (limited to 'src/Propellor/Property')
-rw-r--r--src/Propellor/Property/Journald.hs16
-rw-r--r--src/Propellor/Property/Munin.hs8
-rw-r--r--src/Propellor/Property/Systemd.hs28
3 files changed, 26 insertions, 26 deletions
diff --git a/src/Propellor/Property/Journald.hs b/src/Propellor/Property/Journald.hs
index 2fbb780e..d0261626 100644
--- a/src/Propellor/Property/Journald.hs
+++ b/src/Propellor/Property/Journald.hs
@@ -5,7 +5,7 @@ import qualified Propellor.Property.Systemd as Systemd
import Utility.DataUnits
-- | Configures journald, restarting it so the changes take effect.
-configured :: Systemd.Option -> String -> Property NoInfo
+configured :: Systemd.Option -> String -> Property Linux
configured option value =
Systemd.configured "/etc/systemd/journald.conf" option value
`onChange` Systemd.restarted "systemd-journald"
@@ -14,28 +14,28 @@ configured option value =
-- Examples: "100 megabytes" or "0.5tb"
type DataSize = String
-configuredSize :: Systemd.Option -> DataSize -> Property NoInfo
+configuredSize :: Systemd.Option -> DataSize -> Property Linux
configuredSize option s = case readSize dataUnits s of
Just sz -> configured option (systemdSizeUnits sz)
Nothing -> property ("unable to parse " ++ option ++ " data size " ++ s) $
return FailedChange
-systemMaxUse :: DataSize -> Property NoInfo
+systemMaxUse :: DataSize -> Property Linux
systemMaxUse = configuredSize "SystemMaxUse"
-runtimeMaxUse :: DataSize -> Property NoInfo
+runtimeMaxUse :: DataSize -> Property Linux
runtimeMaxUse = configuredSize "RuntimeMaxUse"
-systemKeepFree :: DataSize -> Property NoInfo
+systemKeepFree :: DataSize -> Property Linux
systemKeepFree = configuredSize "SystemKeepFree"
-runtimeKeepFree :: DataSize -> Property NoInfo
+runtimeKeepFree :: DataSize -> Property Linux
runtimeKeepFree = configuredSize "RuntimeKeepFree"
-systemMaxFileSize :: DataSize -> Property NoInfo
+systemMaxFileSize :: DataSize -> Property Linux
systemMaxFileSize = configuredSize "SystemMaxFileSize"
-runtimeMaxFileSize :: DataSize -> Property NoInfo
+runtimeMaxFileSize :: DataSize -> Property Linux
runtimeMaxFileSize = configuredSize "RuntimeMaxFileSize"
-- Generates size units as used in journald.conf.
diff --git a/src/Propellor/Property/Munin.hs b/src/Propellor/Property/Munin.hs
index 2464985a..dd74d91b 100644
--- a/src/Propellor/Property/Munin.hs
+++ b/src/Propellor/Property/Munin.hs
@@ -19,19 +19,19 @@ import qualified Propellor.Property.Service as Service
nodePort :: Integer
nodePort = 4949
-nodeInstalled :: Property NoInfo
+nodeInstalled :: Property DebianLike
nodeInstalled = Apt.serviceInstalledRunning "munin-node"
-nodeRestarted :: Property NoInfo
+nodeRestarted :: Property DebianLike
nodeRestarted = Service.restarted "munin-node"
nodeConfPath :: FilePath
nodeConfPath = "/etc/munin/munin-node.conf"
-masterInstalled :: Property NoInfo
+masterInstalled :: Property DebianLike
masterInstalled = Apt.serviceInstalledRunning "munin"
-masterRestarted :: Property NoInfo
+masterRestarted :: Property DebianLike
masterRestarted = Service.restarted "munin"
masterConfPath :: FilePath
diff --git a/src/Propellor/Property/Systemd.hs b/src/Propellor/Property/Systemd.hs
index d909e4df..7dc1ccd8 100644
--- a/src/Propellor/Property/Systemd.hs
+++ b/src/Propellor/Property/Systemd.hs
@@ -70,13 +70,13 @@ 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 :: ServiceName -> Property Linux
started n = cmdProperty "systemctl" ["start", n]
`assume` NoChange
`describe` ("service " ++ n ++ " started")
-- | Stops a systemd service.
-stopped :: ServiceName -> Property NoInfo
+stopped :: ServiceName -> Property Linux
stopped n = cmdProperty "systemctl" ["stop", n]
`assume` NoChange
`describe` ("service " ++ n ++ " stopped")
@@ -85,19 +85,19 @@ stopped n = 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 :: ServiceName -> Property Linux
enabled n = cmdProperty "systemctl" ["enable", n]
`assume` NoChange
`describe` ("service " ++ n ++ " enabled")
-- | Disables a systemd service.
-disabled :: ServiceName -> Property NoInfo
+disabled :: ServiceName -> Property Linux
disabled n = cmdProperty "systemctl" ["disable", n]
`assume` NoChange
`describe` ("service " ++ n ++ " disabled")
-- | Masks a systemd service.
-masked :: ServiceName -> RevertableProperty NoInfo
+masked :: ServiceName -> RevertableProperty Linux
masked n = systemdMask <!> systemdUnmask
where
systemdMask = cmdProperty "systemctl" ["mask", n]
@@ -108,11 +108,11 @@ masked n = systemdMask <!> systemdUnmask
`describe` ("service " ++ n ++ " unmasked")
-- | Ensures that a service is both enabled and started
-running :: ServiceName -> Property NoInfo
+running :: ServiceName -> Property Linux
running n = started n `requires` enabled n
-- | Restarts a systemd service.
-restarted :: ServiceName -> Property NoInfo
+restarted :: ServiceName -> Property Linux
restarted n = cmdProperty "systemctl" ["restart", n]
`assume` NoChange
`describe` ("service " ++ n ++ " restarted")
@@ -126,7 +126,7 @@ journald :: ServiceName
journald = "systemd-journald"
-- | Enables persistent storage of the journal.
-persistentJournal :: Property NoInfo
+persistentJournal :: Property DebianLike
persistentJournal = check (not <$> doesDirectoryExist dir) $
combineProperties "persistent systemd journal"
[ cmdProperty "install" ["-d", "-g", "systemd-journal", dir]
@@ -148,7 +148,7 @@ type Option = String
-- currently the case for files like journald.conf and system.conf.
-- And it assumes the file already exists with
-- the right [Header], so new lines can just be appended to the end.
-configured :: FilePath -> Option -> String -> Property NoInfo
+configured :: FilePath -> Option -> String -> Property Linux
configured cfgfile option value = combineProperties desc
[ File.fileProperty desc (mapMaybe removeother) cfgfile
, File.containsLine cfgfile line
@@ -162,18 +162,18 @@ configured cfgfile option value = combineProperties desc
| otherwise = Just l
-- | Causes systemd to reload its configuration files.
-daemonReloaded :: Property NoInfo
+daemonReloaded :: Property Linux
daemonReloaded = cmdProperty "systemctl" ["daemon-reload"]
`assume` NoChange
-- | Configures journald, restarting it so the changes take effect.
-journaldConfigured :: Option -> String -> Property NoInfo
+journaldConfigured :: Option -> String -> Property Linux
journaldConfigured option value =
configured "/etc/systemd/journald.conf" option value
`onChange` restarted journald
-- | Ensures machined and machinectl are installed
-machined :: Property NoInfo
+machined :: Property Linux
machined = withOS "machined installed" $ \o ->
case o of
-- Split into separate debian package since systemd 225.
@@ -239,7 +239,7 @@ nspawned c@(Container name (Chroot.Chroot loc builder _) h) =
-- | Sets up the service file for the container, and then starts
-- it running.
-nspawnService :: Container -> ChrootCfg -> RevertableProperty NoInfo
+nspawnService :: Container -> ChrootCfg -> RevertableProperty Linux
nspawnService (Container name _ _) cfg = setup <!> teardown
where
service = nspawnServiceName name
@@ -290,7 +290,7 @@ nspawnServiceParams (SystemdNspawnCfg ps) =
--
-- This uses nsenter to enter the container, by looking up the pid of the
-- container's init process and using its namespace.
-enterScript :: Container -> RevertableProperty NoInfo
+enterScript :: Container -> RevertableProperty Linux
enterScript c@(Container name _ _) = setup <!> teardown
where
setup = combineProperties ("generated " ++ enterScriptFile c)