[K12OSN] while read do questionts

cliebow at downeast.net cliebow at downeast.net
Fri Feb 4 12:06:00 UTC 2005


###############################################################
cat People.csv | while read line; do
first=$(echo $line | cut -f1 -d ',')
last=$(echo $line | cut -f2 -d ',')
year=$(echo $line  | cut -f3 -d ',')
password=$(echo $line | cut -f4 -d ',')
name=$(echo $line | cut -f5 -d ',')
gid=$year
# echo $gid
 ##################################################################
##echo "Now set up school based on year"
#################################################################
##echo "switching for Staff and Students"
if [ "$year" = "BEM" ] ; then year="$year,ou=Staff" && gid=2051
elif [ "$year" = "CCK" ] ; then year="$year,ou=Staff" && gid=2052
elif [ "$year" = "EHS" ] ; then year="$year,ou=Staff" && gid=2053
elif [ "$year" = "EMS" ] ; then year="$year,ou=Staff" && gid=2054
elif [ "$year" = "HCTC" ] ; then year="$year,ou=Staff" && gid=2055
elif [ "$year" = "SO" ] ; then year="$year,ou=Staff" && gid=2056
elif [ "$year" = "2005" ] ; then year="$year,ou=Students"
elif [ "$year" = "2006" ] ; then year="$year,ou=Students"
elif [ "$year" = "2007" ] ; then year="$year,ou=Students"
elif [ "$year" = "2008" ] ; then year="$year,ou=Students"
elif [ "$year" = "2009" ] ; then year="$year,ou=Students"
elif [ "$year" = "2010" ] ; then year="$year,ou=Students"
elif [ "$year" = "2011" ] ; then year="$year,ou=Students"
elif [ "$year" = "2012" ] ; then year="$year,ou=Students"
elif [ "$year" = "2013" ] ; then year="$year,ou=Students"
elif [ "$year" = "2014" ] ; then year="$year,ou=Students"
fi

#################################################################
(echo "dn: cn=$name,ou=$year,ou=People,$suffix"
echo "sambaLMPassword: B1208432F8D13F034A3B108F3FA6CB6D"
echo "sambaPrimaryGroupSID: $SID-$uid"
echo "displayName: $first $last"
echo "sambaLogonScript: $name.cmd"
echo "objectClass: top"
echo "objectClass: inetOrgPerson"
echo "objectClass: posixAccount"
echo "objectClass: sambaSAMAccount"
echo "userPassword:: e1NTSEF9L2FMV2RNYkFsMVZBanIwMWNjMjZCVER1MFFUc01jNnQ="
echo "sambaLogonTime: 0"
echo "sambaHomeDrive: P:"
echo "uid: $name"
echo "uidNumber: $uid"
echo "cn: $name"
echo "sambaLogoffTime: 2147483647"
echo "sambaPwdLastSet: 1069876848"
echo "loginShell: /bin/bash"
echo "sambaAcctFlags: [UX]"
echo "sambaProfilePath: \\\\$shortened\\profiles\\$name"
###########################
echo "gidNumber: $gid"
##########################
echo "sambaPwdMustChange: 0"
echo "sambaNTPassword: 0C61039F010B2FBB88FE449FBF262477"
echo "gecos: $first $last"
echo "sambaPwdCanChange: 0"
echo "sambaSID: $SID-$uid"
echo "description: $first $last"
echo "homeDirectory: /home/$name"
echo "sambaKickoffTime: 2147483647"
echo "sn: $name"
echo "sambaHomePath: \\\\$shortened\homes"
echo ) >> $LDIFDIR/People.ldif
let "uid +=1"
done

ok coders: can you get me round this stupid brain-flattulence. run 2000
users thru this piece of script and uid increments on each pass.so at end
of script uid otter be 2027 or summat..

echo "Now reset NextFreeUnixId"
(echo "dn: cn=NextFreeUnixId,$suffix"
echo "gidNumber: 2020"
echo "uidNumber: $uid"
echo "objectClass:inetOrgPerson"
echo "objectClass: sambaUnixIdPool"
echo "sn: NextFreeUnixId"
echo "cn: NextFreeUnixId"
echo ) > $LDIFDIR/FreeUnix.ldif
ldapmodify -x -h localhost -D "$dn" -w "$pw"  -f $LDIFDIR/FreeUnix.ldif


when i reset FreeUnixid with the above uid is back to its default value..
i want nextfreeunixid to reflect obviously the last usable id.

i kniw this is trivial but i cant seem to get round it

chuck

---------------------------------------------
This message was sent from Downeast.Net.
http://ellsworthme.com/





More information about the K12OSN mailing list