summaryrefslogtreecommitdiff
path: root/src/Propellor/Property/Postfix.hs
diff options
context:
space:
mode:
authorJoey Hess2014-07-18 13:03:13 -0400
committerJoey Hess2014-07-18 13:03:13 -0400
commit614a6a13acd3e3a7b83dcae86dcf40eb76b824dc (patch)
tree25a69247cdcf45aca2d2a07edf3a382026565c9a /src/Propellor/Property/Postfix.hs
parent5c3b069f2317a015e68c3b430993bb67bf0f63ed (diff)
propellor spin
Diffstat (limited to 'src/Propellor/Property/Postfix.hs')
-rw-r--r--src/Propellor/Property/Postfix.hs13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/Propellor/Property/Postfix.hs b/src/Propellor/Property/Postfix.hs
index fbe39299..1a4a313a 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