Course Management Scripts
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.2 KiB

#!/bin/bash
[ -z "$COURSE" ] && echo "Needs a COURSE set" && exit 1
[ -z "$1" ] && echo "Needs an assignment name" && exit 1
while read USER; do
echo -n "$USER: "
for assn in $*; do
echo -e "\x1b[1;36m$assn:\x1b[0m"
if [ ! -d /course/$COURSE/assn/$USER/$assn ]; then
echo -e "\x1b[1;31mIs not a directory\x1b[0m"
continue
fi
if su $USER -c "test -w /course/$COURSE/assn/$USER/$assn"; then
echo -ne "\x1b[1;32m(test: can write) \x1b[0m"
else
echo -ne "\x1b[1;31m(test: can't write) \x1b[0m"
fi
ACL=`getfacl /course/$COURSE/assn/$USER/$assn 2> /dev/null`
NORM=0
if grep -F "user:$USER:rwx" <<< "$ACL" > /dev/null ; then
echo -ne "\x1b[1;32mopen \x1b[0m"
NORM=1
fi
if grep -F "user:$USER:r-x" <<< "$ACL" > /dev/null ; then
echo -ne "\x1b[1;31mclosed \x1b[0m"
NORM=1
fi
if [ $NORM -ne 1 ]; then
echo -ne "\x1b[1;33mWEIRD? \x1b[0m"
fi
if ! grep -F "user:$USER" <<< "$ACL" > /dev/null ; then
echo -ne "\x1b[1;33mDoesn't exist? \x1b[0m"
fi
USERS=`grep "user:[^:]" <<< "$ACL" | wc -l`
if [ $USERS -gt 1 ]; then
echo -ne "\x1b[1;33mMultiple users? \x1b[0m"
NORM=0
fi
echo
if [ $NORM -ne 1 ]; then
cat <<< "$ACL"
fi
done
done