summaryrefslogtreecommitdiff
path: root/Propellor/Property/Hostname.hs
diff options
context:
space:
mode:
authorJoey Hess2014-04-14 15:17:31 -0400
committerJoey Hess2014-04-14 15:17:31 -0400
commit0b5c5f7c9a4e9b192237669903e954eae84dafd0 (patch)
treecc7cf0a7b14c4cc1926c8cd5dd6554fa9425316e /Propellor/Property/Hostname.hs
parent3da26fbfa1811e503f5f4f492f51cfd17e7fa5f8 (diff)
propellor spin
Diffstat (limited to 'Propellor/Property/Hostname.hs')
-rw-r--r--Propellor/Property/Hostname.hs12
1 files changed, 8 insertions, 4 deletions
diff --git a/Propellor/Property/Hostname.hs b/Propellor/Property/Hostname.hs
index 03613ac9..59aade45 100644
--- a/Propellor/Property/Hostname.hs
+++ b/Propellor/Property/Hostname.hs
@@ -4,11 +4,12 @@ import Propellor
import qualified Propellor.Property.File as File
-- | Ensures that the hostname is set to the HostAttr value.
--- Configures both /etc/hostname and the current hostname.
+-- Configures /etc/hostname and the current hostname.
--
--- When the hostname is 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).
+-- 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
sane = Property ("sane hostname") (ensureProperty . setTo =<< getHostName)
@@ -25,6 +26,9 @@ 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"