#!/bin/bash

vdir=`dirname $0`
. $vdir/vasm-functions
check_root

#if [ $DISPLAY ]; then
#  DIALOG=Xdialog
#else
#  DIALOG=dialog
#fi
 $DCMD --backtitle "$BACKTITLE" --title "HAL Or VL-HOT?" --menu \
 "Would you like to use VL-Hot or HAL to manage your removable devices?  \n
 VL-Hot uses the kernel and udev to mount removable devices when they are attached, 
 and HAL uses a polling daemon that continually scans the system for recently attached hardware.\n 
 We recommend VL-Hot for older hardware. \n 
 Choose the system you would like to use, and we will disable the other." 20 71 4\
    "VL-HOT" "udev-based external block device automounting system" \
    "HAL" "a daemon that implements hardware abstraction layer" \
    2> $freply
     result=$?
     if [ $result != 0 ];then
       exit 0
     fi
     DRIVER="`cat $freply`"
     #echo $DRIVER
     case "$DRIVER" in
      "VL-HOT")
      #while [ ! "$(ps -ef|grep hal|wc|cut -d " " -f7)" = 1 ];do sh /etc/rc.d/rc.hald stop; sleep 1;done
        sh /etc/rc.d/rc.hald stop &>/dev/null
        #sh /etc/rc.d/rc.messagebus stop &>/dev/null
	chmod -x /etc/rc.d/rc.hald
	#chmod -x /etc/rc.d/rc.messagebus
	mv /etc/udev/rules.d/10-vl-hot.rules.disabled /etc/udev/rules.d/10-vl-hot.rules &>/dev/null
        exit 0 
       ;;
      "HAL")
	chmod +x /etc/rc.d/rc.hald
	#chmod +x /etc/rc.d/rc.messagebus
        /etc/rc.d/rc.hald start &>/dev/null
        #/etc/rc.d/rc.messagebus start &>/dev/null
	mv /etc/udev/rules.d/10-vl-hot.rules /etc/udev/rules.d/10-vl-hot.rules.disabled &>/dev/null
       exit 0
       ;;
      esac
