daily pastebin goal
25%
SHARE
TWEET

salt-minion

a guest Jul 14th, 2016 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides:          salt-minion
  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 minion 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 minion control daemon"
  16. NAME=salt-minion
  17. DAEMON=/usr/bin/salt-minion
  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 --background --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.     start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
  52.     RETVAL="$?"
  53.     [ "$RETVAL" = 2 ] && return 2
  54.     rm -f $PIDFILE
  55.     return "$RETVAL"
  56. }
  57.  
  58. case "$1" in
  59.     start)
  60.         [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
  61.         do_start
  62.         case "$?" in
  63.             0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
  64.               2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
  65.         esac
  66.         ;;
  67.     stop)
  68.         [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
  69.         do_stop
  70.         case "$?" in
  71.             0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
  72.               2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
  73.         esac
  74.         ;;
  75.     status)
  76.         status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
  77.         ;;
  78.     #reload)
  79.         # not implemented
  80.         #;;
  81.     restart|force-reload)
  82.         log_daemon_msg "Restarting $DESC" "$NAME"
  83.         do_stop
  84.         case "$?" in
  85.           0|1)
  86.               do_start
  87.               case "$?" in
  88.                   0) log_end_msg 0 ;;
  89.                   1) log_end_msg 1 ;; # Old process is still running
  90.                   *) log_end_msg 1 ;; # Failed to start
  91.               esac
  92.               ;;
  93.           *)
  94.               # Failed to stop
  95.               log_end_msg 1
  96.               ;;
  97.         esac
  98.         ;;
  99.     *)
  100.         echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
  101.         exit 3
  102.         ;;
  103. esac
  104.  
  105. exit 0
RAW Paste Data
Top