diff options
| author | Joey Hess <joeyh@joeyh.name> | 2015-10-23 17:38:48 -0400 |
|---|---|---|
| committer | Joey Hess <joeyh@joeyh.name> | 2015-10-23 17:38:48 -0400 |
| commit | 70797918ff2dd1d0588e4a3d2eb2a38381ecd9ed (patch) | |
| tree | b755fba501fcbe013d7c9294fc7ce4b21a2d057a /src/Propellor/Property/Hostname.hs | |
| parent | 42ed4b5e68ec84106850c07904ee6124a7805742 (diff) | |
| parent | 0d08ba360b576fe000a9ce67ce2082267aad9d5c (diff) | |
Merge branch 'joeyconfig'
Diffstat (limited to 'src/Propellor/Property/Hostname.hs')
| -rw-r--r-- | src/Propellor/Property/Hostname.hs | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/Propellor/Property/Hostname.hs b/src/Propellor/Property/Hostname.hs index 78ec872f..4597b178 100644 --- a/src/Propellor/Property/Hostname.hs +++ b/src/Propellor/Property/Hostname.hs @@ -2,13 +2,17 @@ module Propellor.Property.Hostname where import Propellor.Base import qualified Propellor.Property.File as File +import Propellor.Property.Chroot (inChroot) import Data.List import Data.List.Utils --- | Ensures that the hostname is set using best practices. +-- | Ensures that the hostname is set using best practices, to whatever +-- name the `Host` has. -- --- Configures </etc/hostname> and the current hostname. +-- Configures both </etc/hostname> and the current hostname. +-- (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. -- @@ -25,6 +29,8 @@ sane' :: ExtractDomain -> Property NoInfo sane' extractdomain = property ("sane hostname") $ ensureProperty . setTo' extractdomain =<< asks hostName +-- Like `sane`, but you can specify the hostname to use, instead +-- of the default hostname of the `Host`. setTo :: HostName -> Property NoInfo setTo = setTo' extractDomain @@ -41,7 +47,8 @@ setTo' extractdomain hn = combineProperties desc go then Nothing else Just $ trivial $ hostsline "127.0.1.1" [hn, basehost] , Just $ trivial $ hostsline "127.0.0.1" ["localhost"] - , Just $ trivial $ cmdProperty "hostname" [basehost] + , Just $ trivial $ check (not <$> inChroot) $ + cmdProperty "hostname" [basehost] , Just $ "/etc/mailname" `File.hasContent` [if null domain then hn else domain] ] |
