summaryrefslogtreecommitdiff
path: root/src/Propellor/Property/Group.hs
diff options
context:
space:
mode:
authorFélix Sipma2014-11-23 18:33:26 +0100
committerJoey Hess2014-11-23 14:37:49 -0400
commit6aa21366d57679f82fbaf96a90f93d2d1ac7f223 (patch)
tree5da8692c615013ec898ffb7cb157ed4e257d9d45 /src/Propellor/Property/Group.hs
parent69eace8e9a9d4fb2c6193e9e44ea836bd0bf8ba4 (diff)
Group properties
Signed-off-by: Félix Sipma <felix.sipma@no-log.org>
Diffstat (limited to 'src/Propellor/Property/Group.hs')
-rw-r--r--src/Propellor/Property/Group.hs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/Propellor/Property/Group.hs b/src/Propellor/Property/Group.hs
new file mode 100644
index 00000000..f03510cf
--- /dev/null
+++ b/src/Propellor/Property/Group.hs
@@ -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']