2014-11-23 17:33:26 +00:00
|
|
|
module Propellor.Property.Group where
|
|
|
|
|
|
|
|
import Propellor
|
|
|
|
|
|
|
|
type GID = Int
|
|
|
|
|
|
|
|
exists :: GroupName -> Maybe GID -> Property
|
|
|
|
exists group' mgid = check test (cmdProperty "addgroup" $ args mgid)
|
|
|
|
`describe` unwords ["group", group']
|
|
|
|
where
|
|
|
|
groupFile = "/etc/group"
|
2014-11-25 16:59:00 +00:00
|
|
|
test = not . elem group' . words <$> readProcess "cut" ["-d:", "-f1", groupFile]
|
2014-11-23 17:33:26 +00:00
|
|
|
args Nothing = [group']
|
|
|
|
args (Just gid) = ["--gid", show gid, group']
|