#!/bin/sh
### BEGIN INIT INFO
# Provides:            udev $time
# Required-Start:
# Required-Stop:
# Should-Start:        modules mountkernfs
# Should-Stop:
# Default-Start:       S
# Default-Stop:
# Short-Description:   Populate /dev and load kernel modules
### END INIT INFO

. /lib/lsb/init-functions

case "$1" in
  start)
    log_info_msg "Starting udevd"
    /sbin/udevd --daemon || error=1

    /sbin/udevadm trigger --action=add --type=subsystems || error=1
    /sbin/udevadm trigger --action=add --type=devices || error=1
    /sbin/udevadm trigger --action=change --type=devices || error=1
    /sbin/udevadm settle

    [ -z $error ] && log_success_msg || log_failure_msg
    ;;
  restart)
    log_info_msg "Reloading udev"
    udevadm control --reload-rules && udevadm trigger && \
      log_success_msg || log_failure_msg
    ;;
  *)
    echo "Usage $0 [start|stop|restart]"
    ;;
esac

exit 0
