|
|
@@ -0,0 +1,42 @@
|
|
|
+#!/bin/bash
|
|
|
+. .env
|
|
|
+. funcs
|
|
|
+
|
|
|
+# Check if option -p is passed, and if so prepare for a posixGroup creation
|
|
|
+if [ "$1" = "-p" ]; then
|
|
|
+ posix="true"
|
|
|
+ shift
|
|
|
+else
|
|
|
+ posix="false"
|
|
|
+fi
|
|
|
+
|
|
|
+cn="$1"
|
|
|
+
|
|
|
+if group_exists $cn; then
|
|
|
+ echo "Group $cn already exist."
|
|
|
+ exit 1
|
|
|
+fi
|
|
|
+
|
|
|
+uid="$2"
|
|
|
+
|
|
|
+if user_exists $uid; then
|
|
|
+ true
|
|
|
+else
|
|
|
+ echo "User $uid does not exist."
|
|
|
+ exit 1
|
|
|
+fi
|
|
|
+
|
|
|
+group="dn: cn=$cn,$GROUPSDN
|
|
|
+objectClass: top
|
|
|
+objectClass: groupOfNames
|
|
|
+cn: $cn"
|
|
|
+
|
|
|
+if [ $posix = "true" ] ; then
|
|
|
+ group=$(echo "$group
|
|
|
+gidNumber: $(get_posix_number)")
|
|
|
+fi
|
|
|
+
|
|
|
+group=$(echo "$group
|
|
|
+memberUid: $uid,$PEOPLEDN")
|
|
|
+
|
|
|
+echo "$group" #| ldapadd $LDAPOTS
|