diff --git a/fugit.sh b/fugit.sh index aabbd05fedd54f230ea1a6294dc3921ba4375a38..54576e4e09f763e1f8066771968225c2e05b91ec 100755 --- a/fugit.sh +++ b/fugit.sh @@ -1,9 +1,12 @@ #!/bin/sh -if [ $# -gt 2 ]; then - printf "Usage: %s [branch] [reponame]" $(basename $0) >&2 - printf "Default branch name will be read from comments.txt" >&2 - printf "Default reponame will be npvp-exercises" >&2 +if [ $# -gt 2 ] || [ "$1" = "--help" ]; then + printf "Usage: %s [branch] [reponame]\n" $(basename $0) >&2 + printf "Default branch name will be read from comments.txt\n" >&2 + printf "Default reponame will be npvp-exercises\n" >&2 + printf "set env:FU_ANDORRA_USER and optionally env:FU_ANDORRA_DIR to checkout and run on andorra automatically\n" >&2 + printf "if env:FU_ANDORRA_DIR is not set, a npvp-tmp dir will be created in your main dir\n" >&2 + printf "set env:FU_RUN={0,1,2} to 0 = make, 1 = python, 3 = nodejs\n when running on andorra (default is make)\n" >&2 exit 1 fi @@ -22,4 +25,26 @@ else branch_name=$1 fi -`git clone -b $branch_name git@git.imp.fu-berlin.de:$repo_name git-solution` +case ${FU_RUN:-0} in + 1) + run_cmd="python3 main.py" + ;; + 2) + run_cmd="node main.js" # i hope this is correct, we will see when the sheet are finalised. + ;; + *) + run_cmd="make run" + ;; +esac + +if ! [ -z $FU_ANDORRA_USER ]; then + # FU_ANDORRA_USER is set, executing on andorra + clone_dir=${FU_ANDORRA_DIR:-npvp-tmp} + + `ssh $FU_ANDORRA_USER@andorra.imp.fu-berlin.de \ + "git clone -b $branch_name git@git.imp.fu-berlin.de:$repo_name ./$clone_dir || exit 1; cd $clone_dir && $run_cmd; cd .. && rm -rf $clone_dir"` +else + # run locally: + git clone -b $branch_name git@git.imp.fu-berlin.de:$repo_name git-solution || exit 1 + cd git-solution && `$run_cmd`; cd .. +fi diff --git a/fugitclean.sh b/fugitclean.sh index b567d5eb9d70e480ae6a10233619b23bbbabdc88..23924f6ef8860a00600b3a33fc7997e2891febe5 100755 --- a/fugitclean.sh +++ b/fugitclean.sh @@ -2,7 +2,12 @@ # this script cleans all checked out repositories when called from the same folder that contains the grades.csv # or a singular checked out repo when called from within a student folder +if [ -z $FU_ANDORRA_USER ]; then + # only clean up when not run on ssh + # ssh cleans up itself :) + find -type d \ -wholename "*/git-solution" -prune \ -execdir sh -c "rm -rf ./git-solution/" {} \; +fi