#! /bin/sh

do_dev () {
  rm -f /dev/$1
  mknod /dev/$1 $5 $6 $7
  chown $2:$3 /dev/$1
  chmod $4 /dev/$1
}

case "$1" in
  configure)
    do_dev null 0 0 666 c 1 3
    do_dev zero 0 0 666 c 1 5
    do_dev full 0 0 666 c 1 5
    do_dev random 0 0 666 c 1 8
    do_dev urandom 0 0 444 c 1 9
    do_dev tty 0 0 666 c 5 0
    do_dev ptmx 0 0 666 c 5 2
    ln -s /proc/self/fd /dev/fd
    ln -s /proc/self/fd/0 /dev/stdin
    ln -s /proc/self/fd/1 /dev/stdout
    ln -s /proc/self/fd/2 /dev/stderr
  ;;

  abort-upgrade|abort-remove|abort-deconfigure)
  ;;

  *)
    echo "postinst called with unknown argument \`$1'" >&2
    exit 1
  ;;
esac

exit 0
