]> rtime.felk.cvut.cz Git - eurobot/public.git/blob - devel-utils/mount-robot
robofsm: Homologation 2012
[eurobot/public.git] / devel-utils / mount-robot
1 #!/bin/sh
2 myip=$(ip a|grep -o 'inet 10\.1\.1\.[0-9]\+'|cut -d ' ' -f 2)
3 mypath=$(readlink --canonicalize $PWD/$(dirname $0)/../build/ppc/_compiled)
4
5 if [ ! -d "$mypath" ]; then
6     echo "$0: error: Cannot find $mypath"
7     exit 1
8 fi
9
10 if [ -z "$myip" ]; then
11     echo "$0: error: You do not seem to be connected to the robot"
12     echo "Your IP address should be 10.1.1.xxx"
13     exit 1
14 fi
15
16 set -x
17
18 if ! grep -q $mypath /var/lib/nfs/etab; then
19     sudo exportfs -o ro,no_subtree_check,no_root_squash 10.1.1.1:$mypath
20 fi
21
22 mount_point="/tmp/$USER@$myip"
23
24 if [ "$1" = "-u" ]; then
25         cmd="umount $mount_point"
26 else
27         cmd="mkdir -p $mount_point && mount -o nolock $myip:$mypath $mount_point"
28 fi
29
30 ssh root@10.1.1.1 $cmd
31 if [ "$1" = "-c" ]; then
32         ssh root@10.1.1.1 /home/bin/copy_from $mount_point
33 fi