]> rtime.felk.cvut.cz Git - eurobot/public.git/blobdiff - devel-utils/mount-robot
robofsm: Map 2012
[eurobot/public.git] / devel-utils / mount-robot
index f829656ff607d84423c288ad97f15bde8e3cddf8..c6518ee59d0965fd062856ef1b1ad77b41b0d463 100755 (executable)
@@ -1,26 +1,32 @@
 #!/bin/sh
-set -x
 myip=$(ip a|grep -o 'inet 10\.1\.1\.[0-9]\+'|cut -d ' ' -f 2)
+mypath=$(readlink --canonicalize $PWD/$(dirname $0)/../build/ppc/_compiled)
 
-if [ $USER = "zandar" ]; then
-       mypath=/home/zandar/EUROBOT/eurobot/build/ppc/_compiled
-       mount_point=/home/michalv
-elif [ $USER = "filip" ]; then
-       mypath=/home/filip/fel/eb/build/ppc/_compiled
-       mount_point=/home/filip
-elif [ $USER = "wsh" ]; then
-       mypath=/home/wsh/projects/eurobot/soft/build/ppc/_compiled
-       mount_point=/home/michal
-else
-       echo "Error: Unknown user $USER" >&2
-       exit 1
+if [ ! -d "$mypath" ]; then
+    echo "$0: error: Cannot find $mypath"
+    exit 1
+fi
+
+if [ -z "$myip" ]; then
+    echo "$0: error: You do not seem to be connected to the robot"
+    echo "Your IP address should be 10.1.1.xxx"
+    exit 1
+fi
+
+set -x
+
+if ! grep -q $mypath /var/lib/nfs/etab; then
+    sudo exportfs -o ro,no_subtree_check,no_root_squash 10.1.1.1:$mypath
 fi
 
+mount_point="/tmp/$USER@$myip"
+
 if [ "$1" = "-u" ]; then
        cmd="umount $mount_point"
 else
-       cmd="mount -o nolock $myip:$mypath $mount_point"
+       cmd="mkdir -p $mount_point && mount -o nolock $myip:$mypath $mount_point"
 fi
+
 ssh root@10.1.1.1 $cmd
 if [ "$1" = "-c" ]; then
        ssh root@10.1.1.1 /home/bin/copy_from $mount_point