This file is indexed.

/etc/dpm-postgres/dpm.init is in dpm-server-postgres 1.8.7-3.1+b1.

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
294
295
296
297
298
299
300
301
302
303
304
305
306
#!/bin/sh
#
# dpm         Start/Stop dpm
#
# chkconfig: 2345 93 17
# description: DPM server daemon
#
### BEGIN INIT INFO
# Provides:          dpm
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Should-Start:      $network postgresql dpnsdaemon
# Should-Stop:       $network postgresql dpnsdaemon
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: DPM server daemon
# Description:       DPM server daemon
### END INIT INFO
#
# $Id: dpm.scripts.postgresql 8408 2013-02-21 14:19:57Z mhellmic $
#
# @(#)$RCSfile: dpm.scripts.postgresql,v $ $Revision: 8408 $ $Date: 2013-02-21 15:19:57 +0100 (Thu, 21 Feb 2013) $ CERN/IT/ADC/CA Jean-Damien Durand
#

#
## PLEASE USE sysconfig FILE TO CHANGE THESE ENVIRONMENT VARIABLES
#
PREFIX=/usr
GRIDMAPDIR=/etc/grid-security/gridmapdir
export GRIDMAPDIR
GRIDMAP=/etc/grid-security/grid-mapfile
export GRIDMAP
CSEC_MECH=ID
export CSEC_MECH
DPMDAEMONLOGFILE=/var/log/dpm/log
DPMCONFIGFILE=/etc/DPMCONFIG
DPMUSER=dpmmgr
DPMGROUP=dpmmgr
NB_FTHREADS=20
NB_STHREADS=20

sysname=`uname -s`

# source function library
if [ -r /etc/rc.d/init.d/functions ]; then
    . /etc/rc.d/init.d/functions
    DAEMON="daemon --check dpm"
    FAILURE=failure
    ECHO_FAILURE=echo_failure
    SUCCESS=success
    ECHO_SUCCESS=echo_success
    ECHO_END=echo
    if [ $sysname = "Linux" ]; then
        ECHOOPT=-n
    fi
else
    DAEMON=eval
    FAILURE=
    ECHO_FAILURE=
    SUCCESS=
    ECHO_SUCCESS=
    ECHOOPT=
    ECHO_END=
fi

RETVAL=0
prog="dpm"
PIDFILE=/var/run/dpm.pid
PIDDIR=/var/run
SUBSYS=/var/lock/subsys/dpm
SUBSYSDIR=/var/lock/subsys
[ -z "$SILENTSTOP" ] && SILENTSTOP=0
DPMDAEMON=$PREFIX/sbin/dpm
DPMSHUTDOWN=$PREFIX/sbin/dpm-shutdown
if [ -r /etc/dpm.conf ]; then
    SYSCONFIGDPMDAEMON=/etc/dpm.conf
elif [ -r /etc/sysconfig/dpm ]; then
    SYSCONFIGDPMDAEMON=/etc/sysconfig/dpm
elif [ -r /etc/default/dpm ]; then
    SYSCONFIGDPMDAEMON=/etc/default/dpm
fi

#
## Blindly attempt to create useful directories
#
# [ ! -d $PIDDIR ] && mkdir -p $PIDDIR > /dev/null 2>&1
# [ ! -d $SUBSYSDIR ] && mkdir -p $SUBSYSDIR > /dev/null 2>&1

if [ $sysname = "HP-UX" ]; then
    export UNIX95=1
fi
if [ $sysname = "SunOS" ]; then
    format4comm="fname"
elif [ $sysname = "Darwin" ]; then
    format4comm="ucomm"
else
    format4comm="comm"
fi

