#!/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
-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