From 7f84f196076136252c3d50526ae1805758cf0f2a Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 23 Oct 2015 17:29:26 -0400 Subject: Hostname.sane and Hostname.setTo can now safely be used as a property of a chroot, and won't affect the hostname of the host system. --- src/Propellor/Property/Hostname.hs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/Propellor/Property/Hostname.hs') diff --git a/src/Propellor/Property/Hostname.hs b/src/Propellor/Property/Hostname.hs index 78ec872f..8033bef8 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 and the current hostname. +-- Configures both and the current hostname. +-- (However, if used inside a chroot, avoids setting the current hostname +-- as that would impact the system outside the chroot.) -- -- Configures 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] ] -- cgit v1.2.3 From 883493c2b243db5476a9a09ae9073541cfc5550f Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 23 Oct 2015 17:37:07 -0400 Subject: comments --- src/Propellor/Property/Hostname.hs | 2 +- src/Propellor/Property/Mount.hs | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'src/Propellor/Property/Hostname.hs') diff --git a/src/Propellor/Property/Hostname.hs b/src/Propellor/Property/Hostname.hs index 8033bef8..4597b178 100644 --- a/src/Propellor/Property/Hostname.hs +++ b/src/Propellor/Property/Hostname.hs @@ -11,7 +11,7 @@ import Data.List.Utils -- name the `Host` has. -- -- Configures both and the current hostname. --- (However, if used inside a chroot, avoids setting the current hostname +-- (However, when used inside a chroot, avoids setting the current hostname -- as that would impact the system outside the chroot.) -- -- Configures with the domain part of the hostname. diff --git a/src/Propellor/Property/Mount.hs b/src/Propellor/Property/Mount.hs index 3f13388b..3f96044e 100644 --- a/src/Propellor/Property/Mount.hs +++ b/src/Propellor/Property/Mount.hs @@ -57,7 +57,7 @@ mount fs src mnt opts = boolSystem "mount" $ newtype SwapPartition = SwapPartition FilePath --- | Replaces /etc/fstab with a file that should cause the currently +-- | Replaces with a file that should cause the currently -- mounted partitions to be re-mounted the same way on boot. -- -- For each specified MountPoint, the UUID of each partition @@ -110,8 +110,9 @@ genFstab mnts swaps mnttransform = do uuidprefix = prefix "UUID=" sourceprefix = prefix "LABEL=" --- | Checks if /etc/fstab is not configured. This is the case if it doesn't --- exist, or consists entirely of blank lines or comments. +-- | Checks if is not configured. +-- This is the case if it doesn't exist, or +-- consists entirely of blank lines or comments. -- -- So, if you want to only replace the fstab once, and then never touch it -- again, allowing local modifications: -- cgit v1.2.3