#!/sbin/runscript

NOVFS_MOUNT_PATH=/var/opt/novell/nclmnt
export XTIER_CODE_PAGE=`locale charmap`
export NCPL_DO_NOT_OVERWRITE_OPENLOG=1

depend() {
  before xdm
  need net
  after novell-xregd
}

#checkconfig() {
#  if [ ! -e ${NDSD_CONFIGFILE} ] ; then
#     eerror "Novell eDirectory server has not been configured."
#     return 1
#  fi
#}

start() {
  export XTIER_CODE_PAGE=`locale charmap`
  export NCPL_DO_NOT_OVERWRITE_OPENLOG=1
  
  ebegin "Loading novell novfs kernel module"
  #Try and start novfs
  modprobe novfs
  lsmod |grep novfs 2>&1 >/dev/null
  eend $?
  ebegin "Mounting novell novfs"
  #Mount our filesystem
  mount -t novfs novfs $NOVFS_MOUNT_PATH
  eend $?

  EnableNMAS=1
  if [ -f /etc/opt/novell/ncl/login.conf ]; then
    cat /etc/opt/novell/ncl/login.conf |grep "NMAS_Authentication=false" 2>&1 >/dev/null
    if [ $? -eq 0 ]; then
       EnableNMAS=0
    fi
  fi

  if [ $EnableNMAS -eq 0 ]; then
  ebegin "Starting novell novfs daemon with NMAS-Authentication"
  start-stop-daemon --start --quiet --exec /opt/novell/ncl/bin/novfsd -- -m
  else
  ebegin "Starting Novell novfs daemon"
  start-stop-daemon --start --quiet --exec /opt/novell/ncl/bin/novfsd 
  fi

  eend $?
}

stop() {
  ebegin "Stopping Novell novfs daemon"
  start-stop-daemon --stop --quiet --name novfsd
  eend $?
#  ebegin "unMounting novell novfs"
#  umount $NOVFS_MOUNT_PATH 2>/dev/null
  #Check to see if mount point is still mounted
#  mount | grep novfs 2>&1 > /dev/null
#  eend $?
#  ebegin "unLoading novell novfs kernel module"
#  rmmod novfs
#  eend $?
}

#restart() {
#  (Commands necessary to restart the service)
#}