#!/bin/sh
#
# ltspswapd	LTSP NBD swap
#
# chkconfig: 2345 12 88
# description:	LTSP NBD swap
# processname: ltspswapd
# config: /etc/sysconfig/ltspswapd
# pidfile: /var/run/ltspswapd.pid

# Do not load RH compatibility interface.
WITHOUT_RC_COMPAT=1

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

PIDFILE=/var/run/ltspswapd.pid
LOCKFILE=/var/lock/subsys/ltspswapd
RETVAL=0

[ -s /etc/sysconfig/ltspswapd ] \
&& . /etc/sysconfig/ltspswapd \
|| ARGS="-s /var/spool/ltspswap"

umask 077

start()
{
	start_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" --expect-user root -- ltspswapd $ARGS
	RETVAL=$?
	return $RETVAL
}

stop()
{
	stop_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" --expect-user root -- ltspswapd
	RETVAL=$?
	return $RETVAL
}

restart()
{
	stop
	start
}

# See how we were called.
case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	reload)
		restart
		;;
	restart)
		restart
		;;
	condstop)
		if [ -e "$LOCKFILE" ]; then
			stop
		fi
		;;
	condrestart)
		if [ -e "$LOCKFILE" ]; then
			restart
		fi
		;;
	condreload)
		if [ -e "$LOCKFILE" ]; then
			reload
		fi
		;;
	status)
		status --pidfile "$PIDFILE" --expect-user root -- ltspswapd
		RETVAL=$?
		;;
	*)
		msg_usage "${0##*/} {start|stop|reload|restart|condstop|condrestart|condreload|status}"
		RETVAL=1
esac

exit $RETVAL
