corosync-qdevice.in 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. #!@BASHPATH@
  2. # Authors:
  3. # Jan Friesse <jfriesse@redhat.com>
  4. #
  5. # License: Revised BSD
  6. # chkconfig: - 20 80
  7. # description: Corosync Qdevice daemon
  8. # processname: corosync-qdevice
  9. #
  10. ### BEGIN INIT INFO
  11. # Provides: corosync-qdevice
  12. # Required-Start: corosync
  13. # Required-Stop: corosync
  14. # Default-Start:
  15. # Default-Stop:
  16. # Short-Description: Starts and stops Corosync Qdevice daemon.
  17. # Description: Starts and stops Corosync Qdevice daemon.
  18. ### END INIT INFO
  19. desc="Corosync Qdevice daemon"
  20. prog="corosync-qdevice"
  21. # set secure PATH
  22. PATH="/sbin:/bin:/usr/sbin:/usr/bin:@SBINDIR@"
  23. success()
  24. {
  25. echo -ne "[ OK ]\r"
  26. }
  27. failure()
  28. {
  29. echo -ne "[FAILED]\r"
  30. }
  31. status()
  32. {
  33. pid=$(pidof $1 2>/dev/null)
  34. res=$?
  35. if [ $res -ne 0 ]; then
  36. echo "$1 is stopped"
  37. else
  38. echo "$1 (pid $pid) is running..."
  39. fi
  40. return $res
  41. }
  42. # rpm based distros
  43. if [ -d @SYSCONFDIR@/sysconfig ]; then
  44. [ -f @INITDDIR@/functions ] && . @INITDDIR@/functions
  45. [ -f @SYSCONFDIR@/sysconfig/$prog ] && . @SYSCONFDIR@/sysconfig/$prog
  46. [ -z "$LOCK_FILE" ] && LOCK_FILE="@LOCALSTATEDIR@/lock/subsys/$prog"
  47. fi
  48. # deb based distros
  49. if [ -d @SYSCONFDIR@/default ]; then
  50. [ -f @SYSCONFDIR@/default/$prog ] && . @SYSCONFDIR@/default/$prog
  51. [ -z "$LOCK_FILE" ] && LOCK_FILE="@LOCALSTATEDIR@/lock/$prog"
  52. fi
  53. # The version of __pids_pidof in /etc/init.d/functions calls pidof with -x
  54. # This means it matches scripts, including this one.
  55. # Redefine it here so that status (from the same file) works.
  56. # Otherwise simultaneous calls to stop() will loop forever
  57. __pids_pidof() {
  58. pidof -c -o $$ -o $PPID -o %PPID "$1" || \
  59. pidof -c -o $$ -o $PPID -o %PPID "${1##*/}"
  60. }
  61. cluster_disabled_at_boot()
  62. {
  63. if grep -q nocluster /proc/cmdline && \
  64. [ "$(tty)" = "/dev/console" ]; then
  65. echo -e "not configured to run at boot"
  66. failure
  67. return 1
  68. fi
  69. return 0
  70. }
  71. start()
  72. {
  73. echo -n "Starting $desc ($prog): "
  74. ! cluster_disabled_at_boot && return
  75. # most recent distributions use tmpfs for @LOCALSTATEDIR@/run
  76. # to avoid to clean it up on every boot.
  77. # they also assume that init scripts will create
  78. # required subdirectories for proper operations
  79. if [ ! -d "@LOCALSTATEDIR@/run/corosync-qdevice" ];then
  80. mkdir -p "@LOCALSTATEDIR@/run/corosync-qdevice"
  81. chmod 0770 "@LOCALSTATEDIR@/run/corosync-qdevice"
  82. fi
  83. if status $prog > /dev/null 2>&1; then
  84. success
  85. else
  86. $prog $COROSYNC_QDEVICE_OPTIONS > /dev/null 2>&1
  87. if [ "$?" != 0 ]; then
  88. failure
  89. rtrn=1
  90. else
  91. touch $LOCK_FILE
  92. success
  93. fi
  94. fi
  95. echo
  96. }
  97. stop()
  98. {
  99. ! status $prog > /dev/null 2>&1 && return
  100. echo -n "Signaling $desc ($prog) to terminate: "
  101. kill -TERM $(pidof $prog) > /dev/null 2>&1
  102. success
  103. echo
  104. echo -n "Waiting for $prog services to unload:"
  105. while status $prog > /dev/null 2>&1; do
  106. sleep 1
  107. echo -n "."
  108. done
  109. rm -f $LOCK_FILE
  110. success
  111. echo
  112. }
  113. restart()
  114. {
  115. stop
  116. start
  117. }
  118. rtrn=0
  119. case "$1" in
  120. start)
  121. start
  122. ;;
  123. restart|reload|force-reload)
  124. restart
  125. ;;
  126. condrestart|try-restart)
  127. if status $prog > /dev/null 2>&1; then
  128. restart
  129. fi
  130. ;;
  131. status)
  132. status $prog
  133. rtrn=$?
  134. ;;
  135. stop)
  136. stop
  137. ;;
  138. *)
  139. echo "usage: $0 {start|stop|restart|reload|force-reload|condrestart|try-restart|status}"
  140. rtrn=2
  141. ;;
  142. esac
  143. exit $rtrn