diff options
| -rw-r--r-- | propellor.cabal | 1 | ||||
| -rw-r--r-- | src/Propellor/Property/Group.hs | 14 |
2 files changed, 15 insertions, 0 deletions
diff --git a/propellor.cabal b/propellor.cabal index a09a80d1..cd34d4bf 100644 --- a/propellor.cabal +++ b/propellor.cabal @@ -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 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'] |
