26ce46d3fd9f57129e471b74e62c9a63faf5aa23
[asterisk/asterisk.git] / contrib / init.d / rc.mandrake.zaptel
1 #!/bin/sh
2 #
3 # zaptel:       Loads Asterisk modules
4 #
5 # Version:      @(#) /etc/rc.d/init.d/zaptel 1.0
6 #
7 # chkconfig: 2345 90 10
8 # description: Loads and unloads zaptel modules at boot time and shutdown.
9 #
10 # hide: true
11
12 # Source function library.
13 . /etc/rc.d/init.d/functions
14
15 ######################################
16 #   CONFIGURE ME !!!
17 ######################################
18 MODULES="usb-uhci zaptel wcfxo wcusb"
19 ######################################
20
21 function probe() {
22         gprintf "                           $1"
23         insmod $1
24         # It has to be in the module list, otherwise something is wrong
25         if lsmod | grep -c ^$1 >/dev/null; then
26                 success
27         else
28                 failure
29         fi
30         echo
31 }
32
33 function unprobe() {
34         gprintf "                           $1"
35         rmmod $1 >/dev/null 2>&1
36         # If it's still in the module list after removing it, there's something wrong.
37         if lsmod | grep -c ^$1 >/dev/null; then
38                 failure
39         else
40                 success
41         fi
42         echo
43 }
44
45 function reverse_modules() {
46         tmp=$MODULES
47         MODULES=''
48         for i in $tmp; do
49                 MODULES="$i $MODULES" ;
50         done
51 }
52
53 # See how we were called.
54 case "$1" in
55   start)
56         gprintf "Loading Asterisk modules:\n"
57         for i in $MODULES; do
58                 probe $i
59                 usleep 100000 ;
60         done
61         ztcfg
62         ;;
63   stop)
64         gprintf "Unloading Asterisk modules:\n"
65         reverse_modules
66         for i in $MODULES; do
67                 unprobe $i
68                 usleep 100000 ;
69         done
70         ;;
71   status)
72         ztcfg -vv
73         ;;
74   restart)
75         $0 stop
76         $0 start
77         ;;
78   *)
79         gprintf "*** Usage: $0 {start|stop|status|restart}\n"
80         exit 1
81 esac
82
83 exit 0
84