summaryrefslogtreecommitdiff
path: root/build_tools/make_static_devs
blob: 2c19de6698ce497d92cf9d1769aa3cf277e2d061 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/sh

set -e

# make_static_devs: create static device files for DAHDI

# Copyright (C) 2010 by Xorcom <support@xorcom.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

# In most cases DAHDI device files are generated by udev,
# but there would be cases where you'd want to just have static device
# files. Note that if you do use udev, that static device files will be
# essentially deleted.

BASE_DIR="/dev/dahdi"

usage() {
	me=`basename $0`
	echo "$me: Generate static DAHDI device files"
	echo ""
	echo "Usage:"
	echo "  $me [-h] [-d base_dir]"
	echo "    -d base_dir: create under base_dir (default: $BASE_DIR)"
	echo "    -h: this help message."
}


mknod_safe() {
	if [ -c $1 ]; then return; fi
	mknod "$@"
}

while getopts 'd:h' opt; do
	case "$opt" in
	h) usage; exit 0;;
	d) BASE_DIR="$OPTARG";;
	\?) usage; exit 1;;
	esac
done

mkdir -p "$BASE_DIR"
mknod_safe "${BASE_DIR}/ctl" c 196 0
mknod_safe "${BASE_DIR}/transcode" c 196 250
mknod_safe "${BASE_DIR}/timer" c 196 253
mknod_safe "${BASE_DIR}/channel" c 196 254
mknod_safe "${BASE_DIR}/pseudo" c 196 255

# The following are not used by Asterisk itself nowadays. Some DAHDI
# users still find it simpler to open them directly rather than using
# /dev/dahdi/channel and the DAHDI_SPECIFY ioctl .
for i in `seq 249`; do
	mknod_safe ${BASE_DIR}/$i c 196 $i
done