-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy_sim.sh
More file actions
57 lines (43 loc) · 1.34 KB
/
deploy_sim.sh
File metadata and controls
57 lines (43 loc) · 1.34 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
#!/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/project.jar
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"
scp -o "StrictHostKeyChecking=no" -r "$deployed_code" "${user}@${server}":"$deployed_code"
ssh -o "StrictHostKeyChecking=no" "${user}@${server}" "launch_robot_code.sh $deployed_code $@"
set +x
echo -e "\nDeploy finished. Your code is running"
echo -e "\nOpen simulation viewer at http://$server"