corosync-qdevice.in 3.1 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. [ -f @INITCONFIGDIR@/$prog ] && . @INITCONFIGDIR@/$prog
  43. # rpm based distros
  44. if [ -d @SYSCONFDIR@/sysconfig ]; then
  45. [ -f @INITDDIR@/functions ] && . @INITDDIR@/functions
  46. [ -z "$LOCK_FILE" ] && LOCK_FILE="@LOCALSTATEDIR@/lock/subsys/$prog"
  47. fi
  48. # deb based distros
  49. if [ -d @SYSCONFDIR@/default ]; then
  50. [ -z "$LOCK_FILE" ] && LOCK_FILE="@LOCALSTATEDIR@/lock/$prog"
  51. fi
  52. # The version of __pids_pidof in /etc/init.d/functions calls pidof with -x
  53. # This means it matches scripts, including this one.
  54. # Redefine it here so that status (from the same file) works.
  55. # Otherwise simultaneous calls to stop() will loop forever
  56. __pids_pidof() {
  57. pidof -c -o $$ -o $PPID -o %PPID "$1" || \
  58. pidof -c -o $$ -o $PPID -o %PPID "${1##*/}"
  59. }
  60. cluster_disabled_at_boot()
  61. {
  62. if grep -q nocluster /proc/cmdline && \
  63. [ "$(tty)" = "/dev/console" ]; then
  64. echo -e "not configured to run at boot"
  65. failure
  66. return 1
  67. fi
  68. return 0
  69. }
  70. start()
  71. {
  72. echo -n "Starting $desc ($prog): "
  73. ! cluster_disabled_at_boot && return
  74. # most recent distributions use tmpfs for @LOCALSTATEDIR@/run
  75. # to avoid to clean it up on every boot.
  76. # they also assume that init scripts will create
  77. # required subdirectories for proper operations
  78. if [ ! -d "@LOCALSTATEDIR@/run/corosync-qdevice" ];then
  79. mkdir -p "@LOCALSTATEDIR@/run/corosync-qdevice"
  80. chmod 0770 "@LOCALSTATEDIR@/run/corosync-qdevice"
  81. fi
  82. if status $prog > /dev/null 2>&1; then
  83. success
  84. else
  85. $prog $COROSYNC_QDEVICE_OPTIONS > /dev/null 2>&1
  86. if [ "$?" != 0 ]; then
  87. failure
  88. rtrn=1
  89. else
  90. touch $LOCK_FILE
  91. success
  92. fi
  93. fi
  94. echo
  95. }
  96. stop()
  97. {
  98. ! status $prog > /dev/null 2>&1 && return
  99. echo -n "Signaling $desc ($prog) to terminate: "
  100. kill -TERM $(pidof $prog) > /dev/null 2>&1
  101. success
  102. echo
  103. echo -n "Waiting for $prog services to unload:"
  104. while status $prog > /dev/null 2>&1; do
  105. sleep 1
  106. echo -n "."
  107. done
  108. rm -f $LOCK_FILE
  109. success
  110. echo
  111. }
  112. restart()
  113. {
  114. stop
  115. start
  116. }
  117. rtrn=0
  118. case "$1" in
  119. start)
  120. start
  121. ;;
  122. restart|reload|force-reload)
  123. restart
  124. ;;
  125. condrestart|try-restart)
  126. if status $prog > /dev/null 2>&1; then
  127. restart
  128. fi
  129. ;;
  130. status)
  131. status $prog
  132. rtrn=$?
  133. ;;
  134. stop)
  135. stop
  136. ;;
  137. *)
  138. echo "usage: $0 {start|stop|restart|reload|force-reload|condrestart|try-restart|status}"
  139. rtrn=2
  140. ;;
  141. esac
  142. exit $rtrn