summaryrefslogtreecommitdiff
path: root/templates/check-puppetd.sh.erb
blob: 639a1d519333fde47e29dc5d640efb0b22a65541 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/bash
#
# check if puppet is running
#

PID="/var/run/puppet/<%= puppet_agent_name %>.pid"
INIT="/etc/init.d/puppet"

function puppet_start {
  sleep `echo $RANDOM/2000*60 | bc`
  $INIT start
}

if [ ! -f "$PID" ]; then
  puppet_start
else
  running="$(ps $(cat $PID) &> /dev/null)"
  if [ "$?" != "0" ]; then
    puppet_start
  fi
fi