summaryrefslogtreecommitdiff
path: root/templates/check-puppetd.sh.erb
blob: 80ea3f63b78e9c300967214cd5f515893a59058e (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
#!/bin/bash
#
# check if puppet is running
#

PATH="$PATH:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"
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 [ "$1" == "restart" ]; then
  puppet_restart
elif [ ! -f "$PID" ]; then
  puppet_start
else
  running="$(ps $(cat $PID) &> /dev/null)"
  if [ "$?" != "0" ]; then
    puppet_start
  fi
fi