summaryrefslogtreecommitdiff
path: root/src/Propellor/Property/Postfix.hs
diff options
context:
space:
mode:
authorJoey Hess2014-07-18 14:36:51 -0400
committerJoey Hess2014-07-18 14:36:51 -0400
commit90682a79844078b721f0e071598103ccadb44622 (patch)
tree2bf8b2ddd0949a37149b98a2dc0cad8f8393a8d6 /src/Propellor/Property/Postfix.hs
parent0d188bf5f6a1ad519a660e06d7e74c6cf683ff32 (diff)
propellor spin
Diffstat (limited to 'src/Propellor/Property/Postfix.hs')
-rw-r--r--src/Propellor/Property/Postfix.hs16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/Propellor/Property/Postfix.hs b/src/Propellor/Property/Postfix.hs
index 96bc1bc1..a9815226 100644
--- a/src/Propellor/Property/Postfix.hs
+++ b/src/Propellor/Property/Postfix.hs
@@ -25,7 +25,7 @@ reloaded = Service.reloaded "postfix"
-- futher coniguration/keys. But this should be enough to get cron job
-- mail flowing to a place where it will be seen.
satellite :: Property
-satellite = check norelayhost setup
+satellite = check (not <$> mainCfIsSet "relayhost") setup
`requires` installed
where
setup = trivial $ property "postfix satellite system" $ do
@@ -41,13 +41,6 @@ satellite = check norelayhost setup
, mainCf ("relayhost", domain)
`onChange` reloaded
]
- norelayhost = not . any relayhostset . lines
- <$> readProcess "postconf" []
- relayhostset l
- | l == "relayhost =" = False
- | l == "relayhost = " = False
- | "relayhost =" `isPrefixOf` l = True
- | otherwise = False
-- | Sets up a file by running a property (which the filename is passed
-- to). If the setup property makes a change, postmap will be run on the
@@ -84,6 +77,13 @@ getMainCf name = parse . lines <$> readProcess "postconf" [name]
(_, v) -> v
parse [] = Nothing
+-- | Checks if a main.cf field is set. A field that is set to ""
+-- is considered not set.
+mainCfIsSet :: String -> IO Bool
+mainCfIsSet name = do
+ v <- getMainCf name
+ return $ v == Nothing || v == Just ""
+
-- | Parses main.cf, and removes any initial configuration lines that are
-- overridden to other values later in the file.
--