-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcondor_shell
executable file
·101 lines (85 loc) · 2.33 KB
/
condor_shell
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/bin/bash -e
function usage {
echo "This script creates an interactive shell environment through condor."
echo " USAGE: condor_shell [OPTIONS]"
}
function flags {
echo " FLAGS:"
echo " --machine MACHINE"
echo " Specify a machine to run on."
echo " -w,--whole|--whole-machine"
echo " Specify if you want to run a whole machine job"
echo " -C,--change-dir DIR"
echo " Start the job in the directory specified by DIR"
echo " --nwd"
echo " Don't start the job in the same directory that condor_shell is run from"
}
# Default values.
MACHINE="n"
WHOLE_MACHINE="n"
INITIAL_DIR="$(pwd)"
while [[ $# -gt 0 ]] ;
do
case $1 in
--machine)
MACHINE="${2}"
shift
shift
;;
-w|--whole|--whole-machine)
WHOLE_MACHINE="y"
shift
;;
-h|--help)
usage
flags
exit 0
;;
-C|--change-dir)
INITIAL_DIR="$(realpath ${2})"
shift
shift
;;
--nwd)
INITIAL_DIR="n"
shift
;;
-*|--*)
PASS_NAME=$(echo "$1" | sed 's/^-*//')
PASSES+=("${PASS_NAME}")
shift
;;
*)
echo "Too many positional arguments passed!"
usage
exit 1
;;
esac
done
TMP_CONDOR=$(mktemp)
echo "Universe = vanilla" >> ${TMP_CONDOR}
if [[ "${MACHINE}" == "n" ]] ; then
echo "Requirements = " >> ${TMP_CONDOR}
else
echo "Zythos = ${MACHINE}" >> ${TMP_CONDOR}
echo "Requirements = ((Machine == \"\$(Zythos).cs.northwestern.edu\"))" >> ${TMP_CONDOR}
fi
echo "Rank = TARGET.Mips" >> ${TMP_CONDOR}
echo "Getenv = True" >> ${TMP_CONDOR}
if [[ "${WHOLE_MACHINE}" == "n" ]] ; then
echo "+IsWholeMachineJob = false" >> ${TMP_CONDOR}
else
echo "+IsWholeMachineJob = true" >> ${TMP_CONDOR}
fi
echo "+IsSuspensionJob = false" >> ${TMP_CONDOR}
if [[ "${INITIAL_DIR}" != "n" ]] ; then
echo "InitialDir = ${INITIAL_DIR}" >> ${TMP_CONDOR}
echo "Remote_InitialDir = ${INITIAL_DIR}" >> ${TMP_CONDOR}
fi
echo "priority = 0" >> ${TMP_CONDOR}
echo "queue" >> ${TMP_CONDOR}
echo "Condor file: ${TMP_CONDOR}"
cat ${TMP_CONDOR}
echo ""
condor_submit -i ${TMP_CONDOR}
rm ${TMP_CONDOR}