Advertisement
Guest User

memcachedrep

a guest
Jan 16th, 2014
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.98 KB | None | 0 0
  1. #! /bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides: memcached
  4. # Required-Start: $syslog
  5. # Required-Stop: $syslog
  6. # Should-Start: $local_fs
  7. # Should-Stop: $local_fs
  8. # Default-Start: 2 3 4 5
  9. # Default-Stop: 0 1 6
  10. # Short-Description: memcached - Memory caching daemon replicated
  11. # Description: memcached - Memory caching daemon replicated
  12. ### END INIT INFO
  13. # Author: Marcus Spiegel <marcus.spiegel@gmail.com>
  14. #
  15. # Please remove the "Author" lines above and replace them
  16. # with your own name if you copy and modify this script.
  17. # Do NOT "set -e"
  18. # PATH should only include /usr/* if it runs after the mountnfs.sh script
  19. PATH=/sbin:/usr/sbin:/bin:/usr/bin
  20. DESC="memcachedrep"
  21. NAME=memcached
  22. DAEMON=/usr/local/bin/$NAME
  23. DAEMON_ARGS="--options args"
  24. PIDFILE=/var/run/memcachedrep.pid
  25. SCRIPTNAME=/etc/init.d/$DESC
  26. VERBOSE="yes"
  27. # Exit if the package is not installed
  28. [ -x "$DAEMON" ] || exit 0
  29. # Read configuration variable file if it is present
  30. [ -r /etc/default/$DESC ] && . /etc/default/$DESC
  31. # Load the VERBOSE setting and other rcS variables
  32. . /lib/init/vars.sh
  33. # Define LSB log_* functions.
  34. # Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
  35. . /lib/lsb/init-functions
  36. #
  37. # Function that starts the daemon/service
  38. #
  39. do_start()
  40. {
  41. # Return
  42. # 0 if daemon has been started
  43. # 1 if daemon was already running
  44. # 2 if daemon could not be started
  45. start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
  46. || return 1
  47. start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
  48. $DAEMON_ARGS \
  49. || return 2
  50. # Add code here, if necessary, that waits for the process to be ready
  51. # to handle requests from services started subsequently which depend
  52. # on this one. As a last resort, sleep for some time.
  53. }
  54. #
  55. # Function that stops the daemon/service
  56. #
  57. do_stop()
  58. {
  59. # Return
  60. # 0 if daemon has been stopped
  61. # 1 if daemon was already stopped
  62. # 2 if daemon could not be stopped
  63. # other if a failure occurred
  64. start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
  65. RETVAL="$?"
  66. [ "$RETVAL" = 2 ] && return 2
  67. # Wait for children to finish too if this is a daemon that forks
  68. # and if the daemon is only ever run from this initscript.
  69. # If the above conditions are not satisfied then add some other code
  70. # that waits for the process to drop all resources that could be
  71. # needed by services started subsequently. A last resort is to
  72. # sleep for some time.
  73. start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
  74. [ "$?" = 2 ] && return 2
  75. # Many daemons don't delete their pidfiles when they exit.
  76. rm -f $PIDFILE
  77. return "$RETVAL"
  78. }
  79. #
  80. # Function that sends a SIGHUP to the daemon/service
  81. #
  82. do_reload() {
  83. #
  84. # If the daemon can reload its configuration without
  85. # restarting (for example, when it is sent a SIGHUP),
  86. # then implement that here.
  87. #
  88. start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
  89. return 0
  90. }
  91. case "$1" in
  92. start)
  93. [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
  94. do_start
  95. case "$?" in
  96. 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
  97. 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
  98. esac
  99. ;;
  100. stop)
  101. [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
  102. do_stop
  103. case "$?" in
  104. 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
  105. 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
  106. esac
  107. ;;
  108. #reload|force-reload)
  109. #
  110. # If do_reload() is not implemented then leave this commented out
  111. # and leave 'force-reload' as an alias for 'restart'.
  112. #
  113. #log_daemon_msg "Reloading $DESC" "$NAME"
  114. #do_reload
  115. #log_end_msg $?
  116. #;;
  117. restart|force-reload)
  118. #
  119. # If the "reload" option is implemented then remove the
  120. # 'force-reload' alias
  121. #
  122. log_daemon_msg "Restarting $DESC" "$NAME"
  123. do_stop
  124. case "$?" in
  125. 0|1)
  126. do_start
  127. case "$?" in
  128. 0) log_end_msg 0 ;;
  129. 1) log_end_msg 1 ;; # Old process is still running
  130. *) log_end_msg 1 ;; # Failed to start
  131. esac
  132. ;;
  133. *)
  134. # Failed to stop
  135. log_end_msg 1
  136. ;;
  137. esac
  138. ;;
  139. *)
  140. #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
  141. echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
  142. exit 3
  143. ;;
  144. esac
  145. :
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement