#/bin/sh
if test $# -lt 3
  then
   clear
   echo ""
   echo ""
   echo "USAGE: $0 <NetBios hostname> <shared directory/drive> <mount point> -r -p"
   echo ""
exit 1
fi
if test $# -gt 5
  then
   clear
   echo ""
   echo ""
   echo "USAGE: $0 <NetBios hostname> <shared directory/drive> <mount point> -r -p"
   echo ""
exit 1 
fi
if test "$4" = "-r" -a "$5" = "-p" -o  "$5" = "-r" -a "$4" = "-p" -o "$4" = "-p" -a "$5" = "" -o "$4" = "-r" -a "$5" = ""
  then
    clear
  if test -d "$3"
    then
      :
    else
      mkdir $3
  fi
   clear
   echo ""
   echo ""
   echo "This will mount //$1/$2 at mount point $3"
   echo ""
   echo "$3 will be unavailable as a directory on this server until you are done."
   echo ""
  if test "$4" = "-p" -o "$5" = "-p"
    then
      smbmount //$1/$2 $3 -n shadowlans -N
    else
      smbmount //$1/$2 $3 -n shadowlans
  fi
    echo "//$1/$2" > ~/tmp.share.f
    echo "$3" > ~/tmp.share.x
    echo "$4" > ~/tmp.share.rm
    clear
    echo ""
    echo "Finished mounting //$1/$2 to $3"
    echo ""
    echo "Don't forget to run: nowin to unmount the share at $3!!!"
    echo ""
    echo ""
  if test "$4" = "-r" -o "$5" = "-r"
    then
      echo "1" > ~/tmp.share.rm
    else
      echo "0" > ~/tmp.share.rm
  fi
    chmod 7551 ~/tmp.share.*
    exit 0
  else
   clear
   echo ""
   echo ""
   echo "USAGE: $0 <NetBios hostname> <shared directory/drive> <mount point> -r -p"
   echo ""
exit 1
fi
