#!/bin/bash # # gengrps - script to assist with the generation of LDIF files for # populating class LDAP groups # # If run by itself, all LDIF definitions will be displayed to STDOUT. # Ideal method of production execution: # # gengrps | ldapmodify -x -W -D "cn=admin,dc=lair,dc=bits" # ATTNDPATH="/home/wedge/local/attendance/etc/list" semester="`/usr/local/bin/semester.sh`" LDAPINFO="dc=lair,dc=bits" for group in `/bin/ls -1A ${ATTNDPATH}/class.${semester}.* | cut -d'.' -f3`; do grouplst="$grouplst $group" done for grp in $grouplst; do if [ "$grp" = "hpc1" ]; then echo "dn: cn=hpc,ou=groups,${LDAPINFO}" elif [ "$grp" = "hpc2" ]; then echo "dn: cn=hpc,ou=groups,${LDAPINFO}" else echo "dn: cn=${grp},ou=groups,${LDAPINFO}" fi echo "changetype: modify" echo "add: memberUid" for student in `grep -v '^[A-Z]' ${ATTNDPATH}/class.${semester}.${grp}.*`; do echo "memberUid: ${student}" done echo done for student in `cat ${ATTNDPATH}/class.${semester}.* | grep '^[^A-Z]' | sort -u`; do echo "dn: cn=${student},ou=groups,${LDAPINFO}" echo "changetype: modify" echo "add: memberUid" echo "memberUid: wedge" echo done exit 0