rc.mandriva.zaptel 1.9 KB

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