Advertisement
Guest User

Untitled

a guest
Jul 14th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.87 KB | None | 0 0
  1. #!/bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides: salt-master
  4. # Required-Start: $remote_fs $network
  5. # Required-Stop: $remote_fs $network
  6. # Default-Start: 2 3 4 5
  7. # Default-Stop: 0 1 6
  8. # Short-Description: salt master control daemon
  9. # Description: This is a daemon that controls the salt minions
  10. ### END INIT INFO
  11.  
  12. # Author: Michael Prokop <mika@debian.org>
  13.  
  14. PATH=/sbin:/usr/sbin:/bin:/usr/bin
  15. DESC="salt master control daemon"
  16. NAME=salt-master
  17. DAEMON=/usr/bin/salt-master
  18. DAEMON_ARGS="-d"
  19. PIDFILE=/var/run/$NAME.pid
  20. SCRIPTNAME=/etc/init.d/$NAME
  21.  
  22. # Exit if the package is not installed
  23. [ -x "$DAEMON" ] || exit 0
  24.  
  25. # Read configuration variable file if it is present
  26. [ -r /etc/default/$NAME ] && . /etc/default/$NAME
  27.  
  28. . /lib/lsb/init-functions
  29.  
  30. do_start() {
  31. # Return
  32. # 0 if daemon has been started
  33. # 1 if daemon was already running
  34. # 2 if daemon could not be started
  35. pid=$(pidofproc -p $PIDFILE $DAEMON)
  36. if [ -n "$pid" ] ; then
  37. return 1
  38. fi
  39.  
  40. start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
  41. $DAEMON_ARGS \
  42. || return 2
  43. }
  44.  
  45. do_stop() {
  46. # Return
  47. # 0 if daemon has been stopped
  48. # 1 if daemon was already stopped
  49. # 2 if daemon could not be stopped
  50. # other if a failure occurred
  51. pids=$(pidof -x $DAEMON)
  52. if [ $? -eq 0 ] ; then
  53. echo $pids | xargs kill 2&1> /dev/null
  54. RETVAL=0
  55. else
  56. RETVAL=1
  57. fi
  58.  
  59. [ "$RETVAL" = 2 ] && return 2
  60. rm -f $PIDFILE
  61. return "$RETVAL"
  62. }
  63.  
  64. case "$1" in
  65. start)
  66. [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
  67. do_start
  68. case "$?" in
  69. 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
  70. 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
  71. esac
  72. ;;
  73. stop)
  74. [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
  75. do_stop
  76. case "$?" in
  77. 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
  78. 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
  79. esac
  80. ;;
  81. status)
  82. status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
  83. ;;
  84. #reload)
  85. # not implemented
  86. #;;
  87. restart|force-reload)
  88. log_daemon_msg "Restarting $DESC" "$NAME"
  89. do_stop
  90. case "$?" in
  91. 0|1)
  92. do_start
  93. case "$?" in
  94. 0) log_end_msg 0 ;;
  95. 1) log_end_msg 1 ;; # Old process is still running
  96. *) log_end_msg 1 ;; # Failed to start
  97. esac
  98. ;;
  99. *)
  100. # Failed to stop
  101. log_end_msg 1
  102. ;;
  103. esac
  104. ;;
  105. *)
  106. echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
  107. exit 3
  108. ;;
  109. esac
  110.  
  111. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement