diff options
| author | Joey Hess <joeyh@joeyh.name> | 2015-08-20 10:29:08 -0400 |
|---|---|---|
| committer | Joey Hess <joeyh@joeyh.name> | 2015-08-20 10:29:08 -0400 |
| commit | 6aba3026c44b9c9cf63468927aa57c197f6444fa (patch) | |
| tree | f1b26ccd84164595dff869757b0384ffb7c095dd /src | |
| parent | 0a08f4a1541b3711861a67ff660d60d3f5d668e3 (diff) | |
propellor spin
Diffstat (limited to 'src')
| -rw-r--r-- | src/Propellor/Property/ConfFile.hs | 33 | ||||
| -rw-r--r-- | src/Propellor/Property/LightDM.hs | 2 |
2 files changed, 27 insertions, 8 deletions
diff --git a/src/Propellor/Property/ConfFile.hs b/src/Propellor/Property/ConfFile.hs index b2d96d29..df723eea 100644 --- a/src/Propellor/Property/ConfFile.hs +++ b/src/Propellor/Property/ConfFile.hs @@ -1,4 +1,13 @@ -module Propellor.Property.ConfFile (containsIniPair) where +module Propellor.Property.ConfFile ( + SectionStart, + SectionPast, + AdjustSection, + InsertSection, + adjustSection, + IniSection, + IniKey, + containsIniSetting, +) where import Propellor import Propellor.Property.File @@ -17,8 +26,9 @@ type AdjustSection = [Line] -> [Line] -- insert the section somewhere within it type InsertSection = [Line] -> [Line] +-- | Adjusts a section of conffile. adjustSection - :: String + :: Desc -> SectionStart -> SectionPast -> AdjustSection @@ -40,12 +50,19 @@ adjustSection desc start past adjust insert f = (pre, wanted ++ [l], post) | otherwise = (pre, wanted, post ++ [l]) -iniHeader :: String -> String +-- | Name of a section of a Windows-style .ini file. This value is put +-- in square braces to generate the section header. +type IniSection = String + +-- | Name of a configuration setting within a Windows-style .init file. +type IniKey = String + +iniHeader :: IniSection -> String iniHeader header = '[' : header ++ "]" adjustIniSection - :: String - -> String + :: Desc + -> IniSection -> AdjustSection -> InsertSection -> FilePath @@ -56,8 +73,10 @@ adjustIniSection desc header = (== iniHeader header) ("[" `isPrefixOf`) -containsIniPair :: FilePath -> (String, String, String) -> Property NoInfo -containsIniPair f (header, key, value) = +-- | Ensures that a Windows-style .ini file exists and contains a section +-- with a key=value setting. +containsIniSetting :: FilePath -> (IniSection, IniKey, String) -> Property NoInfo +containsIniSetting f (header, key, value) = adjustIniSection (f ++ " section [" ++ header ++ "] contains " ++ key ++ "=" ++ value) header diff --git a/src/Propellor/Property/LightDM.hs b/src/Propellor/Property/LightDM.hs index 156a2a82..b779ba4d 100644 --- a/src/Propellor/Property/LightDM.hs +++ b/src/Propellor/Property/LightDM.hs @@ -7,6 +7,6 @@ import qualified Propellor.Property.ConfFile as ConfFile -- | Configures LightDM to skip the login screen and autologin as a user. autoLogin :: User -> Property NoInfo -autoLogin (User u) = "/etc/lightdm/lightdm.conf" `ConfFile.containsIniPair` +autoLogin (User u) = "/etc/lightdm/lightdm.conf" `ConfFile.containsIniSetting` ("SeatDefaults", "autologin-user", u) `describe` "lightdm autologin" |
