~bkerensa/ubuntu/raring/puppet/new-upstream-release

« back to all changes in this revision

Viewing changes to conf/suse/server.init

  • Committer: Benjamin Kerensa
  • Date: 2012-11-21 23:50:52 UTC
  • mfrom: (1.1.30)
  • Revision ID: bkerensa@ubuntu.com-20121121235052-ah7nzabp77sh69gb
New Upstream Release

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/bash
2
 
# puppetmaster  This shell script enables the puppetmaster server.
3
 
#
4
 
# Author:       Duane Griffin <d.griffin@psenterprise.com>
5
 
#               Martin Vuk <martin.vuk@fri.uni-lj.si> (SuSE support)
6
 
#
7
 
# chkconfig: - 65 45
8
 
#
9
 
# description: Server for the puppet system management tool.
10
 
# processname: puppetmaster
11
 
 
12
 
### BEGIN INIT INFO
13
 
# Provides: puppetmaster
14
 
# Required-Start: $local_fs $remote_fs $network $syslog
15
 
# Should-Start: puppetmaster
16
 
# Required-Stop: $local_fs $remote_fs $network $syslog
17
 
# Should-Stop: puppetmaster
18
 
# Default-Start: 3 4 5
19
 
# Default-Stop: 0 1 2 6
20
 
# Short-Description: puppetmaster
21
 
# Description: Server for the puppet system management tool.
22
 
### END INIT INFO
23
 
 
24
 
# Shell functions sourced from /etc/rc.status:
25
 
#      rc_check         check and set local and overall rc status
26
 
#      rc_status        check and set local and overall rc status
27
 
#      rc_status -v     ditto but be verbose in local rc status
28
 
#      rc_status -v -r  ditto and clear the local rc status
29
 
#      rc_failed        set local and overall rc status to failed
30
 
#      rc_reset         clear local rc status (overall remains)
31
 
#      rc_exit          exit appropriate to overall rc status
32
 
 
33
 
lockfile=/var/lock/subsys/puppetmaster
34
 
pidfile=/var/run/puppet/puppetmasterd.pid
35
 
 
36
 
# Source function library.
37
 
[ -f /etc/rc.status ] && . /etc/rc.status
38
 
 
39
 
if [ -f /etc/sysconfig/puppetmaster ]; then
40
 
    . /etc/sysconfig/puppetmaster
41
 
fi
42
 
 
43
 
PUPPETMASTER_OPTS=""
44
 
[ -n "$PUPPETMASTER_MANIFEST" ] && PUPPETMASTER_OPTS="--manifest=${PUPPETMASTER_MANIFEST}"
45
 
if [ -n "$PUPPETMASTER_PORTS" ] && [ ${#PUPPETMASTER_PORTS[@]} -gt 1 ]; then
46
 
    PUPPETMASTER_OPTS="$PUPPETMASTER_OPTS --servertype=mongrel"
47
 
elif [ -n "$PUPPETMASTER_PORTS" ] && [ ${#PUPPETMASTER_PORTS[@]} -eq 1 ]; then
48
 
    PUPPETMASTER_OPTS="${PUPPETMASTER_OPTS} --masterport=${PUPPETMASTER_PORTS[0]}"
49
 
fi
50
 
[ -n "$PUPPETMASTER_LOG" ] && PUPPETMASTER_OPTS="${PUPPETMASTER_OPTS} --logdest ${PUPPETMASTER_LOG}"
51
 
PUPPETMASTER_OPTS="${PUPPETMASTER_OPTS} \
52
 
    ${PUPPETMASTER_EXTRA_OPTS}"
53
 
 
54
 
prog=puppetmasterd
55
 
PUPPETMASTER=/usr/sbin/$prog
56
 
 
57
 
start() {
58
 
    echo -n $"Starting puppetmaster: "
59
 
 
60
 
    echo
61
 
    return $RETVAL
62
 
}
63
 
# First reset status of this service
64
 
rc_reset
65
 
 
66
 
# Return values acc. to LSB for all commands but status:
67
 
# 0 - success
68
 
# 1 - misc error
69
 
# 2 - invalid or excess args
70
 
# 3 - unimplemented feature (e.g. reload)
71
 
# 4 - insufficient privilege
72
 
# 5 - program not installed
73
 
# 6 - program not configured
74
 
#
75
 
# Note that starting an already running service, stopping
76
 
# or restarting a not-running service as well as the restart
77
 
# with force-reload (in case signalling is not supported) are
78
 
# considered a success.
79
 
 
80
 
case "$1" in
81
 
    start)
82
 
        echo -n "Starting puppetmaster services."
83
 
        ## Start daemon with startproc(8). If this fails
84
 
        ## the echo return value is set appropriate.
85
 
 
86
 
        # startproc should return 0, even if service is
87
 
        # already running to match LSB spec.
88
 
        # Confirm the manifest exists
89
 
        if [ -r $PUPPETMASTER_MANIFEST ]; then
90
 
            startproc $PUPPETMASTER $PUPPETMASTER_OPTS && touch "$lockfile"
91
 
        else
92
 
            rc_failed
93
 
            echo "Manifest does not exist: $PUPPETMASTER_MANIFEST"
94
 
        fi
95
 
        # Remember status and be verbose
96
 
        rc_status -v
97
 
        ;;
98
 
    stop)
99
 
        echo -n "Shutting down puppetmaster:"
100
 
        ## Stop daemon with killproc(8) and if this fails
101
 
        ## set echo the echo return value.
102
 
 
103
 
        killproc -QUIT $PUPPETMASTER && rm -f ${lockfile} ${pidfile}
104
 
 
105
 
        # Remember status and be verbose
106
 
        rc_status -v
107
 
        ;;
108
 
    try-restart)
109
 
        ## Stop the service and if this succeeds (i.e. the
110
 
        ## service was running before), start it again.
111
 
        $0 status >/dev/null &&  $0 restart
112
 
 
113
 
        # Remember status and be quiet
114
 
        rc_status
115
 
        ;;
116
 
    restart)
117
 
        ## Stop the service and regardless of whether it was
118
 
        ## running or not, start it again.
119
 
        $0 stop
120
 
        $0 start
121
 
 
122
 
        # Remember status and be quiet
123
 
        rc_status
124
 
        ;;
125
 
    force-reload)
126
 
        ## Signal the daemon to reload its config. Most daemons
127
 
        ## do this on signal 1 (SIGHUP).
128
 
        ## If it does not support it, restart.
129
 
 
130
 
        echo -n "Reload service puppet"
131
 
        ## if it supports it:
132
 
        killproc -HUP $PUPPETMASTER
133
 
        rc_status -v
134
 
        ;;
135
 
    reload)
136
 
        ## Like force-reload, but if daemon does not support
137
 
        ## signalling, do nothing (!)
138
 
 
139
 
        # If it supports signalling:
140
 
        echo -n "Reload puppet services."
141
 
        killproc -HUP  $PUPPETMASTER
142
 
        rc_status -v
143
 
        ;;
144
 
    status)
145
 
        echo -n "Checking for service puppetmaster: "
146
 
        ## Check status with checkproc(8), if process is running
147
 
        ## checkproc will return with exit status 0.
148
 
 
149
 
        # Status has a slightly different for the status command:
150
 
        # 0 - service running
151
 
        # 1 - service dead, but /var/run/  pid  file exists
152
 
        # 2 - service dead, but /var/lock/ lock file exists
153
 
        # 3 - service not running
154
 
 
155
 
        # NOTE: checkproc returns LSB compliant status values.
156
 
        checkproc $PUPPETMASTER
157
 
        rc_status -v
158
 
        ;;
159
 
    *)
160
 
        echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload}"
161
 
        exit 1
162
 
esac
163
 
rc_exit