2 Komitmen 93da9bfbfb ... c4987c82d3

Pembuat SHA1 Pesan Tanggal
  theo c4987c82d3 Added -y flag to removeperson to bypass confirmation 2 tahun lalu
  theo 0b51f131f3 Fix grammar 2 tahun lalu
3 mengubah file dengan 17 tambahan dan 7 penghapusan
  1. 1 1
      creategroup
  2. 1 1
      createperson
  3. 15 5
      removeperson

+ 1 - 1
creategroup

@@ -13,7 +13,7 @@ fi
 cn="$1"
 
 if group_exists $cn; then
-    echo "Group $cn already exist." 
+    echo "Group $cn already exists." 
     exit 1
 fi
 

+ 1 - 1
createperson

@@ -31,7 +31,7 @@ done
 pw=$(/usr/sbin/slappasswd -s "salut$uid")
 
 if user_exists $uid; then
-    echo "User $uid already exist." 
+    echo "User $uid already exists." 
     exit 1
 fi
 

+ 15 - 5
removeperson

@@ -2,6 +2,12 @@
 . .env
 . funcs
 
+# Check if option -y is passed
+if [ "$1" = "-y" ]; then
+	confirmed="true"
+	shift
+fi
+
 uid=$1
 if user_exists $uid; then
     true
@@ -10,15 +16,19 @@ else
     exit 1
 fi
 
-read -p "Are you sure you want to delete user $uid [y/N] " a
+[ -z "$confirmed" ] && read -p "Are you sure you want to delete user $uid [y/N] " a
 
 case $a in
     y*|o* )
+	confirmed="true";;
+    *)
+	confirmed="false";;
+esac
+
+if [ $confirmed = "true" ]; then
 	if user_is_posix $uid; then 
 		ldapdelete $LDAPOPTS cn=$uid,$GROUPSDN
 		./removefromgroups $uid $(get_posixGroups $uid)
 	fi
-	ldapdelete $LDAPOPTS uid=$uid,$PEOPLEDN ;;
-    * )
-        exit;;
-esac
+	ldapdelete $LDAPOPTS uid=$uid,$PEOPLEDN
+fi