forked from Splendit/simonykees
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuploadMappingFiles.sh
More file actions
executable file
·65 lines (51 loc) · 1.44 KB
/
uploadMappingFiles.sh
File metadata and controls
executable file
·65 lines (51 loc) · 1.44 KB
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
#!/bin/sh
#author: Matthias Webhofer, Hans-Jörg Schrödl
exitPrintUsage() {
echo "Usage: $0 <originDirectory> <targetDirectory>"
exit 1
}
exitDirectoryNotExisting() {
echo "The Directory $2 doesn't exist!"
exit 2
}
exitDirectoryCreationError() {
echo "The directory named \"$1\" could not be created!"
exit 3
}
exitCopyError() {
echo "Error uploading mapping files!"
exit 4
}
# check argument count
if [ "$#" -ne "2" ]; then
exitPrintUsage
fi
origin_dir=$1
target_dir=$2
# check if the directory, in which all build numbers are stored
# (as directories themselves), exists. exit on failure
if [ -d "$origin_dir" ]; then
# create a temporary directory, if it doesn't exist yet
if [ ! -d "$target_dir" ]; then
mkdir "$target_dir"
if [ $? -gt 0 ]; then
exitDirectoryCreationError
fi
fi
# first: copy all files to temp directory
# find: find all files ending with *.out recursively from the given directory
# xargs: takes the stdout of find and applies cp to each entry of the list
# {} is the placeholder for the list items
find "$origin_dir" -name "*.out" | xargs -i cp {} "$target_dir"
# then: zip and upload to deobfuscation service
zip -r "$target_dir".zip "$target_dir"
curl -F file=@"$target_dir".zip http://172.16.0.6:8080/upload
if [ $? -gt 0 ]; then
exitCopyError
fi
# remove tempdir and zipfile
rm -rf "$target_dir" "$target_dir.zip"
echo "Mapping files uploaded successfully"
else
exitDirectoryNotExisting
fi