Group properties

Signed-off-by: Félix Sipma <felix.sipma@no-log.org>
This commit is contained in:
Félix Sipma 2014-11-23 18:33:26 +01:00 committed by Joey Hess
parent 69eace8e9a
commit 6aa21366d5
2 changed files with 15 additions and 0 deletions

View File

@ -83,6 +83,7 @@ Library
Propellor.Property.Firewall
Propellor.Property.Git
Propellor.Property.Gpg
Propellor.Property.Group
Propellor.Property.Grub
Propellor.Property.Network
Propellor.Property.Nginx

View File

@ -0,0 +1,14 @@
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"
test = not <$> elem group' <$> words <$> readProcess "cut" ["-d:", "-f1", groupFile]
args Nothing = [group']
args (Just gid) = ["--gid", show gid, group']