Created
September 7, 2015 02:43
-
-
Save ramblingenzyme/6e649e69e56d7b4bb10b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 [email protected]: /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 [email protected] -t $DIRECTIVE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment