#!/bin/sh
#
# devremover    remover of devices from /dev
#
# chkconfig: - 98 03
#
# description: remove some devices after system start
#
# processname: /dev/null
#

# Do not load RH compatibility interface.
WITHOUT_RC_COMPAT=1

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

# DevRemover configuration
SYSCONFIGFILE="/etc/sysconfig/devremover"
SourceIfNotEmpty $SYSCONFIGFILE

BASE="/dev"
RETVAL=1

start()
{
    if [ -n "$LIST_DEV" ];then
	for device in ${LIST_DEV}; do
	    printf "Removing: %s" "${BASE}/$device"
	    [ -b "${BASE}/$device" ] && { rm -f "${BASE}/$device"; echo_success; } || echo_failure
	    RETVAL=$?
	    echo
	done
    else
	printf "Device list is empty %s" "${LIST_DEV}"
	echo_failure
	RETVAL=1
	echo
    fi
    return ${RETVAL}
}

stop()
{
    return 0
}

reload()
{
    return 0
}

# See how we were called.
case "$1" in
        start)
	    if is_yes "$CONFIGURED"; then
                start 
	    else
		printf "Error: %s" "DevRemover is not configured in $SYSCONFIGFILE"
		echo_failure
		echo
		RETVAL=1
	    fi
        ;;
        stop)
	    RETVAL=0
        ;;
	restart|reload)
            stop
	    start
        ;;
	condrestart)
	    RETVAL=0
	;;
	condstop)
	    RETVAL=0
	;;
	restore)
	    udevadm trigger
	;;
        *)
    	    msg_usage "${0##*/} {start|stop|reload|restart|condrestart|restore}"
    	    RETVAL=1
	;;
esac

exit $RETVAL
