-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsync.sh
More file actions
executable file
·64 lines (53 loc) · 1.89 KB
/
sync.sh
File metadata and controls
executable file
·64 lines (53 loc) · 1.89 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
#! /usr/bin/env bash
Help()
{
# Display Help
echo -e "Syncs a robot with the current workspace."
echo -e "Usage: sync.sh [options] <user> <hostname>"
echo -e " sync.sh [options] <user> <ip address>"
echo -e
echo -e "Options:"
echo -e "\t-h\tDisplay this help message."
}
# Get the options
while getopts ":h" option; do
case $option in
h) # display Help
Help
exit;;
\?) # incorrect option
echo "Error: Invalid option"
exit;;
esac
done
# Remove the options from the positional parameters
shift $((OPTIND - 1))
# Check if the positional parameters are valid
if [ $# -ne 2 ]; then
echo "Error: Invalid number of positional parameters"
exit
fi
user=$1
hostname=$2
port=22
echo "Checking if $user@$hostname is up"
ssh -p $port -q $user@$hostname -o ConnectTimeout=1 exit
if [ $? -ne 0 ]; then
echo "Error: $user@$hostname is down. Please make sure that you can access the robot via 'ssh $user@$hostname'."
exit
fi
echo "$user@$hostname is up"
# Create /tmp/install_dependencies.sh
echo "Creating /tmp/install_dependencies.sh"
AMENT_PREFIX_PATH="none" bash -c "rosdep install --dependency-types=exec --default-yes --ignore-src -r --simulate --reinstall --as-root apt:false -n --from-paths src > /tmp/install_dependencies.sh"
chmod +x /tmp/install_dependencies.sh
# Copy the install_dependencies.sh to the robot
echo "Copying install_dependencies.sh to the robot"
rsync -e "ssh -p $port" --progress /tmp/install_dependencies.sh $1@$2:/tmp/install_dependencies.sh
# Copy the install/ directory to the robot
remote_install_dir='~/'$(basename $(pwd))
echo "Copying contents of install/ to $1@$2:$remote_install_dir"
rsync -e "ssh -p $port" --progress -r install $1@$2:$remote_install_dir
echo "Installing dependencies on the robot"
ssh -p $port $1@$2 "sudo /tmp/install_dependencies.sh"
echo "Syncing done! Run 'source $remote_install_dir/install/setup.bash' on the robot."