start() {
    if [ -n "$SYSCONFIGDPMDAEMON" ]; then
        #
        ## Source the configuration
        #
        . $SYSCONFIGDPMDAEMON
        if [ "${RUN_DPMDAEMON}" != "yes" ]; then
            echo $ECHOOPT "$SYSCONFIGDPMDAEMON says NO: "
            [ -n "$ECHO_SUCCESS" ] && $ECHO_SUCCESS "$SYSCONFIGDPMDAEMON says NO: "
            RETVAL=0
            $ECHO_END
            exit $RETVAL
        fi
        export DPNS_HOST
        if [ -n "${ULIMIT_N}" ]; then
            ulimit -n ${ULIMIT_N}
        fi
    fi
    if [ ! -s "$DPMCONFIGFILE" ]; then
        echo $ECHOOPT "config file $DPMCONFIGFILE empty: "
        [ -n "$ECHO_FAILURE" ] && $ECHO_FAILURE "config file $DPMCONFIGFILE empty: "
        RETVAL=1
    fi
    if [ $RETVAL -eq 0 ]; then
        echo $ECHOOPT "Starting $prog: "
        cd /
        mkdir -p `dirname $DPMDAEMONLOGFILE`
        chown $DPMUSER:$DPMGROUP `dirname $DPMDAEMONLOGFILE`
        ## For the DPM, umask must be set to 0
        umask 0
        if [ "${ALLOW_COREDUMP}" != "yes" ]; then
            $DAEMON "su $DPMUSER -c \"$DPMDAEMON -t $NB_FTHREADS -T $NB_STHREADS -c $DPMCONFIGFILE -l $DPMDAEMONLOGFILE\""
        else
            $DAEMON "su $DPMUSER -c \"mkdir -p $DPMUSERHOME/dpm; cd $DPMUSERHOME/dpm; hostname -f >> logstart; date >> logstart; umask 0; umask >> logstart; ulimit -c unlimited; pwd >> logstart; ulimit -c >> logstart; echo DAEMON $DPMDAEMON \`hostname -f\` >> logstart; $DPMDAEMON -t $NB_FTHREADS -T $NB_STHREADS -c $DPMCONFIGFILE -l $DPMDAEMONLOGFILE\""
        fi
        if [ $? -eq 0 ]; then
            [ -d $SUBSYSDIR ] && touch $SUBSYS
            if [ -d $PIDDIR ]; then
                pid=`ps -eo pid,ppid,$format4comm | grep " 1 dpm$" | awk '{print $1}'`
                # The point of $PIDFILE is that it kills only
                # the master daemon.
                rm -f $PIDFILE
                echo $pid > $PIDFILE
            fi
            [ -n "$ECHO_SUCCESS" ] && $ECHO_SUCCESS "Starting $prog: "
            RETVAL=0
        else
            [ -n "$ECHO_FAILURE" ] && $ECHO_FAILURE "Starting $prog: "
            RETVAL=1
        fi
    fi
}

