#!/bin/bash
#
# udev-post     Post script for udev, after all filesystems are mounted
#
# Authors:      Harald Hoyer <harald@redhat.com>
#
# chkconfig: 345 26 75
# description: Moves the generated persistent udev rules to /etc/udev/rules.d
# 
### BEGIN INIT INFO
# Requires: $local_fs
### END INIT INFO

. /etc/rc.d/init.d/functions

# See how we were called.
case "$1" in
  start)
	STRING=$"Adding udev persistent rules"
	
	# copy the rules generated before / was mounted read-write
	for file in /dev/.udev/tmp-rules--*; do
		dest=${file##*tmp-rules--}
		# check, if anything is todo
		[ "$dest" = '*' ] && exit 0
		echo -n $STRING 
		cat $file >> /etc/udev/rules.d/$dest
		rc=$?
		rm -f $file
		if [ "$rc" -eq "0" ]; then
			success "$STRING"
			echo
		elif [ "$rc" -eq "1" ]; then
			failure "$STRING"
			echo
            	fi
	done
	exit 0
	;;
  stop)
	exit 0
	;;
  *)
        echo $"Usage: $0 {start}"
        exit 1
esac
exit 0
