]> rtime.felk.cvut.cz Git - eurobot/public.git/blobdiff - devel-utils/mount-robot
robofsm: Map 2012
[eurobot/public.git] / devel-utils / mount-robot
index 8b4b551c5408fd92b12bbb02fe4e41d02f2f17f5..c6518ee59d0965fd062856ef1b1ad77b41b0d463 100755 (executable)
@@ -1,27 +1,33 @@
 #!/bin/sh
-
 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
-elif [ $USER = "petr" ]; then
-       mypath=/mnt/data/eurobot/eurobot/build/
-       mount_point=/home/petr
-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
+fi