#!/bin/bash

conf=$HOME/.rcondor/rcondor.conf

if [ ! -f $conf ]; then
  echo "rcondor: config file does not exist: $conf" >&2  
  exit 1
fi

# parse config file
usr_host=`awk -F = '/^ *USR_HOST *=/ {print $2}' "$conf"`
usr_host=`echo $usr_host` # strip whitespaces
local=`awk -F = '/^ *LOCAL *=/ {print $2}' "$conf"`
local=`echo $local`
remote=`awk -F = '/^ *REMOTE *=/ {print $2}' "$conf"`
remote=`echo $remote`

# make sure config values are nonzero length
if [ -z "$usr_host" ] || [ -z "$local" ] || [ -z "$remote" ]; then
  echo "rcondor_mnt: error parsing rcondor.conf" >&2
  exit 1
fi

sshfs "$usr_host:$remote" "$local"
