Last active
August 23, 2016 02:45
-
-
Save ramblingenzyme/b4c439211ffacb7703ed7c6634e475bb 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/env bash | |
TURNIN=false; | |
while getopts :c:a:u:th opt; do | |
case $opt in | |
c) | |
CLASS="$OPTARG" | |
;; | |
a) | |
ASSIGN="$OPTARG" | |
;; | |
u) | |
BANSHEEUSER="$OPTARG" | |
;; | |
t) | |
TURNIN=true; | |
;; | |
\?) | |
echo "Invalid option: -$OPTARG" | |
exit 1 | |
;; | |
:) | |
echo "Option -$OPTARG requires an argument." | |
exit 1 | |
;; | |
esac | |
done | |
shift $((OPTIND-1)) | |
# Initialise ssh directive | |
DIRECTIVE="cd $CLASS/$ASSIGN &&" | |
# Copy the files | |
if [[ $# -ne 0 ]]; then | |
FILES=$@ | |
elif [[ $# -eq 0 ]]; then | |
FILES=\* | |
fi | |
ssh [email protected] -t "mkdir $CLASS" | |
rsync -r $FILES [email protected]:$CLASS/$ASSIGN | |
# Create the submit directive | |
if [ "$TURNIN" = false ]; then | |
DIRECTIVE="$DIRECTIVE /share/bin/submit -u $BANSHEEUSER -c $CLASS -a $ASSIGN $FILES" | |
else | |
DIRECTIVE="$DIRECTIVE /share/bin/turnin -c $CLASS -a $ASSIGN $FILES && /share/bin/turnout -c $CLASS -a $ASSIGN" | |
fi | |
echo $DIRECTIVE | |
ssh [email protected] -t $DIRECTIVE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment