salt-syndic 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. #!/bin/sh
  2. #
  3. # Salt syndic
  4. ###################################
  5. # LSB header
  6. ### BEGIN INIT INFO
  7. # Provides: salt-syndic
  8. # Required-Start: $all
  9. # Required-Stop:
  10. # Default-Start: 2 3 4 5
  11. # Default-Stop: 0 1 6
  12. # Short-Description: Salt syndic master-minion passthrough daemon
  13. # Description: This is a the Salt syndic daemon that enables Salt master-minion
  14. # remote control passthrough.
  15. ### END INIT INFO
  16. # chkconfig header
  17. # chkconfig: - 99 99
  18. # description: This is a the Salt syndic daemon that enables Salt master-minion remote control passthrough.
  19. #
  20. # processname: /usr/bin/salt-syndic
  21. DEBIAN_VERSION=/etc/debian_version
  22. SUSE_RELEASE=/etc/SuSE-release
  23. # Source function library.
  24. if [ -f $DEBIAN_VERSION ]; then
  25. break
  26. elif [ -f $SUSE_RELEASE -a -r /etc/rc.status ]; then
  27. . /etc/rc.status
  28. else
  29. . /etc/rc.d/init.d/functions
  30. fi
  31. # Default values (can be overridden below)
  32. SALTSYNDIC=/usr/bin/salt-syndic
  33. PYTHON=/usr/bin/python
  34. SYNDIC_ARGS=""
  35. if [ -f /etc/default/salt ]; then
  36. . /etc/default/salt
  37. fi
  38. SERVICE=salt-syndic
  39. PROCESS=salt-syndic
  40. RETVAL=0
  41. start() {
  42. echo -n $"Starting salt-syndic daemon: "
  43. if [ -f $SUSE_RELEASE ]; then
  44. startproc -f -p /var/run/$SERVICE.pid $SALTSYNDIC -d $SYNDIC_ARGS
  45. rc_status -v
  46. elif [ -e $DEBIAN_VERSION ]; then
  47. if [ -f $LOCKFILE ]; then
  48. echo -n "already started, lock file found"
  49. RETVAL=1
  50. elif $PYTHON $SALTSYNDIC -d $SYNDIC_ARGS >& /dev/null; then
  51. echo -n "OK"
  52. RETVAL=0
  53. fi
  54. else
  55. daemon --check $SERVICE $SALTSYNDIC -d $SYNDIC_ARGS
  56. RETVAL=$?
  57. [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$SERVICE
  58. echo
  59. return $RETVAL
  60. fi
  61. RETVAL=$?
  62. echo
  63. return $RETVAL
  64. }
  65. stop() {
  66. echo -n $"Stopping salt-syndic daemon: "
  67. if [ -f $SUSE_RELEASE ]; then
  68. killproc -TERM $SALTSYNDIC
  69. rc_status -v
  70. elif [ -f $DEBIAN_VERSION ]; then
  71. # Added this since Debian's start-stop-daemon doesn't support spawned processes
  72. if ps -ef | grep "$PYTHON $SALTSYNDIC" | grep -v grep | awk '{print $2}' | xargs kill &> /dev/null; then
  73. echo -n "OK"
  74. RETVAL=0
  75. else
  76. echo -n "Daemon is not started"
  77. RETVAL=1
  78. fi
  79. else
  80. killproc $PROCESS
  81. RETVAL=$?
  82. echo
  83. [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$SERVICE
  84. return $RETVAL
  85. fi
  86. RETVAL=$?
  87. echo
  88. }
  89. restart() {
  90. stop
  91. start
  92. }
  93. # See how we were called.
  94. case "$1" in
  95. start|stop|restart)
  96. $1
  97. ;;
  98. status)
  99. if [ -f $SUSE_RELEASE ]; then
  100. echo -n "Checking for service salt-syndic "
  101. checkproc $SALTSYNDIC
  102. rc_status -v
  103. elif [ -f $DEBIAN_VERSION ]; then
  104. if [ -f $LOCKFILE ]; then
  105. RETVAL=0
  106. echo "salt-syndic is running."
  107. else
  108. RETVAL=1
  109. echo "salt-syndic is stopped."
  110. fi
  111. else
  112. status $PROCESS
  113. RETVAL=$?
  114. fi
  115. ;;
  116. *)
  117. echo $"Usage: $0 {start|stop|status|restart}"
  118. exit 1
  119. ;;
  120. esac
  121. exit $RETVAL