This file is indexed.

/etc/init.d/pmwebd is in pcp 3.8.12ubuntu1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  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
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
#! /bin/sh
#
# Copyright (c) 2013 Red Hat.
# Copyright (c) 2005 Silicon Graphics, Inc.  All Rights Reserved.
# 
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
# 
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# for more details.
# 
# Start or Stop the Performance Co-Pilot (PCP) web daemon for pmcd
#
# The following is for chkconfig on RedHat based systems
# chkconfig: 2345 95 05
# description: pmwebd is the web frontend for the Performance Co-Pilot (PCP)
#
# The following is for insserv(1) based systems,
# e.g. SuSE, where chkconfig is a perl script.
### BEGIN INIT INFO
# Provides:       pmwebd
# Required-Start: $remote_fs
# Should-Start: $local_fs $network $syslog $time $pmcd
# Required-Stop: $remote_fs
# Should-Stop:  $local_fs $network $syslog $pmcd
# Default-Start:  2 3 4 5
# Default-Stop:   0 1 6
# Short-Description: Control pmwebd (the web frontend for PCP)
# Description:       Configure and control pmwebd (the web frontend daemon for the Performance Co-Pilot)
### END INIT INFO

. $PCP_DIR/etc/pcp.env
. $PCP_SHARE_DIR/lib/rc-proc.sh

PMWEBD=$PCP_BINADM_DIR/pmwebd
PMWEBDOPTS=$PCP_PMWEBDOPTIONS_PATH
RUNDIR=$PCP_LOG_DIR/pmwebd
pmprog=$PCP_RC_DIR/pmwebd
prog=$PCP_RC_DIR/`basename $0`

tmp=`mktemp -d /var/tmp/pcp.XXXXXXXXX` || exit 1
status=1
trap "rm -rf $tmp; exit \$status" 0 1 2 3 15

if [ $pmprog = $prog ]
then
    VERBOSE_CTL=on
else
    VERBOSE_CTL=off
fi

case "$PCP_PLATFORM"
in
    mingw)
	# nothing we can usefully do here, skip the test
	#
	;;

    *)
	# standard Unix/Linux style test
	#
	ID=id
	test -f /usr/xpg4/bin/id && ID=/usr/xpg4/bin/id

	IAM=`$ID -u 2>/dev/null`
	if [ -z "$IAM" ]
	then
	    # do it the hardway
	    #
	    IAM=`$ID | sed -e 's/.*uid=//' -e 's/(.*//'`
	fi
	;;
esac

_shutdown()
{
    # Is pmwebd running?
    #
    _get_pids_by_name pmwebd >$tmp/tmp
    if [ ! -s $tmp/tmp ]
    then
	[ "$1" = verbose ] && echo "$pmprog: pmwebd not running"
	return 0
    fi

    # Send pmwebd a SIGTERM, which is noted as a pending shutdown.
    # When finished the currently active request, pmwebd will close any
    # connections and then exit.
    # Wait for pmwebd to terminate.
    #
    pmsignal -a -s TERM pmwebd > /dev/null 2>&1
    $ECHO $PCP_ECHO_N "Waiting for pmwebd to terminate ...""$PCP_ECHO_C"
    gone=0
    for i in 1 2 3 4 5 6
    do
	sleep 3
	_get_pids_by_name pmwebd >$tmp/tmp
	if [ ! -s $tmp/tmp ]
	then
	    gone=1
	    break
	fi

	# If pmwebd doesn't go in 15 seconds, SIGKILL and sleep 1 more time
	# to allow any clients reading from pmwebd sockets to fail so that
	# socket doesn't end up in TIME_WAIT or somesuch.
	#
	if [ $i = 5 ]
	then
	    $ECHO
	    echo "Process ..."
	    $PCP_PS_PROG $PCP_PS_ALL_FLAGS >$tmp/ps
	    sed 1q $tmp/ps
	    for pid in `cat $tmp/tmp`
	    do
		$PCP_AWK_PROG <$tmp/ps "\$2 == $pid { print }"
	    done
	    echo "$prog: Warning: Forcing pmwebd to terminate!"
	    pmsignal -a -s KILL pmwebd > /dev/null 2>&1
	else
	    $ECHO $PCP_ECHO_N ".""$PCP_ECHO_C"
	fi
    done
    if [ $gone != 1 ]	# It just WON'T DIE, give up.
    then
	echo "Process ..."
	cat $tmp/tmp
	echo "$prog: Warning: pmwebd won't die!"
	exit
    fi
    $RC_STATUS -v 
    $PCP_BINADM_DIR/pmpost "stop pmwebd from $pmprog"
}

