#!/bin/sh
########################################################################
# Begin $rc_base/init.d/udev_retry
#
# Description : Udev Retry Boot Script
#
# Authors     : Based on Open Suse Udev Rules
#               kay.sievers@suse.de
#
# Adapted to  : Jim Gifford
# LFS
#
# Version     : 00.00
#
# Notes       : Retry Udev events that have failed after local file
#               systems are mounted
#
########################################################################

. /etc/sysconfig/rc
. ${rc_functions}

case "$1" in
    start)
	if test -d /dev/.udev/failed; then
	    boot_mesg "Retry device configuration..."
	    list=$(echo /dev/.udev/failed/*)
	    for i in $list; do
		device="$(readlink $i)/uevent"
		test -e $device && echo "add" > $device
	    done
	fi
	loop=300
	confirm=0
	while true ; do
	    sleep 0.1
	    test -d /dev/.udev/queue && confirm=0 || confirm=$(( $confirm + 1 ))
	    loop=$(( $loop - 1 ))
	    test $loop -gt 0 || break
	    test $confirm -lt 10 || break
	done
	echo_ok
	;;
    *)
	echo "Usage: $0 {start}"
	exit 1
	;;
esac
