#!/bin/sh
# Copyright (c) 2008 SuSE Linux AG, Nuernberg, Germany.
# All rights reserved.
#
# Author: Marcus Schäfer
#
# /etc/init.d/sax
#
#   and it's symbolic link
#
# /usr/sbin/rcsax
#
### BEGIN INIT INFO
# Provides:       sax
# Required-Start: $remote_fs $syslog
# Should-Start:
# Required-Stop:
# Should-Stop:
# Default-Start:  3 5
# Default-Stop: 
# Description:    run sax2    
# Short-Description: run sax2 if required 
### END INIT INFO

. /etc/rc.status

# First reset status of this service
rc_reset

case "$1" in
	start)
		echo -n "Creating X configuration..."
		xconf=0
		if [ -f /etc/dmidecode.md5 ];then
			dmidecode | md5sum --check /etc/dmidecode.md5 &>/dev/null || xconf=1
		fi
		if [ ! -f /etc/X11/xorg.conf ] ;then
			xconf=1
		fi
		if [ $xconf = 1 ] ;then
			#test -e /proc/splash && echo verbose > /proc/splash
			/usr/sbin/sax2 -c 0 -a &>/dev/null
			#test -e /proc/splash && echo silent > /proc/splash
		else
			rc_status -s
			rc_exit
		fi
		dmidecode | md5sum > /etc/dmidecode.md5		
		rc_status -v
		;;
	stop)
		echo -n "Creating X configuration..."
		rc_status -v
		;;
	try-restart)
		$0 status >/dev/null &&  $0 restart
		rc_status
		;;
	restart)
		$0 stop
		$0 start
		rc_status
		;;
	*)
		echo "Usage: $0 {start|stop|try-restart|restart}"
		exit 1
		;;
esac
rc_exit

