6 echo "Interrupting account creation"
11 trap sighandler INT TERM
19 GROUP_ID
=1211 # A group everybody's in
20 GROUP_ID2
=1212 # A group nobody's in
21 GROUP_NAME
='od_test_group'
27 echo "Usage: ${NAME} count nodename"
29 echo " ie. ${NAME} 1000 /Local/Default"
31 echo " will create users 1000 users (from '${PREFIX}1' to '${PREFIX}1000')"
32 echo " Default password is set to 'test'"
33 echo " User ID starts from 5000"
34 echo " Default group is '${GROUP_NAME}', Group ID 1211"
36 echo "This tool assumes user 'diradmin' with password 'admin' for OD admin"
45 # if local node we don't need credentials
46 if [ $NODE != "/Local/Default" ]; then
51 echo "Creating users ${PREFIX}1 to ${PREFIX}$COUNT"
53 # check to see if od_test_group exist. if not, create one
55 result
=`dscl $NODE -list Groups/${GROUP_NAME}1 2> /dev/null`
57 echo "Group \"${GROUP_NAME}\" does not exist. Creating ${GROUP_NAME}"
58 if [ -n "$OD_ADMIN" ]; then
59 dseditgroup
-q -o create
-n $NODE -u $OD_ADMIN -P $OD_PASS -i ${GROUP_ID} ${GROUP_NAME}1
60 dseditgroup
-q -o create
-n $NODE -u $OD_ADMIN -P $OD_PASS -i ${GROUP_ID2} ${GROUP_NAME}2
62 dseditgroup
-q -o create
-n $NODE -i ${GROUP_ID} ${GROUP_NAME}1
63 dseditgroup
-q -o create
-n $NODE -i ${GROUP_ID2} ${GROUP_NAME}2
68 echo "Failed to create test_group"
72 # using dsimport is faster than using dscl
75 echo "Writing a temporary import file ..."
76 while [ $i -le $COUNT ]
78 result
=`dscl $NODE -list Users/${PREFIX}${i} 2> /dev/null`
80 # Uses standard template
81 # RecordName:Password:UniqueID:PrimaryGroupID:DistinguishedName:NFSHomeDirectory:UserShell
82 echo "${PREFIX}${i}:test:${uid}:1211:${PREFIX}${i}:/Users/${PREFIX}${i}:/bin/bash" >> $TMPF
83 printf "\r${PREFIX}${i} / ${COUNT}"
85 echo "account $PREFIX$i already exist. skipping"
92 # Now do the real work
94 if [[ -f $TMPF ]]; then
95 echo "Running dsimport to create users. Please be patient. This takes a while ..."
96 # assume if admin is provided that slapconfig exists
97 if [ -n "$OD_ADMIN" ]; then
98 if [[ -x "/usr/sbin/slapconfig" ]]; then
99 /usr
/sbin
/slapconfig
-setfullsyncmode no
102 /usr
/bin
/time dsimport
$TMPF $NODE I
--username $OD_ADMIN --password $OD_PASS --template StandardUser
104 if [[ -x "/usr/sbin/slapconfig" ]]; then
105 /usr
/sbin
/slapconfig
-setfullsyncmode yes
108 /usr
/bin
/time dsimport
$TMPF $NODE I
--template StandardUser
112 # and now delete the temp file
116 echo "Nothing done. All users already exist"
119 echo Create a SACL group
for libMicro
120 # Create a sample SACL group
121 dseditgroup
-q -o create
-r "libMicro ACL" com.apple.access_libMicro
123 while [ $i -le $COUNT ]; do
124 dseditgroup
-q -o edit
-a ${PREFIX}${i} -t user com.apple.access_libMicro