Guest User

Untitled

a guest
Dec 14th, 2011
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.73 KB | None | 0 0
  1. #!/bin/sh
  2. #
  3. # kannel This script takes care of starting and stopping the kannel \
  4. # WAP gateway services (bearer/wap/smsbox).
  5. # chkconfig: - 97 03
  6. # description: The Kannel WAP and SMS gateway services
  7. # config: /etc/kannel.conf
  8.  
  9. # Use start-stop-kannel
  10. prog="/usr/local/sbin/start-stop-daemon"
  11. args="--start --background --chuid kannel:kannel --exec "
  12. config="/etc/kannel.conf"
  13.  
  14. # Source function library.
  15. . /etc/rc.d/init.d/functions
  16.  
  17. # Source networking configuration.
  18. . /etc/sysconfig/network
  19.  
  20. # Check that networking is up.
  21. [ "${NETWORKING}" = "no" ] && exit 0
  22.  
  23. [ -f $config ] || exit 1
  24.  
  25. RETVAL=0
  26. RETVAL_BEARER=0
  27. RETVAL_WAP=0
  28. RETVAL_SMS=0
  29.  
  30. start() {
  31. # Start daemons.
  32. echo -n "Starting kannel bearer box: "
  33. daemon $prog $args /usr/local/sbin/bearerbox $config
  34. RETVAL_BEARER=$?
  35. echo
  36.  
  37. # It seems like the bearerbox may need to settle before accepting
  38. # connections from wapbox and smsbox
  39. sleep 3s
  40.  
  41. # Starting wap and sms only makes sense if bearerbox is running
  42. if [ $RETVAL_BEARER -eq 0 ]; then
  43. if grep "^group = wapbox" $config &>/dev/null; then
  44. echo -n "Starting kannel wap box: "
  45. daemon $prog $args /usr/sbin/wapbox $config
  46. RETVAL_WAP=$?
  47. echo
  48. fi
  49. if grep "^group = smsbox" $config &>/dev/null; then
  50. echo -n "Starting kannel sms box: "
  51. daemon $prog $args /usr/local/sbin/smsbox $config
  52. RETVAL_SMS=$?
  53. echo
  54. fi
  55. fi
  56. [ $RETVAL_BEARER -eq 0 -a $RETVAL_WAP -eq 0 -a $RETVAL_SMS -eq 0 ] \
  57. && touch /var/lock/subsys/kannel || RETVAL=1
  58. }
  59.  
  60. stop() {
  61. # Stop daemons.
  62. if grep "^group = smsbox" $config &>/dev/null; then
  63. echo -n "Shutting down kannel sms box: "
  64. killproc /usr/local/sbin/smsbox
  65. RETVAL_SMS=$?
  66. echo
  67. fi
  68. if grep "^group = wapbox" $config &>/dev/null; then
  69. echo -n "Shutting down kannel wap box: "
  70. killproc /usr/local/sbin/wapbox
  71. RETVAL_WAP=$?
  72. echo
  73. fi
  74. echo -n "Shutting down kannel bearer box: "
  75. killproc /usr/local/sbin/bearerbox
  76. RETVAL_BEARER=$?
  77. echo
  78. [ $RETVAL_BEARER -eq 0 -a $RETVAL_WAP -eq 0 -a $RETVAL_SMS -eq 0 ] \
  79. || RETVAL=1
  80. rm -f /var/lock/subsys/kannel
  81. }
  82.  
  83. # See how we were called.
  84. case "$1" in
  85. start)
  86. start
  87. ;;
  88. stop)
  89. stop
  90. ;;
  91. status)
  92. status /usr/local/sbin/bearerbox
  93. RETVAL_BEARER=$?
  94. if grep "^group = wapbox" $config &>/dev/null; then
  95. status /usr/local/sbin/wapbox
  96. RETVAL_WAP=$?
  97. fi
  98. if grep "^group = smsbox" $config &>/dev/null; then
  99. status /usr/local/sbin/smsbox
  100. RETVAL_SMS=$?
  101. fi
  102. [ $RETVAL_BEARER -eq 0 -a $RETVAL_WAP -eq 0 -a $RETVAL_SMS -eq 0 ] \
  103. || RETVAL=1
  104. ;;
  105. restart)
  106. stop
  107. start
  108. ;;
  109. *)
  110. echo $"Usage: $0 {start|stop|restart|status}"
  111. RETVAL=1
  112. esac
  113.  
  114. exit $RETVAL
  115.  
Advertisement
Add Comment
Please, Sign In to add comment