#!/bin/sh
########################################################################
# BooNE utility to ensure that we're picking up auto.master and
# auto.misc, etc, from NIS
#
# Chris Green <greenc@fnal.gov>
# UCR / BooNE
# 2002/05/22
#
########################################################################
# Check NIS is running
if [ -z "`ypwhich`" ]; then
  echo "Unable to find NIS server" 1>&2
  exit 2
fi

# Check we're not trying to screwup the NIS master
if [ -f /var/yp/src/auto.master ]; then
  echo "Will not remove autofs files on NIS master" 1>&2
  exit 0
fi

# Check we actually have something to do
if [ -f /etc/auto.master -a -f /etc/auto.misc ]; then
  rm -f /etc/auto.master /etc/auto.misc
  [[ -f /var/lock/subsys/autofs ]] && /etc/rc.d/init.d/autofs restart
  exit 0
else
  echo "autofs config files have already been removed: nothing to do" 1>&2
  exit 0
fi