Guest User

Untitled

a guest
Jan 19th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.90 KB | None | 0 0
  1. # This shell script takes care of starting and stopping
  2. # the Kannel SMS & WAP gateway
  3. # Original version Fabrice Gatille <fgatille at ivision.fr>
  4. # Modified by Stephane Rosa (srosa at domusmea.org) for RedHat9
  5. # chkconfig: 2345 97 03
  6. # description: Kannel is an SMS and WAP gateway
  7.  
  8. VERSION=`/usr/local/bin/gw-config --version`
  9. OPTIONS="--daemonize --parachute --user kannel --pid-file /var/run/kannel/"
  10. KANNELPATH=/usr/local/sbin
  11. CONF=/etc/kannel.conf
  12. CONFDIR=/etc/configurations
  13.  
  14. # Source function library & networking conf.
  15. . /etc/init.d/functions
  16. [ -f /etc/sysconfig/network ] && . /etc/sysconfig/network
  17.  
  18. # Check that we are root ... so non-root users stop here
  19. [ `id -u` = 0 ] || exit 1
  20.  
  21. # Various other checks
  22. [ ${NETWORKING} = "yes" ] || exit 0
  23. [ -x $KANNELPATH/bearerbox ] || exit 0
  24. [ -x $KANNELPATH/smsbox ] || exit 0
  25. [ -x $KANNELPATH/wapbox ] || exit 0
  26. [ -f $CONF ] || exit 0
  27.  
  28. RETVAL=0; RETVAL1=0; RETVAL2=0; RETVAL3=0
  29. prog="Kannel"
  30.  
  31. start() {
  32. # Check that at least one group is defined for sms
  33. # and/or wap to start the bearer. Then start boxes
  34. # as needed.
  35. # startsms=`egrep -se '^[ \t]*group *= *smsbox' $CONF`
  36. # startwap=`egrep -se '^[ \t]*group *= *wapbox' $CONF`
  37.  
  38. startsms=`egrep -hse '^[ \t]*group *= *smsbox' $CONF ${CONFDIR}/*`
  39. startwap=`egrep -hse '^[ \t]*group *= *wapbox' $CONF ${CONFDIR}/*`
  40.  
  41. if [ -n "$startsms$startwap" ]; then
  42. echo -n "Starting Mobile Gateway Service 1 ($VERSION): "
  43. daemon /usr/local/sbin/bearerbox ${OPTIONS}bearerbox.pid -- $CONF
  44. RETVAL1=$?
  45. echo
  46. sleep 15
  47. else
  48. exit 0
  49. fi
  50.  
  51. if [ -n "$startsms" ]; then
  52. echo -n "Starting Mobile Gateway Service 2 ($VERSION): "
  53. daemon /usr/local/sbin/smsbox ${OPTIONS}smsbox.pid -- $CONF
  54. RETVAL2=$?
  55. echo
  56. fi
  57.  
  58. if [ -n "$startwap" ]; then
  59. echo -n "Starting Mobile Gateway Wap service ($VERSION): "
  60. daemon /usr/local/sbin/wapbox ${OPTIONS}wapbox.pid -- $CONF
  61. RETVAL3=$?
  62. echo
  63. fi
  64.  
  65. let RETVAL=$REVAL1+$RETVAL2+$RETVAL3
  66. if [ $RETVAL -eq 0 ]; then
  67. sleep 2
  68. touch /var/lock/subsys/gateway
  69. cat /var/run/kannel/*.pid > /var/run/kannel.pid
  70. fi
  71. return $RETVAL
  72. }
  73.  
  74. stop() {
  75. echo -n "Shutting down Mobile Gateway $VERSION: "
  76. killproc kannel
  77. RETVAL=$?
  78. echo
  79.  
  80. if [ $RETVAL -eq 0 ]; then
  81. sleep 2
  82. rm -f /var/lock/subsys/gateway
  83. rm /var/run/kannel/*.pid
  84. fi
  85. return $RETVAL
  86. }
  87.  
  88. # See how we were called.
  89. case "$1" in
  90. start)
  91. # Start daemons.
  92. start
  93. ;;
  94.  
  95. stop)
  96. # Stop daemons
  97. stop
  98. ;;
  99.  
  100. restart)
  101. # Restart daemons
  102. stop
  103. sleep 1
  104. start
  105. ;;
  106.  
  107. status)
  108. status bearerbox
  109. status smsbox
  110. status wapbox
  111. exit $?
  112. ;;
  113.  
  114. *)
  115. echo "Usage: named {start|stop|status|restart}"
  116. RETVAL=1
  117. esac
  118.  
  119. exit $RETVAL
Add Comment
Please, Sign In to add comment