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