summaryrefslogtreecommitdiff
path: root/src/Propellor/Property/Group.hs
blob: 978d3bff719d04a0137e534558ec81f4d1546849 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
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']