| 1 |
#!/bin/sh |
| 2 |
# |
| 3 |
# DAHDI: Loads Asterisk modules |
| 4 |
# |
| 5 |
# Version: @(#) /etc/rc.d/init.d/dahdi 1.0 |
| 6 |
# |
| 7 |
# chkconfig: 2345 90 10 |
| 8 |
# description: Loads and unloads DAHDI modules at boot time and shutdown. |
| 9 |
# |
| 10 |
# hide: true |
| 11 |
|
| 12 |
# $Id$ |
| 13 |
|
| 14 |
# Source function library. |
| 15 |
. /etc/rc.d/init.d/functions |
| 16 |
|
| 17 |
# Default modules - override in /etc/sysconfig/dahdi |
| 18 |
###################################### |
| 19 |
MODULES="usb-uhci dahdi wcfxo wcusb" |
| 20 |
###################################### |
| 21 |
|
| 22 |
# Resolve back to the basename (i.e. dahdi, not S90dahdi) |
| 23 |
if [ 0`readlink $0` = "0" ]; then |
| 24 |
CONFIGFILE=/etc/sysconfig/`basename $0` |
| 25 |
else |
| 26 |
CONFIG0=`readlink $0` |
| 27 |
CONFIGFILE=/etc/sysconfig/`basename $CONFIG0` |
| 28 |
fi |
| 29 |
|
| 30 |
[ -f $CONFIGFILE ] && . $CONFIGFILE |
| 31 |
|
| 32 |
function probe() { |
| 33 |
gprintf " $1" |
| 34 |
modprobe -i $1 |
| 35 |
# It has to be in the module list, otherwise something is wrong |
| 36 |
if lsmod | grep -c ^$1 >/dev/null; then |
| 37 |
success |
| 38 |
else |
| 39 |
failure |
| 40 |
fi |
| 41 |
echo |
| 42 |
} |
| 43 |
|
| 44 |
function unprobe() { |
| 45 |
gprintf " $1" |
| 46 |
rmmod $1 >/dev/null 2>&1 |
| 47 |
# If it's still in the module list after removing it, there's something wrong. |
| 48 |
if lsmod | grep -c ^$1 >/dev/null; then |
| 49 |
failure |
| 50 |
else |
| 51 |
success |
| 52 |
fi |
| 53 |
echo |
| 54 |
} |
| 55 |
|
| 56 |
function reverse_modules() { |
| 57 |
tmp=$MODULES |
| 58 |
MODULES='' |
| 59 |
for i in $tmp; do |
| 60 |
MODULES="$i $MODULES" ; |
| 61 |
done |
| 62 |
} |
| 63 |
|
| 64 |
# See how we were called. |
| 65 |
case "$1" in |
| 66 |
start) |
| 67 |
gprintf "Loading Asterisk modules:\n" |
| 68 |
for i in $MODULES; do |
| 69 |
probe $i |
| 70 |
usleep 100000 ; |
| 71 |
done |
| 72 |
ztcfg |
| 73 |
;; |
| 74 |
stop) |
| 75 |
gprintf "Unloading Asterisk modules:\n" |
| 76 |
reverse_modules |
| 77 |
for i in $MODULES; do |
| 78 |
unprobe $i |
| 79 |
usleep 100000 ; |
| 80 |
done |
| 81 |
;; |
| 82 |
status) |
| 83 |
#ztcfg -vv |
| 84 |
OK=1 |
| 85 |
gprintf "Checking Asterisk modules" |
| 86 |
for i in $MODULES; do |
| 87 |
if [ `lsmod | grep -c $i` -eq 0 ]; then |
| 88 |
OK=0 |
| 89 |
fi |
| 90 |
done |
| 91 |
if [ $OK -gt 0 ]; then |
| 92 |
success |
| 93 |
else |
| 94 |
failure |
| 95 |
fi |
| 96 |
echo |
| 97 |
;; |
| 98 |
restart) |
| 99 |
$0 stop |
| 100 |
$0 start |
| 101 |
;; |
| 102 |
*) |
| 103 |
gprintf "*** Usage: $0 {start|stop|status|restart}\n" |
| 104 |
exit 1 |
| 105 |
esac |
| 106 |
|
| 107 |
exit 0 |