From 5590c1c75a4207ab5ad3d02a2073f974b0b27add Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 18 Jul 2014 00:20:09 -0400 Subject: propellor spin --- src/Propellor/Property/Hostname.hs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/Propellor/Property/Hostname.hs') diff --git a/src/Propellor/Property/Hostname.hs b/src/Propellor/Property/Hostname.hs index 1cce4e60..c3821eb4 100644 --- a/src/Propellor/Property/Hostname.hs +++ b/src/Propellor/Property/Hostname.hs @@ -3,6 +3,8 @@ module Propellor.Property.Hostname where import Propellor import qualified Propellor.Property.File as File +import Data.List + -- | Ensures that the hostname is set using best practices. -- -- Configures /etc/hostname and the current hostname. @@ -37,3 +39,21 @@ setTo hn = combineProperties desc go addhostsline ip names ls = (ip ++ "\t" ++ (unwords names)) : filter (not . hasip ip) ls hasip ip l = headMaybe (words l) == Just ip + +-- | Makes /etc/resolv.conf contain search and domain lines for +-- the domain that the hostname is in. +searchDomain :: Property +searchDomain = property desc (ensureProperty . go =<< asks hostName) + where + desc = "resolv.conf search and domain configured" + go hn = + let (_basehost, domain) = separate (== '.') hn + in File.fileProperty desc (use domain) "/etc/resolv.conf" + use domain ls = filter wanted $ nub (ls ++ cfgs) + where + cfgs = ["domain " ++ domain, "search " ++ domain] + wanted l + | l `elem` cfgs = True + | "domain " `isPrefixOf` l = False + | "search " `isPrefixOf` l = False + | otherwise = True -- cgit v1.3-2-g0d8e From 1143ca7c5c673094ec2ab11d61d75a8928da6f2b Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 18 Jul 2014 12:48:08 -0400 Subject: propellor spin --- config-joey.hs | 2 ++ src/Propellor/Property/Hostname.hs | 4 ++++ 2 files changed, 6 insertions(+) (limited to 'src/Propellor/Property/Hostname.hs') diff --git a/config-joey.hs b/config-joey.hs index b95a3278..c3fb177f 100644 --- a/config-joey.hs +++ b/config-joey.hs @@ -102,7 +102,9 @@ hosts = -- (o) ` `requires` Gpg.keyImported "98147487" "root" `requires` Ssh.keyImported SshRsa "root" (Context "kite.kitenet.net") + & JoeySites.kiteMailServer + -- & alias "smtp.kitenet.net" -- not yet live! & Apt.installed ["mutt", "alpine", "git-annex", "myrepos"] -- Since password authentication is allowed: diff --git a/src/Propellor/Property/Hostname.hs b/src/Propellor/Property/Hostname.hs index c3821eb4..c489e2fb 100644 --- a/src/Propellor/Property/Hostname.hs +++ b/src/Propellor/Property/Hostname.hs @@ -9,6 +9,8 @@ import Data.List -- -- Configures /etc/hostname and the current hostname. -- +-- Configures /etc/mailname with the domain part of the hostname. +-- -- /etc/hosts is also configured, with an entry for 127.0.1.1, which is -- standard at least on Debian to set the FDQN. -- @@ -31,6 +33,8 @@ setTo hn = combineProperties desc go else Just $ trivial $ hostsline "127.0.1.1" [hn, basehost] , Just $ trivial $ hostsline "127.0.0.1" ["localhost"] , Just $ trivial $ cmdProperty "hostname" [basehost] + , Just $ "/etc/mailname" `File.hasContent` + [if null domain then hn else domain] ] hostsline ip names = File.fileProperty desc -- cgit v1.3-2-g0d8e