From 8bb029002e547f272e705d92dbc9c4fa53a63d78 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 14 Apr 2014 15:35:29 -0400 Subject: propellor spin --- Propellor/Property/Postfix.hs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Propellor/Property/Postfix.hs (limited to 'Propellor/Property/Postfix.hs') diff --git a/Propellor/Property/Postfix.hs b/Propellor/Property/Postfix.hs new file mode 100644 index 00000000..c253aac2 --- /dev/null +++ b/Propellor/Property/Postfix.hs @@ -0,0 +1,26 @@ +module Propellor.Property.Postfix where + +import Propellor +import qualified Propellor.Property.Apt as Apt +import Propellor.Property.User +import Utility.SafeCommand +import Utility.FileMode + +import System.PosixCompat + +installed :: Property +installed = Apt.serviceInstalledRunning "postfix" + +-- | Configures postfix as a satellite system, which +-- relats 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 = Apt.reConfigure "postfix" + [ ("postfix/main_mailer_type", "select", "Satellite system") + , ("postfix/destinations", "string", "") + ] + `describe` "postfix satellite system" + `requires` installed -- cgit v1.3-2-g0d8e From e8db2577a8e07deda5ad121f7a574e2f4d88c543 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 14 Apr 2014 15:42:26 -0400 Subject: propellor spin --- Propellor/Property/Hostname.hs | 5 ----- Propellor/Property/Postfix.hs | 21 ++++++++++----------- 2 files changed, 10 insertions(+), 16 deletions(-) (limited to 'Propellor/Property/Postfix.hs') diff --git a/Propellor/Property/Hostname.hs b/Propellor/Property/Hostname.hs index 59aade45..30e0992d 100644 --- a/Propellor/Property/Hostname.hs +++ b/Propellor/Property/Hostname.hs @@ -6,8 +6,6 @@ import qualified Propellor.Property.File as File -- | Ensures that the hostname is set to the HostAttr value. -- Configures /etc/hostname and the current hostname. -- --- When the hostname is a FQDN, also configures /etc/mailname --- with the domain part. -- A FQDN also configures /etc/hosts, with an entry for 127.0.1.1, which is -- standard at least on Debian to set the FDQN (127.0.0.1 is localhost). sane :: Property @@ -26,9 +24,6 @@ setTo hn = combineProperties desc go then Nothing else Just $ File.fileProperty desc addhostline "/etc/hosts" - , if null domain - then Nothing - else Just $ "/etc/mailname" `File.hasContent` [domain] ] hostip = "127.0.1.1" diff --git a/Propellor/Property/Postfix.hs b/Propellor/Property/Postfix.hs index c253aac2..49676640 100644 --- a/Propellor/Property/Postfix.hs +++ b/Propellor/Property/Postfix.hs @@ -2,11 +2,6 @@ module Propellor.Property.Postfix where import Propellor import qualified Propellor.Property.Apt as Apt -import Propellor.Property.User -import Utility.SafeCommand -import Utility.FileMode - -import System.PosixCompat installed :: Property installed = Apt.serviceInstalledRunning "postfix" @@ -18,9 +13,13 @@ installed = Apt.serviceInstalledRunning "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 = Apt.reConfigure "postfix" - [ ("postfix/main_mailer_type", "select", "Satellite system") - , ("postfix/destinations", "string", "") - ] - `describe` "postfix satellite system" - `requires` installed +satellite = setup `requires` installed + where + setup = Property "postfix satellite system" $ do + hn <- getHostName + ensureProperty $ Apt.reConfigure "postfix" + [ ("postfix/main_mailer_type", "select", "Satellite system") + , ("postfix/root_address", "string", "root") + , ("postfix/destinations", "string", " ") + , ("postfix/mailname", "string", hn) + ] -- cgit v1.3-2-g0d8e From 1f2c68d595bbe5591517f44cdaa9ffd7ce1e00bb Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 14 Apr 2014 16:01:17 -0400 Subject: propellor spin --- Propellor/Property/Apt.hs | 12 +++++++----- Propellor/Property/Postfix.hs | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'Propellor/Property/Postfix.hs') diff --git a/Propellor/Property/Apt.hs b/Propellor/Property/Apt.hs index a01ab3cc..2aeeab74 100644 --- a/Propellor/Property/Apt.hs +++ b/Propellor/Property/Apt.hs @@ -5,6 +5,7 @@ import Control.Applicative import Data.List import System.IO import Control.Monad +import System.Process (env) import Propellor import qualified Propellor.Property.File as File @@ -195,12 +196,13 @@ reConfigure package vals = reconfigure `requires` setselections `describe` ("reconfigure " ++ package) where setselections = Property "preseed" $ makeChange $ - withHandle StdinHandle createProcessSuccess - (proc "debconf-set-selections" []) $ \h -> do - forM_ vals $ \(tmpl, tmpltype, value) -> - hPutStrLn h $ unwords [package, tmpl, tmpltype, value] - hClose h + withHandle StdinHandle createProcessSuccess p $ \h -> do + forM_ vals $ \(tmpl, tmpltype, value) -> + hPutStrLn h $ unwords [package, tmpl, tmpltype, value] + hClose h reconfigure = cmdProperty "dpkg-reconfigure" ["-fnone", package] + p = (proc "debconf-set-selections" []) + { env = Just noninteractiveEnv } -- | Ensures that a service is installed and running. -- diff --git a/Propellor/Property/Postfix.hs b/Propellor/Property/Postfix.hs index 49676640..f4be27cf 100644 --- a/Propellor/Property/Postfix.hs +++ b/Propellor/Property/Postfix.hs @@ -15,7 +15,7 @@ installed = Apt.serviceInstalledRunning "postfix" satellite :: Property satellite = setup `requires` installed where - setup = Property "postfix satellite system" $ do + setup = trivial $ Property "postfix satellite system" $ do hn <- getHostName ensureProperty $ Apt.reConfigure "postfix" [ ("postfix/main_mailer_type", "select", "Satellite system") -- cgit v1.3-2-g0d8e