#!/bin/bash
#
# kudzu		This scripts runs the kudzu hardware probe.
#
# chkconfig: 345 05 95
# description: 	This runs the hardware probe, and optionally configures \
#		changed hardware.

# This is an interactive program, we need the current locale

[ -f /etc/profile.d/lang.sh ] && . /etc/profile.d/lang.sh

if [ "$LANG" = "ja" -o "$LANG" = "ja_JP.eucJP" ]; then
    # We can't Japanese on normal console at boot time.
    # So, force to set LANG=C
    if [ "$TERM" = "linux" ] ; then
	LANG=C
    fi
fi

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

KUDZU_ARGS=

# Do we want to do a safe probe?
. /etc/sysconfig/kudzu

if [ "$SAFE" != "no" ]; then
	KUDZU_ARGS="-s"
fi
if [ "xxx$aurora" != "xxx" ];then
    KUDZU_ARGS="$KUDZU_ARGS -q"
fi

RETVAL=$?

case "$1" in
 start)
	echo -n $"Suche neue Hardware"

        # Have a 30 second timeout.
 	/usr/sbin/kudzu $KUDZU_ARGS -t 30
	RETVAL=$?
	if [ "$RETVAL" -eq 0 ]; then
  	   action "" /bin/true
	else
	   action "" /bin/false
           if [ "$RETVAL" -eq 5 ]; then
	       echo -n $"Hardware Konfiguration fehlgeschlagen."
	       echo -n $"Starten Sie  '/usr/sbin/kudzu' von der Kommandozeile fr einen erneuten Versuch."
	       initlog -n kudzu -s $"Hardware Konfiguration fehlgeschlagen."
	       initlog -n kudzu -s $"Starten Sie  '/usr/sbin/kudzu' von der Kommandozeile fr einen erneuten Versuch."
	   fi
	fi
	# We don't want to run this on random runlevel changes.
	touch /var/lock/subsys/kudzu
	# However, if they did configure X and want runlevel 5, let's
	# switch to it...
	if [ -f /var/run/ranXconfig ]; then
	    grep -q "^id:5:initdefault:" /etc/inittab && telinit 5
	    rm -f /var/run/ranXconfig
	fi
	;;

 status)
	;;
 reload)
        ;;
 stop)
 	rm -f /var/lock/subsys/kudzu
 	;;
 *)
 	echo $"Benutzung: kudzu {start|stop}"
	exit 1
	;;
esac

exit $RETVAL
