-- | Maintainer: Nicolas Schodet -- -- Support for Nullmailer. module Propellor.Property.Nullmailer ( installed, configured, configured', ) where import Propellor import Propellor.Base import qualified Propellor.Property.Apt as Apt import qualified Propellor.Property.File as File import qualified Propellor.Property.Systemd as Systemd -- | Make sure needed tools are installed. installed :: RevertableProperty DebianLike DebianLike installed = install remove where install = Apt.installed packages remove = Apt.removed packages packages = ["nullmailer"] -- | Configure nullmailer using the hostname of the `Host`. configured :: HostName -> String -> Property DebianLike configured relayHost adminAddr = property' "nullmailer configured" $ \w -> ensureProperty w . configured' relayHost adminAddr =<< asks hostName -- | Like configured, but allow to specify the hostname. configured' :: HostName -> String -> HostName -> Property DebianLike configured' relayHost adminAddr hn = (setup `onChange` reload) `requires` installed where setup :: Property UnixLike setup = combineProperties desc $ props & config "defaulthost" hn & config "adminaddr" adminAddr & config "remotes" (relayHost ++ " smtp") desc = "nullmailer configured" config name value = File.hasContent ("/etc/nullmailer" name) [value] reload = Systemd.restarted "nullmailer"