make_static_devs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #!/bin/sh
  2. set -e
  3. # make_static_devs: create static device files for DAHDI
  4. # Copyright (C) 2010 by Xorcom <support@xorcom.com>
  5. #
  6. # This program is free software; you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation; either version 2 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program; if not, write to the Free Software
  18. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. # In most cases DAHDI device files are generated by udev,
  20. # but there would be cases where you'd want to just have static device
  21. # files. Note that if you do use udev, that static device files will be
  22. # essentially deleted.
  23. BASE_DIR="/dev/dahdi"
  24. usage() {
  25. me=`basename $0`
  26. echo "$me: Generate static DAHDI device files"
  27. echo ""
  28. echo "Usage:"
  29. echo " $me [-h] [-d base_dir]"
  30. echo " -d base_dir: create under base_dir (default: $BASE_DIR)"
  31. echo " -h: this help message."
  32. }
  33. mknod_safe() {
  34. if [ -c $1 ]; then return; fi
  35. mknod "$@"
  36. }
  37. while getopts 'd:h' opt; do
  38. case "$opt" in
  39. h) usage; exit 0;;
  40. d) BASE_DIR="$OPTARG";;
  41. \?) usage; exit 1;;
  42. esac
  43. done
  44. mkdir -p "$BASE_DIR"
  45. mknod_safe "${BASE_DIR}/ctl" c 196 0
  46. mknod_safe "${BASE_DIR}/transcode" c 196 250
  47. mknod_safe "${BASE_DIR}/timer" c 196 253
  48. mknod_safe "${BASE_DIR}/channel" c 196 254
  49. mknod_safe "${BASE_DIR}/pseudo" c 196 255
  50. # The following are not used by Asterisk itself nowadays. Some DAHDI
  51. # users still find it simpler to open them directly rather than using
  52. # /dev/dahdi/channel and the DAHDI_SPECIFY ioctl .
  53. for i in `seq 249`; do
  54. mknod_safe ${BASE_DIR}/$i c 196 $i
  55. done