forked from Team766/MaroonFramework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy_sim.sh
executable file
·60 lines (45 loc) · 1.41 KB
/
deploy_sim.sh
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
#!/bin/bash
set -euo pipefail
builtin cd "$(dirname -- "${BASH_SOURCE[0]}")"
if [ $# -gt 0 ]; then
server="$1"
elif [ -f sim_robots.lst ]; then
PS3="Which sim robot would you like to use? "
COLUMNS=1
cancel_option="Cancel Deployment"
select name in $(cat sim_robots.lst) "$cancel_option"
do
server="${name-"$REPLY"}"
break
done
if [ "$server" == "$cancel_option" ]; then
echo "Canceled"
exit
fi
fi
if [ -z "${server-}" ]; then
# Sleep here is necessary to allow Theia to finish opening the task terminal
# before displaying the error message.
sleep 1
echo "Please supply the URL of the sim robot"
exit 1
fi
echo -e "Deploying to $server\n"
set -x
user="root"
./gradlew jar
jar_file=( build/libs/*.jar )
[ "${#jar_file[@]}" -eq 1 ] || (echo "Output jar file could not be determined"; exit 1)
version="$(md5sum < "$jar_file" | awk '{ print $1 }')"
deployed_code="/tmp/project-$(date +%s)-$version"
rm -rf "$deployed_code"
mkdir -p "$deployed_code"
cp "$jar_file" "$deployed_code/project.jar"
cp -R src/main/deploy "$deployed_code"
cp simConfig.txt "$deployed_code"
deployed_package=${deployed_code}.tgz
tar cfz ${deployed_package} -C ${deployed_code} .
curl --fail -F "package=@${deployed_package}" ${server}:4000/uploadrobotcode
set +x
echo -e "\nDeploy finished. Your code is running"
echo -e "\nOpen simulation viewer at http://$server"