summaryrefslogtreecommitdiff
path: root/src/Propellor/Property/Hostname.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Propellor/Property/Hostname.hs')
-rw-r--r--src/Propellor/Property/Hostname.hs10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/Propellor/Property/Hostname.hs b/src/Propellor/Property/Hostname.hs
index 0ece92a8..8383fdaa 100644
--- a/src/Propellor/Property/Hostname.hs
+++ b/src/Propellor/Property/Hostname.hs
@@ -1,8 +1,10 @@
+{-# LANGUAGE LambdaCase #-}
+
module Propellor.Property.Hostname where
import Propellor.Base
import qualified Propellor.Property.File as File
-import Propellor.Property.Chroot (inChroot)
+import Propellor.Types.Container
import Utility.Split
import Data.List
@@ -41,7 +43,7 @@ setTo' extractdomain hn = combineProperties desc $ toProps
else Just ("127.0.1.1", [hn, basehost])
, Just ("127.0.0.1", ["localhost"])
]
- , check (not <$> inChroot) $
+ , check safetochange $
cmdProperty "hostname" [basehost]
`assume` NoChange
]
@@ -50,6 +52,10 @@ setTo' extractdomain hn = combineProperties desc $ toProps
basehost = takeWhile (/= '.') hn
domain = extractdomain hn
+ safetochange = askInfo >>= return . \case
+ [] -> True
+ caps -> HostnameContained `elem` caps
+
hostslines ipsnames =
File.fileProperty desc (addhostslines ipsnames) "/etc/hosts"
addhostslines :: [(String, [String])] -> [String] -> [String]