X-Git-Url: https://arthur.barton.de/gitweb/?p=usertools.macosx.git;a=blobdiff_plain;f=useradd.macosx.sh;h=01a6b4a9ae93f0e6599b5978c22e23409ef1571b;hp=5382ec02d84baf49073751a179f392b936e0971e;hb=HEAD;hpb=b0526459da47522b5548716ff61abe74bca73e01 diff --git a/useradd.macosx.sh b/useradd.macosx.sh index 5382ec0..01a6b4a 100755 --- a/useradd.macosx.sh +++ b/useradd.macosx.sh @@ -1,16 +1,20 @@ #!/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 program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +# or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. # NAME=`basename $0` -RELEASE="2" +RELEASE="3" Abort() { [ $# -lt 1 ] \ @@ -20,7 +24,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." @@ -45,8 +49,8 @@ sw_vers -productName 2>/dev/null | grep "Mac OS X" >/dev/null 2>&1 [ $? -eq 0 ] || Abort "This script requires Mac OS X!" epoch=`sw_vers -productVersion | cut -d'.' -f1` major=`sw_vers -productVersion | cut -d'.' -f2` -if [ $epoch -ne 10 -o $major -ne 5 ]; then - Abort "This script requires Mac OS X 10.5.x Leopard!" +if [ $epoch -ne 10 -o $major -lt 5 -o $major -gt 6 ]; then + Abort "This script requires Mac OS X 10.5.x or 10.6.x!" fi # Defaults @@ -128,13 +132,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