From 614a6a13acd3e3a7b83dcae86dcf40eb76b824dc Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 18 Jul 2014 13:03:13 -0400 Subject: [PATCH] propellor spin --- src/Propellor/Property/Postfix.hs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Propellor/Property/Postfix.hs b/src/Propellor/Property/Postfix.hs index fbe3929..1a4a313 100644 --- a/src/Propellor/Property/Postfix.hs +++ b/src/Propellor/Property/Postfix.hs @@ -19,22 +19,31 @@ reloaded :: Property reloaded = Service.reloaded "postfix" -- | Configures postfix as a satellite system, which --- relats all mail through a relay host, which defaults to smtp.domain. +-- relays all mail through a relay host, which defaults to smtp.domain. -- -- The smarthost may refuse to relay mail on to other domains, without -- 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 = setup `requires` installed +satellite = check norelayhost setup + `requires` installed where setup = trivial $ property "postfix satellite system" $ do hn <- asks hostName + let (_, domain) = separate (== '.') hn ensureProperty $ Apt.reConfigure "postfix" [ ("postfix/main_mailer_type", "select", "Satellite system") , ("postfix/root_address", "string", "root") , ("postfix/destinations", "string", " ") , ("postfix/mailname", "string", hn) + , ("postfix/relayhost", "string", "smtp." ++ domain) ] + norelayhost = not . any relayhostset . lines + <$> readProcess "postconf" [] + relayhostset l + | 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