rc.mandrake.zaptel 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. # Source function library.
  12. . /etc/rc.d/init.d/functions
  13. ######################################
  14. # CONFIGURE ME !!!
  15. ######################################
  16. MODULES="usb-uhci zaptel wcfxo wcusb"
  17. ######################################
  18. function probe() {
  19. gprintf " $1"
  20. insmod $1
  21. # It has to be in the module list, otherwise something is wrong
  22. if lsmod | grep -c ^$1 >/dev/null; then
  23. success
  24. else
  25. failure
  26. fi
  27. echo
  28. }
  29. function unprobe() {
  30. gprintf " $1"
  31. rmmod $1 >/dev/null 2>&1
  32. # If it's still in the module list after removing it, there's something wrong.
  33. if lsmod | grep -c ^$1 >/dev/null; then
  34. failure
  35. else
  36. success
  37. fi
  38. echo
  39. }
  40. function reverse_modules() {
  41. tmp=$MODULES
  42. MODULES=''
  43. for i in $tmp; do
  44. MODULES="$i $MODULES" ;
  45. done
  46. }
  47. # See how we were called.
  48. case "$1" in
  49. start)
  50. gprintf "Loading Asterisk modules:\n"
  51. for i in $MODULES; do
  52. probe $i
  53. usleep 100000 ;
  54. done
  55. ztcfg
  56. ;;
  57. stop)
  58. gprintf "Unloading Asterisk modules:\n"
  59. reverse_modules
  60. for i in $MODULES; do
  61. unprobe $i
  62. usleep 100000 ;
  63. done
  64. ;;
  65. status)
  66. ztcfg -vv
  67. ;;
  68. restart)
  69. $0 stop
  70. $0 start
  71. ;;
  72. *)
  73. gprintf "*** Usage: $0 {start|stop|status|restart}\n"
  74. exit 1
  75. esac
  76. exit 0