_usage()
{
    echo "Usage: $pmprog [-v] {start|restart|condrestart|stop|status|reload|force-reload}"
}

while getopts v c
do
    case $c
    in
	v)  # force verbose
	    VERBOSE_CTL=on
	    ;;
	
	*)
	    _usage
	    exit 1
	    ;;
    esac
done
shift `expr $OPTIND - 1`

if [ $VERBOSE_CTL = on ]
then				# For a verbose startup and shutdown
    ECHO=$PCP_ECHO_PROG
else				# For a quiet startup and shutdown
    ECHO=:
fi

if [ "$IAM" != 0 -a "$1" != "status" ]
then
    if [ -n "$PCP_DIR" ]
    then
	: running in a non-default installation, do not need to be root
    else
	echo "$prog:"'
Error: You must be root (uid 0) to start or stop the PCP pmwebd daemon.'
	exit
    fi
fi

# First reset status of this service
$RC_RESET
 
# Return values acc. to LSB for all commands but status:
# 0 - success
# 1 - misc error
# 2 - invalid or excess args
# 3 - unimplemented feature (e.g. reload)
# 4 - insufficient privilege
# 5 - program not installed
# 6 - program not configured
#
# Note that starting an already running service, stopping
# or restarting a not-running service as well as the restart
# with force-reload (in case signalling is not supported) are
# considered a success.
case "$1" in

  'start'|'restart'|'condrestart'|'reload'|'force-reload')
	if [ "$1" = "condrestart" ] && ! is_chkconfig_on pmwebd
	then
	    status=0
	    exit
	fi

	_shutdown quietly

	# pmwebd messages should go to stderr, not the GUI notifiers
	#
	unset PCP_STDERR

	if [ -x $PMWEBD ]
	then
	    if [ ! -f $PCP_PMWEBDCONF_PATH ]
	    then
		echo "$prog:"'
Error: pmwebd control file "$PCP_PMWEBDCONF_PATH" is missing, cannot start pmwebd.'
		exit
	    fi
	    [ ! -d $RUNDIR ] && mkdir -p $RUNDIR
	    cd $RUNDIR

	    # salvage the previous versions of any pmwebd
	    #
	    if [ -f pmwebd.log ]
	    then
		rm -f pmwebd.log.prev
		mv pmwebd.log pmwebd.log.prev
	    fi

	    $ECHO $PCP_ECHO_N "Performance Co-Pilot starting pmwebd (logfile is $RUNDIR/pmwebd.log) ..." "$PCP_ECHO_C"

	    # options file processing ...
	    # only consider lines which start with a hyphen
	    # get rid of the -f option
	    # ensure multiple lines concat onto 1 line
	    OPTS=`sed <$PMWEBDOPTS 2>/dev/null \
			    -e '/^[^-]/d' \
			    -e 's/^/ /' \
			    -e 's/$/ /' \
			    -e 's/ -f / /g' \
			    -e 's/^ //' \
			    -e 's/ $//' \
		    | tr '\012' ' ' `

	    # environment stuff
	    #
	    eval `sed -e 's/"/\\"/g' $PMWEBDOPTS \
	    | awk -F= '
BEGIN			{ exports="" }
/^[A-Z]/ && NF == 2	{ exports=exports" "$1
			  printf "%s=${%s:-\"%s\"}\n", $1, $1, $2
			}
END			{ if (exports != "") print "export", exports }'`

	    $PMWEBD $OPTS
	    $RC_STATUS -v

	    $PCP_BINADM_DIR/pmpost "start pmwebd from $pmprog"

	fi
	status=0
        ;;

  'stop')
	_shutdown
	status=0
        ;;

  'status')
	# NOTE: $RC_CHECKPROC returns LSB compliant status values.
	$ECHO $PCP_ECHO_N "Checking for pmwebd:" "$PCP_ECHO_C"
        if [ -r /etc/rc.status ]
        then
            # SuSE
            $RC_CHECKPROC $PMWEBD
            $RC_STATUS -v
            status=$?
        else
            # not SuSE
            $RC_CHECKPROC $PMWEBD
            status=$?
            if [ $status -eq 0 ]
            then
                $ECHO running
            else
                $ECHO stopped
            fi
        fi
	;;

  *)
	_usage
        ;;
esac