remove extraneous svn:executable properties
[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 # Default modules - override in /etc/sysconfig/zaptel
16 ######################################
17 MODULES="usb-uhci zaptel wcfxo wcusb"
18 ######################################
19
20 [ -f /etc/sysconfig/`basename $0` ] && . /etc/sysconfig/`basename $0`
21
22 function probe() {
23         gprintf "                           $1"
24         modprobe -i $1
25         # It has to be in the module list, otherwise something is wrong
26         if lsmod | grep -c ^$1 >/dev/null; then
27                 success
28         else
29                 failure
30         fi
31         echo
32 }
33
34 function unprobe() {
35         gprintf "                           $1"
36         rmmod $1 >/dev/null 2>&1
37         # If it's still in the module list after removing it, there's something wrong.
38         if lsmod | grep -c ^$1 >/dev/null; then
39                 failure
40         else
41                 success
42         fi
43         echo
44 }
45
46 function reverse_modules() {
47         tmp=$MODULES
48         MODULES=''
49         for i in $tmp; do
50                 MODULES="$i $MODULES" ;
51         done
52 }
53
54 # See how we were called.
55 case "$1" in
56   start)
57         gprintf "Loading Asterisk modules:\n"
58         for i in $MODULES; do
59                 probe $i
60                 usleep 100000 ;
61         done
62         ztcfg
63         ;;
64   stop)
65         gprintf "Unloading Asterisk modules:\n"
66         reverse_modules
67         for i in $MODULES; do
68                 unprobe $i
69                 usleep 100000 ;
70         done
71         ;;
72   status)
73         #ztcfg -vv
74         OK=1
75         gprintf "Checking Asterisk modules"
76         for i in $MODULES; do
77                 if [ `lsmod | grep -c $i` -eq 0 ]; then
78                         OK=0
79                 fi
80         done
81         if [ $OK -gt 0 ]; then
82                 success
83         else
84                 failure
85         fi
86         echo
87         ;;
88   restart)
89         $0 stop
90         $0 start
91         ;;
92   *)
93         gprintf "*** Usage: $0 {start|stop|status|restart}\n"
94         exit 1
95 esac
96
97 exit 0
98