-
Notifications
You must be signed in to change notification settings - Fork 0
/
twr.spec
73 lines (66 loc) · 1.86 KB
/
twr.spec
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
# Define help
usage () {
printf "Wrapper for $TOOL_NAME $VERSION\\n\\nPlease specify:\n-i\tInput directory with ALL files to read (REQUIRED)\n-o\tOutput directory for the generated files to be stored (REQUIRED)\n-r\tDirectory containing reference (Optional)\n-v\tDisplay version\n-h\tDisplay this help\n\nEXAMPLE\t\$$TOOL -i /Path/to/input -o /Path/for/output -r /Path/to/reference\n\n";
}
# Define update
update () {
cd $REPO_PATH;
if git diff origin/master $REPO_PATH/$TOOL/$TOOL | grep -q "git --diff"; then
printf "Found newer version of $TOOL.\n\nUpdate $TOOL now?[y/n]: ";
read ANSWER;
echo $ANSWER;
if [ $ANSWER == "y" ]; then
printf "Retrieving changes from git repository\n\n";
git pull;
exec bash "$0" "$@";
fi
fi
}
# Read flags
while getopts 'i:o:r:vh' OPTION; do
case $OPTION in
i)
IFLAG=true;
INPUT="$OPTARG"
;;
o)
OFLAG=true;
OUTPUT="$OPTARG"
;;
v)
echo $TOOL $VERSION;
exit
;;
r)
REFERENCE="$OPTARG"
;;
h)
usage;
exit
;;
:)
echo "Missing option argument for -$OPTARG" >&2;
exit 1
;;
*)
echo "Incorrect options provided";
usage;
exit 1
;;
esac
done
# Check for update
update;
# Check if required options are provided
if ! $IFLAG & ! $OFLAG; then
echo "Please specify all required options";
usage;
exit 1;
fi
# Display info before starting container
printf "Starting $TOOL with $INPUT as input and $OUTPUT as output.\n\n------------\n\nHINT 1\tPlease use the directories /input (mapped to $INPUT) and /output (mapped to $OUTPUT) for your file paths.\n\nHINT 2\tTo Leave $TOOL, simply call \"exit\".\n\n------------\n\n";
# Display version
sudo docker run -it --rm $IMAGE:$VERSION bash -c "$CMD --version";
# Run tool in container
cd $USER_PATH;
sudo docker run -it --rm -v $INPUT:/input -v $OUTPUT:/output -w="/input" -v $REFERENCE:/reference $IMAGE:$VERSION;