#!/bin/sh
#@(#)HP Netstation Admin Scripts
#
# get_floppy_prefs
#

trap 'exit 0' 1 2 3 15

#
# This script excutes from vue/xdm Xstartup
# It finds out if user wants x terminal floppy mounted
# and exits with appropriate code
#
#   	exit 0	 =	go ahead and mount	
#	exit 1	=	don't mount
#
# The user indicated preference is kept in a file in $HOME
# Valid values are MOUNT, NOMOUNT, and ASK
# The name of the file to use for preference is passed in $1

get_my_env()
{
  #
  # get env vars only if necessary - (to speed things up)
  #
  THISPATH=`ls -la $0 | awk '{print $NF}'`
  THISDIR=`dirname $THISPATH`
  XTERM=/usr/bin/X11/xterm
  if [ ! -x $XTERM ]
  then
    XTERM=/usr/openwin/bin/xterm
  fi
  if [ ! -x $XTERM ]
  then
    echo "$0: cannot find xterm"
    exit 0
  fi
  XDIALOG=/usr/bin/X11/xdialog
  FLAG=/tmp/.mount.hpxt
}

FLOPPY_PREFS=$1

#if [ ! -f $FLOPPY_PREFS ]
#then
#  get_my_env
#  $XTERM -geometry 80x15+270+270 -bg Gray81 \
#		-e $THISDIR/ask_floppy floppy_prefs $FLOPPY_PREFS
#fi
 
if [ ! -f $FLOPPY_PREFS ]
then
  exit 0
fi

PREFS=`cat $FLOPPY_PREFS | tr "[a-z]" "[A-Z]" | egrep '^[A-Z]' | head -1`

case $PREFS in
  PROMPT)
    get_my_env
    if [ -x $XDIALOG ]
    then
      $XDIALOG -geometry +300+270 -O "yes" -C "no" \
		-m "NFS mount floppy on \$HOME/floppy?" -e "touch $FLAG"
    else
      $XTERM -geometry 65x2+270+270 -bg Gray81 \
		-e $THISDIR/ask_floppy will_mount $FLAG
    fi
    if [ -f "$FLAG" ]
    then
      rm "$FLAG"
      exit 0
    else
      exit 1
    fi
    ;;
  NOMOUNT)
    exit 1
    ;;
  MOUNT|*)
    exit 0 
    ;;
esac

