# devices
#
# populates /dev with devices and does some housekeeping when using udev,
# does nothing at all when using static /dev

description	"Populates /dev"
author		"Arjan Bouter <abouter@sourcemage.org>"

start on mount_root-start
stop on shutdown

emits devices-start

task

script
  [ -e /etc/sysconfig/devices ] && . /etc/sysconfig/devices
  case $DEVICES in
    udev) echo "using udev to manage /dev"
          mount -t tmpfs dev /dev
          ln -s /proc/self/fd /dev/fd
          ln -s /dev/fd/0 /dev/stdin
          ln -s /dev/fd/1 /dev/stdout
          ln -s /dev/fd/2 /dev/stderr
          mkdir -p /dev/shm
          mount -t tmpfs shm /dev/shm
          mkdir -p /dev/pts
          mount -t devpts devpts /dev/pts
          udevd --daemon
          udevadm trigger
          udevadm settle --quiet
          echo "done starting udev" ;;
    static) echo "static /dev nothing to do" ;;
    *) echo "unsupported /dev system, aborting" ;;
  esac
  initctl emit devices-start
end script
