#!/bin/sh
#
# s3switch:	Sets up video output on S3 Savage cards.
#
#
# chkconfig:	2345 70 31
# description:	s3switch is a utility with which video outputs on S3 Savage cards can be set
#
# config:	/etc/sysconfig/s3switch

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

# Get service config
if [ -f /etc/sysconfig/s3switch ]; then
	. /etc/sysconfig/s3switch
fi

RETVAL=0
# See how we were called.
case "$1" in
  start)
	# Check if service is already running?
	if [ ! -f /var/lock/subsys/s3switch ]; then
		if [ -n "${S3_OUTPUT}" ]; then
			show "Seting S3 output device"
			busy
			/usr/sbin/s3switch -q $S3_OUTPUT
			touch /var/lock/subsys/s3switch
			ok
		else
			nls "You don't have any output device configured"
			nls "please visit /etc/sysconfig/s3switch"
			RETVAL=6
		fi
	else
		msg_already_running s3switch
	fi
	;;
  stop)
	if [ -f /var/lock/subsys/s3switch ]; then
		msg_stopping s3switch
		busy
		/usr/sbin/s3switch -q BOTH
		rm -f /var/lock/subsys/s3switch
		ok
	else
		msg_not_running s3switch
	fi
	;;
  status)
	if [ -f /var/lock/subsys/s3switch ]; then
		RETVAL=0;
	else
		msg_not_running s3switch
		RETVAL=3
	fi
	/usr/sbin/s3switch
	;;
  restart|force-reload)
	$0 stop
	$0 start
	RETVAL=$?
	;;
  *)
	msg_usage "$0 {start|stop|restart|force-reload|status}"
	RETVAL=3
esac

exit $RETVAL
