1
0

salt-syndic 3.3 KB

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