summaryrefslogtreecommitdiff
path: root/pcr/puppet/puppet
blob: 4126be850583b784a8fd842057b6edd1c837409d (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
#!/bin/bash
DAEMON=$(type -p puppetd)

. /etc/rc.conf
. /etc/rc.d/functions
[ -f /etc/conf.d/puppet ] && . /etc/conf.d/puppet

PID=$(pidof -xo %PPID $DAEMON)
case "$1" in
  start)
    stat_busy "Starting Puppet Daemon"
    if [ -z "$PID" ]; then 
      [ -f /var/run/puppet.pid ] && rm -f /var/run/puppet.pid
      $DAEMON $PUPPETD_ARGS
    fi
    if [ ! -z "$PID" -o $? -gt 0 ]; then
      stat_fail
    else
      PID=$(pidof -xo %PPID $DAEMON)
      echo $PID > /var/run/puppet.pid
      add_daemon puppet
      stat_done
    fi
    ;;
  stop)
    stat_busy "Stopping Puppet Daemon"
    [ ! -z "$PID" ]  && kill $PID &> /dev/null
    if [ $? -gt 0 ]; then
      stat_fail
    else
      rm_daemon puppet
      rm -f /var/run/puppet.pid
      stat_done
    fi
    ;;
  restart)
    $0 stop
    if [ ! -z $PID ]; then
      while ps -p $PID > /dev/null; do sleep 1; done
    fi
    $0 start
    ;;
  *)
    echo "usage: $0 {start|stop|restart}"  
esac