Guest User

kannel init.d script for ubuntu

a guest
Aug 7th, 2012
436
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.29 KB | None | 0 0
  1. #!/bin/sh
  2. # Start/stop the Kannel boxes: One bearer box and one WAP box.
  3.  
  4. # This is the default init.d script for Kannel. Its configuration is
  5. # appropriate for a small site running Kannel on one machine.
  6.  
  7. # Make sure that the Kannel binaries can be found in $BOXPATH or somewhere
  8. # else along $PATH. run_kannel_box has to be in $BOXPATH.
  9.  
  10. ### BEGIN INIT INFO
  11. # Provides: kannel
  12. # Required-Start: $local_fs $remote_fs
  13. # Required-Stop: $local_fs $remote_fs
  14. # Should-Start: $network $named
  15. # Should-Stop: $network $named
  16. # Default-Start: 2 3 4 5
  17. # Default-Stop: 0 1 6
  18. # Short-Description: SMS and WAP gateway
  19. # Description: Kannel is a gateway for connecting WAP phones to the
  20. # Internet. It also works as an SMS gateway.
  21. ### END INIT INFO
  22.  
  23. . /lib/lsb/init-functions
  24.  
  25. BOXPATH=/usr/sbin
  26. PIDFILES=/var/run/kannel
  27. CONF=/etc/kannel/kannel.conf
  28.  
  29. PATH=$BOXPATH:$PATH
  30.  
  31. # On Debian, the most likely reason for the bearerbox not being available
  32. # is that the package is in the "removed" or "unconfigured" state, and the
  33. # init.d script is still around because it's a conffile. This is normal,
  34. # so don't generate any output.
  35. test -x $BOXPATH/bearerbox || exit 0
  36.  
  37. test -r /etc/default/kannel && . /etc/default/kannel
  38.  
  39. if [ ! -d $PIDFILES ]
  40. then
  41. mkdir $PIDFILES
  42. chown kannel:root $PIDFILES
  43. fi
  44.  
  45. case "$1" in
  46. start)
  47. log_daemon_msg "Starting WAP gateway"
  48. log_progress_msg "bearerbox"
  49. start-stop-daemon --start --quiet \
  50. --pidfile $PIDFILES/kannel_bearerbox.pid \
  51. --chuid kannel \
  52. --exec $BOXPATH/run_kannel_box \
  53. -- \
  54. --pidfile $PIDFILES/kannel_bearerbox.pid \
  55. --no-extra-args \
  56. $BOXPATH/bearerbox -v 4 -- $CONF
  57. sleep 1 # Wait for bearerbox
  58. test ! -z $START_WAPBOX && (
  59. log_progress_msg "wapbox"
  60. start-stop-daemon --start --quiet \
  61. --pidfile $PIDFILES/kannel_wapbox.pid \
  62. --chuid kannel \
  63. --exec $BOXPATH/run_kannel_box \
  64. -- \
  65. --pidfile $PIDFILES/kannel_wapbox.pid \
  66. --no-extra-args \
  67. $BOXPATH/wapbox -v 4 -- $CONF
  68. )
  69. test ! -z $START_SMSBOX && (
  70. log_progress_msg "smsbox"
  71. start-stop-daemon --start --quiet \
  72. --pidfile $PIDFILES/kannel_smsbox.pid \
  73. --chuid kannel \
  74. --exec $BOXPATH/run_kannel_box \
  75. -- \
  76. --pidfile $PIDFILES/kannel_smsbox.pid \
  77. --no-extra-args \
  78. $BOXPATH/smsbox -v 4 -- $CONF
  79. )
  80. log_end_msg 0
  81. ;;
  82.  
  83. stop)
  84. log_daemon_msg "Stopping WAP gateway"
  85. test ! -z $START_SMSBOX && (
  86. log_progress_msg "smsbox"
  87. start-stop-daemon --stop --retry 5 --quiet \
  88. --pidfile $PIDFILES/kannel_smsbox.pid \
  89. --exec $BOXPATH/run_kannel_box
  90. )
  91. test ! -z $START_WAPBOX && (
  92. log_progress_msg "wapbox"
  93. start-stop-daemon --stop --retry 5 --quiet \
  94. --pidfile $PIDFILES/kannel_wapbox.pid \
  95. --exec $BOXPATH/run_kannel_box
  96. )
  97. log_progress_msg "bearerbox"
  98. start-stop-daemon --stop --retry 5 --quiet \
  99. --pidfile $PIDFILES/kannel_bearerbox.pid \
  100. --exec $BOXPATH/run_kannel_box
  101. log_end_msg 0
  102. ;;
  103.  
  104. reload)
  105. # We don't have support for this yet.
  106. exit 1
  107. ;;
  108.  
  109. restart|force-reload)
  110. $0 stop
  111. sleep 1
  112. $0 start
  113. ;;
  114.  
  115. *)
  116. echo "Usage: $0 {start|stop|restart|force-reload}"
  117. exit 1
  118.  
  119. esac
  120.  
  121. exit 0
Advertisement
Add Comment
Please, Sign In to add comment