summaryrefslogtreecommitdiff
path: root/src/Propellor/Property/Postfix.hs
diff options
context:
space:
mode:
authorJoey Hess2015-12-31 12:40:42 -0400
committerJoey Hess2015-12-31 12:40:42 -0400
commitbfe8375d46e78bc6dd796ba1d0bdce577dbd123c (patch)
tree547acbf0acb730d30f088b481a2ab95b22cc75d2 /src/Propellor/Property/Postfix.hs
parent5e73aa446e46b61ebea77af5a6addaa8be517c1d (diff)
actually parse service lines
So whitespace etc changes don't matter
Diffstat (limited to 'src/Propellor/Property/Postfix.hs')
-rw-r--r--src/Propellor/Property/Postfix.hs17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/Propellor/Property/Postfix.hs b/src/Propellor/Property/Postfix.hs
index b6a1d170..df244061 100644
--- a/src/Propellor/Property/Postfix.hs
+++ b/src/Propellor/Property/Postfix.hs
@@ -139,14 +139,14 @@ data Service = Service
, serviceCommand :: String
, serviceOpts :: ServiceOpts
}
- deriving (Show)
+ deriving (Show, Eq)
data ServiceType
= InetService (Maybe HostName) ServicePort
| UnixService FilePath PrivateService
| FifoService FilePath PrivateService
| PassService FilePath PrivateService
- deriving (Show)
+ deriving (Show, Eq)
-- Can be a port number or service name such as "smtp".
type ServicePort = String
@@ -160,7 +160,7 @@ data ServiceOpts = ServiceOpts
, serviceWakeupTime :: Maybe Int
, serviceProcessLimit :: Maybe Int
}
- deriving (Show)
+ deriving (Show, Eq)
defServiceOpts :: ServiceOpts
defServiceOpts = ServiceOpts
@@ -254,13 +254,16 @@ parseServiceLine l = Service
-- | Enables a `Service` in postfix's `masterCfFile`.
service :: Service -> RevertableProperty NoInfo
service s = (enable <!> disable)
- `describe` ("enabled postfix service " ++ show (serviceType s))
+ `describe` desc
where
- enable = masterCfFile `File.containsLine` l
+ desc = "enabled postfix service " ++ show (serviceType s)
+ enable = masterCfFile `File.containsLine` (formatServiceLine s)
`onChange` reloaded
- disable = masterCfFile `File.lacksLine` l
+ disable = File.fileProperty desc (filter (not . matches)) masterCfFile
`onChange` reloaded
- l = formatServiceLine s
+ matches l = case parseServiceLine l of
+ Just s' | s' == s -> True
+ _ -> False
-- | Installs saslauthd and configures it for postfix, authenticating
-- against PAM.