#!/bin/bash
#set -x
if test $# -gt 0
  then 
    clear
    echo "USAGE: $0"
    echo ""
    echo "Be sure to stop USING the directory when you run this command...."
    echo "Otherwise you will produce an error....."
    echo ""
  exit 1
fi
#if test -d $x
#  then
    for i in `cat ~/tmp.share.x`
      do 
        x=$i
    done
if test $? -gt 0
  then
    for y in `cat ~/tmp.share.f`
      do
        f=$y
    done
  if test -d $x 
    then
      smbumount $x
  else
     clear
     echo "USAGE: $0"
     echo ""
     echo "Be sure to stop USING the directory when you run this command...."
     echo "Otherwise you will produce an error....." 
     echo ""
    exit 1
  fi
  if test $? -gt 0
    then
      clear
      echo ""
      echo "Be sure to stop USING the directory when you run this command...."
      echo "Otherwise you will produce an error....."
      echo ""
      echo "Don't forget to check all XTERM windows if you receive an error!"
      echo ""
    exit 1
  else
    for z in `cat ~/tmp.share.rm`
      do
        r=$z
    done
  fi
  if test "$z" = "0"
    then
      :
  else 
      rmdir $x
  fi
  echo ""
  echo "Cleaning. . . ."
  rm ~/tmp.share.f
  rm ~/tmp.share.x
  rm ~/tmp.share.rm
  clear
  echo ""
  echo "Windows share $f has been umounted from $x"
  echo ""
  echo ""
exit 0
  else 
   clear
   echo ""
   echo "USAGE: $0"
   echo ""
   echo "This command requires that a NetBios share be activated using the win command."
   echo "Otherwise you will produce an error....."
   echo ""
   echo "To unmount an existing share, cd out of the directory and type:"
   echo ""
   echo "umount <directory> - ie. umount /tmp/doh"
   echo ""
exit 1
fi 
