aboutsummaryrefslogtreecommitdiff
path: root/system/salt/rc.salt-minion.new
blob: f699a12f25bdf0de16c86b5f69861e237418962b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/sh
# Start/stop/restart salt minion

PIDFILE=/var/run/salt-minion.pid
LOGFILE=/var/log/salt/minion
# LOGLEVEL: One of: all, garbage, trace, debug, info, warning, error, quiet
LOGLEVEL=warning

# Start salt-minion:
salt_minion_start() {
  if [ -x /usr/bin/salt-minion ]; then
    echo "Starting salt-minion daemon:  /usr/bin/salt-minion"
    /usr/bin/salt-minion -d \
      --pid-file=$PIDFILE \
      --log-file=$LOGFILE \
      --log-file-level=$LOGLEVEL
  fi
}

# Stop salt-minion:
salt_minion_stop() {
  if [ -s $PIDFILE ] ; then
    kill $(cat $PIDFILE)
  else
    killall salt-minion
  fi
  rm -f $PIDFILE
}

# Restart salt-minion:
salt_minion_restart() {
  salt_minion_stop
  sleep 1
  salt_minion_start
}

case "$1" in
'start')
  salt_minion_start
  ;;
'stop')
  salt_minion_stop
  ;;
'restart')
  salt_minion_restart
  ;;
*)
  echo "usage $0 start|stop|restart"
esac