#!/bin/sh
#
# linuxconf  Hook to allow linuxconf to put into place any
#	     linuxconf-specific policies
#
# chkconfig: 2345 28 68
# description: Set the Host ID for generating a job ID (jid) and \
#	       load the job module if it is not built into the kernel.

jsethid=/usr/bin/jsethid

if [ ! -x $jsethid ] ; then
	echo "The job commands package is not properly installed."
	exit 1
fi

# See how we were called.
case "$1" in
  start)
	echo "Enabling Linux Jobs"
	if [ ! -f /proc/job ] ; then
	# /proc/job doesn't exist, maybe we need to install the 
	# kernel module.
	/sbin/insmod -s job
	if [ $? -ne 0 ] ; then
		echo -e " Failed to load the job module." \
		"Consult /var/log/messages for\n" \
		"additional error messages to" \
		"deterimine the cause of failure."
		exit 1
		fi
	fi
	$jsethid
	;;
  stop)
	if [ ! -f /proc/job ] ; then
		echo -e " Linux Jobs was not found. There is nothing to stop."
		exit 1
	fi
	echo -e "Disabling Linux Jobs\n"
	echo -e " No new jobs will be created. If Linux Jobs" \
		"support was loaded\n as a kernel module, you" \
		"can unload the module once the number of\n" \
		"running jobs is 0 (zero).  Use the lsmod" \
		"command to find if job\n module is loaded and" \
		"the rmmod command to unload it once the\n" \
		"used-count is 0. The jstat" \
		"command can be used\n to determine what jobs" \
		"are currently running."
	$jsethid 0xffffffff
	;;
  *)
	echo "Usage: $0 start|stop"
	exit 1
esac

exit 0