case "$1" in
  start)
    DPMUSERHOME=`finger $DPMUSER | grep -i directory: | cut -f 2 -d' '`
    X509_USER_CERT=/etc/grid-security/$DPMUSER/dpmcert.pem
    export X509_USER_CERT
    X509_USER_KEY=/etc/grid-security/$DPMUSER/dpmkey.pem
    export X509_USER_KEY

    pid=`ps -eo pid,ppid,$format4comm | grep " 1 dpm$" | awk '{print $1}'`
    if [ -n "$pid" ]; then
        echo $ECHOOPT "dpm (pid $pid) already started:"
        $ECHO_SUCCESS
        RETVAL=0
    else
        netstat -an | egrep '[:.]5015 ' | egrep 'LISTEN *$' > /dev/null
        port_in_use="$?" # 0 is true, > 0 is false

        if [ -f $PIDFILE ]; then
            if [ $port_in_use -eq 0 ]; then 
                echo $ECHOOPT "dpm port in use:"
                $ECHO_FAILURE
                RETVAL=1
            else
                start
            fi
        else
            if [ $port_in_use -eq 0 ]; then 
                echo $ECHOOPT "dpm port in use:"
                $ECHO_FAILURE
                RETVAL=1
            else
                start
            fi
        fi
    fi
    $ECHO_END
    ;;
  stop)
    if [ -f $PIDFILE ]; then
        echo $ECHOOPT "Stopping $prog: "
        if [ -x $DPMSHUTDOWN ]; then
            $DPMSHUTDOWN -f -h `hostname` > /dev/null 2>&1
            RETVAL=$?
            if [ $RETVAL -ne 0 ]; then
                kill -2 -`cat $PIDFILE` > /dev/null 2>&1
                RETVAL=$?
            fi
        else
            kill -2 -`cat $PIDFILE` > /dev/null 2>&1
            RETVAL=$?
        fi
        if [ $RETVAL -eq 0 ]; then
            rm -f $PIDFILE
            [ -n "$ECHO_SUCCESS" ] && $ECHO_SUCCESS "Stopping $prog: "
        else
            [ -n "$ECHO_FAILURE" ] && $ECHO_FAILURE "Stopping $prog: "
        fi
    else
        # dpm might have been started by hand
        pid=`ps -eo pid,ppid,$format4comm | grep " 1 dpm$" | awk '{print $1}'`
        if [ -n "$pid" ]; then
            echo $ECHOOPT "Stopping $prog: "
            if [ -x $DPMSHUTDOWN ]; then
                $DPMSHUTDOWN -f -h `hostname` > /dev/null 2>&1
                RETVAL=$?
                if [ $RETVAL -ne 0 ]; then
                    kill -2 -$pid > /dev/null 2>&1
                    RETVAL=$?
                fi
            else
                kill -2 -$pid > /dev/null 2>&1
                RETVAL=$?
            fi
            if [ $RETVAL -eq 0 ]; then
                [ -n "$ECHO_SUCCESS" ] && $ECHO_SUCCESS "Stopping $prog: "
            else
                [ -n "$ECHO_FAILURE" ] && $ECHO_FAILURE "Stopping $prog: "
            fi
        else
            echo $ECHOOPT "dpm already stopped: "
            [ -n "$ECHO_SUCCESS" ] && $ECHO_SUCCESS "dpm already stopped: "
            [ $SILENTSTOP -eq 0 ] && RETVAL=0 || RETVAL=1
        fi
    fi

    lpid="X"
    while [ "x$lpid" != "x" ]; do
        sleep 1
        #Does not seem to work on SunOS ;-)
        lpid=`ps -eo pid,ppid,$format4comm | grep " 1 dpm$" | awk '{print $1}'`
    done

    [ -d $SUBSYSDIR ] && rm -f $SUBSYS
    $ECHO_END
    ;;
  restart | force-reload)
    $0 stop
    if [ $? -eq 0 -o $SILENTSTOP -eq 0 ]; then
        sleep 1
        $0 start
        RETVAL=$?
    else
        RETVAL=0
    fi
    ;;
  condrestart | try-restart)
    SILENTSTOP=1
    export SILENTSTOP
    $0 restart
    RETVAL=$?
    ;;
  reload)
    ;;
  status)
    pid=`ps -eo pid,ppid,$format4comm | grep " 1 dpm$" | awk '{print $1}'`
    if [ -n "$pid" ]; then
        echo $ECHOOPT "dpm (pid $pid) is running..."
        $ECHO_SUCCESS
        $ECHO_END
        RETVAL=0
    else
        if [ -f $PIDFILE ]; then
            pid=`head -1 $PIDFILE`
            if [ "$pid" != "" ] ; then
                echo $ECHOOPT "dpm dead but pid file exists"
                $ECHO_FAILURE
                $ECHO_END
                RETVAL=1
            else
                echo $ECHOOPT "dpm dead"
                $ECHO_FAILURE
                $ECHO_END
                RETVAL=1
            fi
        else
            if [ -f $SUBSYS ]; then
                echo $ECHOOPT "dpm dead but subsys ($SUBSYS) locked"
                RETVAL=2
            else
                echo $ECHOOPT "dpm is stopped"
                RETVAL=3
            fi
            $ECHO_FAILURE
            $ECHO_END
        fi
    fi
    ;;
  *)
    echo "Usage: $0 {start|stop|status|restart|condrestart}"
    RETVAL=1
    ;;
esac

exit $RETVAL