]> arthur.barton.de Git - usertools.macosx.git/blobdiff - useradd.macosx.sh
useradd.macosx.sh: Update copyright and usage information
[usertools.macosx.git] / useradd.macosx.sh
index 5382ec02d84baf49073751a179f392b936e0971e..1081c796905a41261e063460dac3afd101f8b33f 100755 (executable)
@@ -1,16 +1,14 @@
 #!/bin/bash
 #
 # useradd.macosx
-# Copyright (c)2008 Barton IT-Consulting, Alexander Barton
+# Copyright (c)2008,2009 Barton IT-Consulting, Alexander Barton
 #
-# 2008-07-28, alex@barton-it.de - R2
-#  - start directory services when not running (e. g. single user mode)
-# 2008-07-28, alex@barton-it.de - R1
-#  - initial version.
+# This is free software; see the source for copying conditions. There is NO
+# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 #
 
 NAME=`basename $0`
-RELEASE="2"
+RELEASE="3"
 
 Abort() {
        [ $# -lt 1 ] \
@@ -20,7 +18,7 @@ Abort() {
 }
 Usage() {
        echo "$NAME (useradd.macosx.sh) release $RELEASE"
-       echo "Copyright (c)2008 Barton IT-Consulting, Alexander Barton (alex@barton-it.de)"
+       echo "Copyright (c)2008,2009 Barton IT-Consulting, Alex Barton (alex@barton-it.de)"
        echo
        echo "This is free software; see the source for copying conditions. There is NO"
        echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -128,13 +126,8 @@ fi
 # No user ID given, generate it
 if [ $user_id -lt 0 ]; then
        # search next free user ID
-       declare -i new_id=501
-       id "$new_id" >/dev/null 2>&1
-       while [ $? -eq 0 ]; do
-               new_id=$new_id+1;
-               id "$new_id" >/dev/null 2>&1
-       done
-       user_id=$new_id
+       user_id=`echo $[$(dscl . -list /Users uid | awk '{print $2}' \
+               | sort -n | tail -n1)+1]`
 fi
 
 # Validate user name, user id and group id