7 DISABLED_PAGE=/~sysadmin/expired/index.php
12 EXPIRED_USERS=$(mktemp "/tmp/expired_users.XXXX")
15 # Identify expired accounts
18 # Get the current term
21 TERM_START_MONTH=$(($MONTH - (($MONTH - 1) % 4)))
23 # NOTE: This is configured to give 1 months grace period
24 if [ ${TERM_START_MONTH} -eq 1 ]; then
25 if [ ${MONTH} -eq 1 ]; then
26 TERM_FILTER="(!(term=F$((${YEAR} - 1))))(!(term=W${YEAR}))"
28 TERM_FILTER="(!(term=W${YEAR}))"
30 elif [ ${TERM_START_MONTH} -eq 5 ]; then
31 if [ ${MONTH} -eq 5 ]; then
32 TERM_FILTER="(!(term=W${YEAR}))(!(term=S${YEAR}))"
34 TERM_FILTER="(!(term=S${YEAR}))"
36 elif [ ${TERM_START_MONTH} -eq 9 ]; then
37 if [ ${MONTH} -eq 9 ]; then
38 TERM_FILTER="(!(term=S${YEAR}))(!(term=F${YEAR}))"
40 TERM_FILTER="(!(term=F${YEAR}))"
43 echo "Invalid term start month: ${TERM_START_MONTH}" >&2
47 # Find expired accounts
48 ldapsearch -xb "ou=People,dc=csclub,dc=uwaterloo,dc=ca" "(&${TERM_FILTER}(objectClass=member))" | grep 'uid:' | awk '{print $2}' | sort -u > ${EXPIRED_USERS}
51 # Generate Apache config
53 for uid in $(cat ${EXPIRED_USERS}); do
54 if [ -d /users/${uid}/www ] && [[ ! ${WHITELIST} =~ ${uid} ]]; then
55 echo "<Directory /users/${uid}>"
56 echo " AllowOverride None"
57 echo " RewriteEngine On"
58 echo " RewriteRule . ${DISABLED_PAGE} [L]"
64 rm -f ${EXPIRED_USERS}