Skip to content

Instantly share code, notes, and snippets.

@ramblingenzyme
Created September 7, 2015 02:43
Show Gist options
  • Save ramblingenzyme/6e649e69e56d7b4bb10b to your computer and use it in GitHub Desktop.
Save ramblingenzyme/6e649e69e56d7b4bb10b to your computer and use it in GitHub Desktop.
#!/usr/bin/bash
TURNIN="false";
while getopts :c:a:th opt; do
case $opt in
c)
CLASS="$OPTARG"
;;
a)
ASSIGN="$OPTARG"""
;;
t)
TURNIN="true";
\?)
echo "Invalid option: -$OPTARG"
exit 1
;;
:)
echo "Option -$OPTARG requires an argument."
exit 1
;;
esac
done
shift $((OPTIND-1))
#Mounts banshee if needed
if [ ! mountpoint -q /mnt/banshee ]; then
sshfs ss960@banshee.cs.uow.edu.au: /mnt/banshee
fi
#Creates target directory if doesn't exist
if [[ ! -d /mnt/banshee/$CLASS/$ASSIGN/ ]]; then
mkdir -p /mnt/banshee/$CLASS/$ASSIGN
fi
cd ~/src/$CLASS/$ASSIGN/
if [[ $# -ne 0 && "$TURNIN" = false ]]; then
cp ./$@ /mnt/banshee/$CLASS/$ASSIGN
if [ "$TURNIN" = false ]; then
DIRECTIVE="cd $CLASS/$ASSIGN && /share/bin/submit -u ss960 -c $CLASS -a $ASSIGN $@"
else
DIRECTIVE="cd $CLASS/$ASSIGN && /share/bin/turnin -c $CLASS -a $ASSIGN $@ && turnout -c $CLASS -a $ASSIGN"
fi
elif [[ $# -gt 0 ]]; then
cp * /mnt/banshee/$CLASS/$ASSIGN
if [ "$TURNIN" = false ]; then
DIRECTIVE="cd $CLASS/$ASSIGN && /share/bin/submit -u ss960 -c $CLASS -a $ASSIGN *"
else
DIRECTIVE="cd $CLASS/$ASSIGN && /share/bin/turnin -c $CLASS -a $ASSIGN * && turnout -c $CLASS -a $ASSIGN"
fi
fi
ssh ss960@banshee.cs.uow.edu.au -t $DIRECTIVE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment