summaryrefslogtreecommitdiff
path: root/src/Propellor/Property
diff options
context:
space:
mode:
Diffstat (limited to 'src/Propellor/Property')
-rw-r--r--src/Propellor/Property/HostingProvider/CloudAtCost.hs1
-rw-r--r--src/Propellor/Property/Hostname.hs17
-rw-r--r--src/Propellor/Property/Installer/Target.hs1
-rw-r--r--src/Propellor/Property/OS.hs1
4 files changed, 16 insertions, 4 deletions
diff --git a/src/Propellor/Property/HostingProvider/CloudAtCost.hs b/src/Propellor/Property/HostingProvider/CloudAtCost.hs
index 48c19572..839aa14e 100644
--- a/src/Propellor/Property/HostingProvider/CloudAtCost.hs
+++ b/src/Propellor/Property/HostingProvider/CloudAtCost.hs
@@ -13,6 +13,7 @@ import qualified Propellor.Property.User as User
decruft :: Property DebianLike
decruft = propertyList "cloudatcost cleanup" $ props
& Hostname.sane
+ & Hostname.mailname
& grubbugfix
& nukecruft
where
diff --git a/src/Propellor/Property/Hostname.hs b/src/Propellor/Property/Hostname.hs
index 1eb9d690..0ece92a8 100644
--- a/src/Propellor/Property/Hostname.hs
+++ b/src/Propellor/Property/Hostname.hs
@@ -14,8 +14,6 @@ import Data.List
-- (However, when used inside a chroot, avoids setting the current hostname
-- as that would impact the system outside the chroot.)
--
--- 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.
--
@@ -46,8 +44,6 @@ setTo' extractdomain hn = combineProperties desc $ toProps
, check (not <$> inChroot) $
cmdProperty "hostname" [basehost]
`assume` NoChange
- , "/etc/mailname" `File.hasContent`
- [if null domain then hn else domain]
]
where
desc = "hostname " ++ hn
@@ -85,6 +81,19 @@ searchDomain' extractdomain = property' desc $ \w ->
| "search " `isPrefixOf` l = False
| otherwise = True
+-- Configures </etc/mailname> with the domain part of the hostname of the
+-- `Host` it's used in.
+mailname :: Property UnixLike
+mailname = mailname' extractDomain
+
+mailname' :: ExtractDomain -> Property UnixLike
+mailname' extractdomain = property' ("mailname set from hostname") $ \w ->
+ ensureProperty w . go =<< asks hostName
+ where
+ go mn = "/etc/mailname" `File.hasContent` [if null mn' then mn else mn']
+ where
+ mn' = extractdomain mn
+
-- | Function to extract the domain name from a HostName.
type ExtractDomain = HostName -> String
diff --git a/src/Propellor/Property/Installer/Target.hs b/src/Propellor/Property/Installer/Target.hs
index 8c865143..c6889dc5 100644
--- a/src/Propellor/Property/Installer/Target.hs
+++ b/src/Propellor/Property/Installer/Target.hs
@@ -24,6 +24,7 @@
-- > seed ver = host "debian.local" $ props
-- > & osDebian Unstable X86_64
-- > & Hostname.sane
+-- > & Hostname.mailname
-- > & Apt.stdSourcesList
-- > & Apt.installed ["linux-image-amd64"]
-- > & Grub.installed PC
diff --git a/src/Propellor/Property/OS.hs b/src/Propellor/Property/OS.hs
index c31bef7b..503f303d 100644
--- a/src/Propellor/Property/OS.hs
+++ b/src/Propellor/Property/OS.hs
@@ -58,6 +58,7 @@ import Control.Exception (throw)
-- > -- , oldOsRemoved (Confirmed "foo.example.com")
-- > ]
-- > & Hostname.sane
+-- > & Hostname.mailname
-- > & Apt.installed ["linux-image-amd64"]
-- > & Apt.installed ["ssh"]
-- > & User.hasSomePassword "root"