#!/bin/sh
#
# chkconfig: 345 05 95
#
# description: \
#	Preloads various thing into filesystem's cache
#
# processname: preload
# config: /etc/preload.d/

# Do not load RH compatibility interface.
WITHOUT_RC_COMPAT=1

# Source function library.
. /etc/init.d/functions

EXECUTABLE=preload
PRELOAD_PROFILES="kdm kde"
RETVAL=0

precat_f()
{
	local P
	for P in $1; do
		[ -f /var/cache/preload/$P.precat1 ] && /usr/bin/precated /var/cache/preload/$P.precat1
		[ -f /var/cache/preload/$P.precat2 ] && /usr/bin/precated /var/cache/preload/$P.precat2
	done
}

preload_f()
{
	local P
	for P in $1; do
		$EXECUTABLE "/etc/preload.d/$P"
	done
	precat_f "$PRELOAD_PROFILES" >/dev/null 2>/dev/null
}


start()
{
	action "Preloading: $PRELOAD_PROFILES" /bin/true
	preload_f "$PRELOAD_PROFILES" >/dev/null 2>/dev/null&
}

condstop()
{
	return 0
}

stop()
{
	return 0
}

restart()
{
	start
}

case "$1" in
	start|condstop|stop|restart)
		"$1"
		;;
	*)
		msg_usage "${0##*/} {start|condstop|stop|restart}"
		RETVAL=1
esac

exit $RETVAL

