#!/sbin/sh
#@(#)HP X Station Admin Scripts
#
# Ask_floppy_prefs
#
#	Ask user to choose behaviour when logging in
#	through vue/xdm Xstartup  in regard to the x terminal floppy
#	The result is placed in file passed in $2
#
trap 'exit 0' 1 2 3 15

THISPATH=`ls -la $0 | awk '{print $NF}'`
THISDIR=`dirname $THISPATH`
OS=`$THISDIR/xtutil_get-os`

case $OS in
  sco|sun4)
    ECHO="echo -n"
    NL=""
    ;;
  *)
    ECHO="echo"
    NL="\c"
    ;;
esac

FLOPPY_PREFS=$2
floppy_prefs ()
{


  while [ 0 ]
  do
    echo ""
    echo "  Your HP X Station seems to have a floppy drive." 
    echo "  If you choose so, the floppy may be NFS mounted on the unix host"
    echo "  and become accessible as $HOME/floppy, "
    echo "  whenever you login through xdm or vuelogin. "
    echo "  (it will automatically be unmounted when you logout)"
    echo ""
    echo "  Please choose a mount mode."
    echo "  The available mount modes are:"
    echo "    1) always mount floppy without asking"
    echo "    2) never mount floppy "
    echo "    3) ask each time you login"
    echo ""
    $ECHO "Please enter selection [1|2|3] (def=1): $NL"
    read SEL 
    echo ""
    echo "#"	                                           > $FLOPPY_PREFS
    echo "# This file controls if the HP X Station floppy" >> $FLOPPY_PREFS
    echo "# is NFS mounted as $HOME/floppy "              >> $FLOPPY_PREFS
    echo "# when user logs in through xdm or vuelogin."   >> $FLOPPY_PREFS
    echo "# Valid options are MOUNT NOMOUNT PROMPT"         >> $FLOPPY_PREFS
    echo "# option MOUNT   = always mount floppy"         >> $FLOPPY_PREFS
    echo "# option NOMOUNT = never mount floppy "	  >> $FLOPPY_PREFS
    echo "# option PROMPT     = ask each time you login"	  >> $FLOPPY_PREFS
    echo "#"	                                          >> $FLOPPY_PREFS
    echo "# You may enable a particular mount option"     >> $FLOPPY_PREFS  
    echo "# by uncommenting the 1 appropriate line below" >> $FLOPPY_PREFS
    echo "# (remove # in column 1)"                   	  >> $FLOPPY_PREFS
    echo "# and comment the 2 non-appropriate lines."     >> $FLOPPY_PREFS
    echo "# (prepend # in column 1)"                      >> $FLOPPY_PREFS
    echo "#"	                                          >> $FLOPPY_PREFS
    
    case $SEL in
      1|"")
        echo "#NOMOUNT"  >> $FLOPPY_PREFS
        echo "#PROMPT"      >> $FLOPPY_PREFS
        echo "MOUNT"     >> $FLOPPY_PREFS
        ;;
      2)
        echo "#MOUNT"  >> $FLOPPY_PREFS
        echo "#PROMPT"    >> $FLOPPY_PREFS
        echo "NOMOUNT" >> $FLOPPY_PREFS
        ;;
      3)
        echo "#MOUNT"   >> $FLOPPY_PREFS
        echo "#NOMOUNT" >> $FLOPPY_PREFS
        echo "PROMPT"      >> $FLOPPY_PREFS
        ;;
      *)
        continue
        ;;
     esac
     chmod 644 $FLOPPY_PREFS
     echo "  Your selection was saved in the file \$HOME/.hpxt_floppy"
     echo "  If you want to change the floppy mount mode, this file"
     echo "  may be edited using any standard editor."
     echo ""
     $ECHO "Please type <Enter> to continue $NL"
     read SEL 
     break
  done
}

will_mount ()
{
  #
  # will_mount
  #
  #	Ask user to choose behaviour when logging in
  #	through vue/xdm Xstartup  in regard to the x terminal floppy
  #

  while [ 0 ]
  do
    echo ""
    $ECHO "NFS mount X Station floppy on \$HOME/floppy? [y|n] (def=y): $NL"
    read SEL 
    echo ""
    case $SEL in
      y|Y|""|y*|Y*)
        touch /tmp/.mount.hpxt
        exit 0
        ;;
      n|N|n*|N*)
        exit 1
        ;;
      *)
      continue
      ;;
    esac
    break
  done
}

$1
