From 90682a79844078b721f0e071598103ccadb44622 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 18 Jul 2014 14:36:51 -0400 Subject: propellor spin --- src/Propellor/Property/Postfix.hs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/Propellor/Property/Postfix.hs') 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. -- -- cgit v1.2.3