propellor spin
This commit is contained in:
parent
fbc57d6845
commit
7932c5abec
|
@ -3,12 +3,30 @@ module Propellor.Property.Hostname where
|
||||||
import Propellor
|
import Propellor
|
||||||
import qualified Propellor.Property.File as File
|
import qualified Propellor.Property.File as File
|
||||||
|
|
||||||
-- | Sets the hostname. Should be provided with a FQDN, and will configure
|
-- | Sets the hostname. Configures both /etc/hostname and the current
|
||||||
-- both /etc/hostname (with the base hostname) and /etc/hosts (with the
|
-- hostname.
|
||||||
-- full hostname). Also sets the current hostname.
|
--
|
||||||
|
-- When provided with 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).
|
||||||
set :: HostName -> Property
|
set :: HostName -> Property
|
||||||
set hostname = "/etc/hostname" `File.hasContent` [hostname]
|
set hostname = propertyList desc go
|
||||||
`onChange` cmdProperty "hostname" [hostname]
|
`onChange` cmdProperty "hostname" [host]
|
||||||
`describe` ("hostname " ++ hostname)
|
`describe` desc
|
||||||
where
|
where
|
||||||
|
desc = "hostname " ++ hostname
|
||||||
(host, domain) = separate (== '.') hostname
|
(host, domain) = separate (== '.') hostname
|
||||||
|
|
||||||
|
go = catMaybes
|
||||||
|
[ Just $ "/etc/hostname" `File.hasContent` [host]
|
||||||
|
, if null domain
|
||||||
|
then Nothing
|
||||||
|
else Just $ File.fileProperty desc
|
||||||
|
addhostline "/etc/hosts"
|
||||||
|
]
|
||||||
|
|
||||||
|
hostip = "127.0.1.1"
|
||||||
|
hostline = hostip ++ "\t" ++ hostname ++ " " ++ host
|
||||||
|
|
||||||
|
addhostline ls = hostline : filter (not . hashostip) ls
|
||||||
|
hashostip l = headMaybe (words l) == Just hostip
|
||||||
|
|
|
@ -10,7 +10,7 @@ import qualified Propellor.Property.Cron as Cron
|
||||||
import qualified Propellor.Property.Sudo as Sudo
|
import qualified Propellor.Property.Sudo as Sudo
|
||||||
import qualified Propellor.Property.User as User
|
import qualified Propellor.Property.User as User
|
||||||
import qualified Propellor.Property.Hostname as Hostname
|
import qualified Propellor.Property.Hostname as Hostname
|
||||||
import qualified Propellor.Property.Reboot as Reboot
|
--import qualified Propellor.Property.Reboot as Reboot
|
||||||
import qualified Propellor.Property.Tor as Tor
|
import qualified Propellor.Property.Tor as Tor
|
||||||
import qualified Propellor.Property.Docker as Docker
|
import qualified Propellor.Property.Docker as Docker
|
||||||
import qualified Propellor.Property.SiteSpecific.GitHome as GitHome
|
import qualified Propellor.Property.SiteSpecific.GitHome as GitHome
|
||||||
|
|
Loading…
Reference in New Issue