This file is indexed.

/usr/lib/ocf/resource.d/heartbeat/eDir88 is in cluster-agents 1:1.0.4-0ubuntu2.

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
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
#!/bin/bash
#
#      eDirectory Resource Agent (RA) for Heartbeat.
#      This script is only compatible with eDirectory 8.8 and later
#
# Copyright (c) 2007 Novell Inc, Yan Fitterer
#                    All Rights Reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of version 2 of the GNU General Public License as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it would be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# Further, this software is distributed without any warranty that it is
# free of the rightful claim of any third person regarding infringement
# or the like.  Any license provided herein, whether implied or
# otherwise, applies only to this software file.  Patent licenses, if
# any, provided herein do not apply to combinations of this program with
# other software, or any other product whatsoever.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write the Free Software Foundation,
# Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
#
#
# OCF parameters:
#  OCF_RESKEY_eDir_config_file      - full filename to instance configuration file
#  OCF_RESKEY_eDir_monitor_ldap     - Should we monitor LDAP (0/1 - 1 is true)
#  OCF_RESKEY_eDir_monitor_idm      - Should we monitor IDM (0/1 - 1 is true)
#  OCF_RESKEY_eDir_jvm_initial_heap - Value of the DHOST_INITIAL_HEAP java env var
#  OCF_RESKEY_eDir_jvm_max_heap     - Value of the DHOST_MAX_HEAP java env var
#  OCF_RESKEY_eDir_jvm_options      - Value of the DHOST_OPTIONS java env var
###############################################################################

#######################################################################
# Initialization:

: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
test -f /opt/novell/eDirectory/bin/ndspath &&
	. /opt/novell/eDirectory/bin/ndspath 2>/dev/null >/dev/null

#######################################################################

usage() {
    ME=$(basename "$0")
    cat <<-EOFA

usage: $ME start|stop|status|monitor|validate-all

$ME manages an eDirectory instance as an HA resource.

The 'start' operation starts the instance.
The 'stop' operation stops the instance.
The 'status' operation reports if the instance is running.
The 'monitor' operation reports if the instance is running, and runs additional checks.
The 'validate-all' operation checks the validity of the arguments (environment variables).
EOFA
}

eDir_meta_data() {
cat <<-EOFB
<?xml version="1.0"?>
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
<resource-agent name="eDir88" version="0.17">
<version>1.0</version>

<longdesc lang="en">
Resource script for managing an eDirectory instance. Manages a single instance
of eDirectory as an HA resource. The "multiple instances" feature or
eDirectory has been added in version 8.8. This script will not work for any
version of eDirectory prior to 8.8. This RA can be used to load multiple
eDirectory instances on the same host.

It is very strongly recommended to put eDir configuration files (as per the
eDir_config_file parameter) on local storage on each node. This is necessary for
this RA to be able to handle situations where the shared storage has become
unavailable. If the eDir configuration file is not available, this RA will fail,
and heartbeat will be unable to manage the resource. Side effects include
STONITH actions, unmanageable resources, etc...

Setting a high action timeout value is _very_ _strongly_ recommended. eDir
with IDM can take in excess of 10 minutes to start. If heartbeat times out
before eDir has had a chance to start properly, mayhem _WILL ENSUE_.

The LDAP module seems to be one of the very last to start. So this script will
take even longer to start on installations with IDM and LDAP if the monitoring
of IDM and/or LDAP is enabled, as the start command will wait for IDM and LDAP
to be available.
</longdesc>
<shortdesc lang="en">Manages a Novell eDirectory directory server</shortdesc>
<parameters>
<parameter name="eDir_config_file" unique="1" required="0">
<longdesc lang="en">
Path to configuration file for eDirectory instance.
</longdesc>
<shortdesc lang="en">eDir config file</shortdesc>
<content type="string" default="/etc/opt/novell/eDirectory/conf/nds.conf" />
</parameter>
<parameter name="eDir_monitor_ldap" required="0">
<longdesc lang="en">
Should we monitor if LDAP is running for the eDirectory instance?
</longdesc>
<shortdesc lang="en">eDir monitor ldap</shortdesc>
<content type="boolean" default="0" />
</parameter>
<parameter name="eDir_monitor_idm" required="0">
<longdesc lang="en">
Should we monitor if IDM is running for the eDirectory instance?
</longdesc>
<shortdesc lang="en">eDir monitor IDM</shortdesc>
<content type="boolean" default="0" />
</parameter>
<parameter name="eDir_jvm_initial_heap" required="0">
<longdesc lang="en">
Value for the DHOST_INITIAL_HEAP java environment variable. If unset, java defaults will be used.
</longdesc>
<shortdesc lang="en">DHOST_INITIAL_HEAP value</shortdesc>
<content type="integer" default="" />
</parameter>
<parameter name="eDir_jvm_max_heap" required="0">
<longdesc lang="en">
Value for the DHOST_MAX_HEAP java environment variable. If unset, java defaults will be used.
</longdesc>
<shortdesc lang="en">DHOST_MAX_HEAP value</shortdesc>
<content type="integer" default="" />
</parameter>
<parameter name="eDir_jvm_options" required="0">
<longdesc lang="en">
Value for the DHOST_OPTIONS java environment variable. If unset, original values will be used.
</longdesc>
<shortdesc lang="en">DHOST_OPTIONS value</shortdesc>
<content type="string" default="" />
</parameter>
</parameters>

<actions>
<action name="start" timeout="600" />
<action name="stop" timeout="600" />
<action name="monitor" timeout="60" interval="30" />
<action name="meta-data" timeout="5" />
<action name="validate-all" timeout="5" />
</actions>
</resource-agent>
EOFB
return $OCF_SUCCESS
}

#
# eDir_start: Start eDirectory instance
#

eDir_start() {
    if eDir_status ; then
        ocf_log info "eDirectory is already running ($NDSCONF)."
        return $OCF_SUCCESS
    fi

    # Start eDirectory instance
    if [ -n "$OCF_RESKEY_eDir_jvm_initial_heap" ]; then
        DHOST_JVM_INITIAL_HEAP=$OCF_RESKEY_eDir_jvm_initial_heap
        export DHOST_JVM_INITIAL_HEAP
    fi
    if [ -n "$OCF_RESKEY_eDir_jvm_max_heap" ]; then
        DHOST_JVM_MAX_HEAP=$OCF_RESKEY_eDir_jvm_max_heap
        export DHOST_JVM_MAX_HEAP
    fi
    if [ -n "$OCF_RESKEY_eDir_jvm_options" ]; then
        DHOST_JVM_OPTIONS=$OCF_RESKEY_eDir_jvm_options
        export DHOST_JVM_OPTIONS
    fi

    $NDSMANAGE start --config-file "$NDSCONF" > /dev/null 2>&1
    if [ $? -eq 0 ]; then
        ocf_log info "eDir start command sent for $NDSCONF."
    else
        echo "ERROR: Can't start eDirectory for $NDSCONF."
        return $OCF_ERR_GENERIC
    fi

    CNT=0
    while ! eDir_monitor ; do
        # Apparently, LDAP will only start after all other services
        # Startup time can be in excess of 10 minutes.
        # Leave a very long heartbeat timeout on the start action
        # We're relying on heartbeat to bail us out...
        let CNT=$CNT+1
        ocf_log info "eDirectory start waiting for ${CNT}th retry for $NDSCONF."
        sleep 10
    done

    ocf_log info "eDirectory start verified for $NDSCONF."

    return $OCF_SUCCESS
}

#
# eDir_stop: Stop eDirectory instance
#            This action is written in such a way that even when run
#            on a node were things are broken (no binaries, no config
#            etc...) it will try to stop any running ndsd processes
#            and report success if none are running.
#

eDir_stop() {
    if ! eDir_status ; then
        return $OCF_SUCCESS
    fi

    $NDSMANAGE stop --config-file "$NDSCONF" >/dev/null 2>&1
    if eDir_status ; then
            # eDir failed to stop.
        ocf_log err "eDirectory instance failed to stop for $NDSCONF"
        return $OCF_ERR_GENERIC
    else
        ocf_log info "eDirectory stop verified for $NDSCONF."
        return $OCF_SUCCESS
    fi
}

#
# eDir_status: is eDirectory instance up ?
#

eDir_status() {
    if [ ! -r "$NDSCONF" ] ; then
        ocf_log err "Config file missing ($NDSCONF)."
        exit $OCF_ERR_GENERIC
    fi

    # Find how many ndsd processes have open listening sockets
    # with the IP of this eDir instance
    IFACE=$(grep -i "n4u.server.interfaces" $NDSCONF | cut -f2 -d= | tr '@' ':')
    if [ -z "$IFACE" ] ; then
        ocf_log err "Cannot retrieve interfaces from $NDSCONF. eDirectory may not be correctly configured."
        exit $OCF_ERR_GENERIC
    fi
    NDSD_SOCKS=$(netstat -ntlp | grep -ce "$IFACE.*ndsd")

    if [ "$NDSD_SOCKS" -eq 1 ] ; then
        # Correct ndsd instance is definitely running
        # Further checks are superfluous (I think...)
        return 0
    elif [ "$NDSD_SOCKS" -gt 1 ] ; then
        ocf_log err "More than 1 ndsd listening socket matched. Likely misconfiguration of eDirectory."
        exit $OCF_ERR_GENERIC
    fi

    # No listening socket. Make sure we don't have the process running...
    PIDDIR=$(grep -i "n4u.server.vardir" "$NDSCONF" | cut -f2 -d=)
    if [ -z "$PIDDIR" ] ; then
        ocf_log err "Cannot get vardir from nds config ($NDSCONF). Probable eDir configuration error."
        exit $OCF_ERR_GENERIC
    fi
    NDSD_PID=$(cat $PIDDIR/ndsd.pid 2>/dev/null)
    if [ -z "$NDSD_PID" ] ; then
        # PID file unavailable or empty.
        # This will happen if the PIDDIR is not available
        # on this node at this time.
        return 1
    fi

    RC=$(ps -p "$NDSD_PID" | grep -c ndsd)
    if [ "$RC" -gt 0 ] ; then
        # process found but no listening socket. ndsd likely not operational
        ocf_log err "ndsd process found, but no listening socket. Something's gone wrong ($NDSCONF)"
        exit $OCF_ERR_GENERIC
    fi

    # Instance is not running, but no other error detected.
    return 1
}


#
# eDir_monitor: Do more in-depth checks to ensure that eDirectory is fully functional
#               LDAP and IDM checks are only done if reqested.
#
#

eDir_monitor() {
    if ! eDir_status ; then
        ocf_log info "eDirectory instance is down ($NDSCONF)"
        return $OCF_NOT_RUNNING
    fi

    # We know the right ndsd is running locally, check health
    $NDSSTAT --config-file "$NDSCONF" >/dev/null 2>&1
    if [ $? -ne 0 ] ; then
        return 1
    fi

    # Monitor IDM first, as it will start before LDAP
    if [ $MONITOR_IDM -eq 1 ]; then
        RET=$($NDSTRACE --config-file "$NDSCONF" -c modules | egrep -i '^vrdim.*Running' | awk '{print $1}')
        if [ "$RET" !=  "vrdim" ]; then
            ocf_log err "eDirectory IDM engine isn't running ($NDSCONF)."
            return $OCF_ERR_GENERIC
        fi
    fi
    if [ $MONITOR_LDAP -eq 1 ] ; then
        $NDSNLDAP -c --config-file "$NDSCONF" >/dev/null 2>&1
        if [ $? -ne 0 ]; then
            ocf_log err "eDirectory LDAP server isn't running ($NDSCONF)."
            return $OCF_ERR_GENERIC
        fi
    fi

    ocf_log debug "eDirectory monitor success ($NDSCONF)"
    return $OCF_SUCCESS
}

#
# eDir_validate: Validate environment
#

eDir_validate() {

    declare rc=$OCF_SUCCESS

    # Script must be run as root
    if ! ocf_is_root ; then
        ocf_log err "$0 must be run as root"
        rc=$OCF_ERR_GENERIC
    fi

    # ndsmanage must be available and runnable
    check_binary $NDSMANAGE

    # ndsstat must be available and runnable
    check_binary $NDSSTAT

    # Config file must be readable
    if [ ! -r "$NDSCONF" ] ; then
        ocf_log err "eDirectory configuration file [$NDSCONF] is not readable"
        rc=$OCF_ERR_ARGS
    fi

    # monitor_ldap must be unambiguously resolvable to a truth value
    MONITOR_LDAP=$(echo "$MONITOR_LDAP" | tr [A-Z] [a-z])
    case "$MONITOR_LDAP" in
        yes|true|1)
            MONITOR_LDAP=1;;
        no|false|0)
            MONITOR_LDAP=0;;
        *)
            ocf_log err "Configuration parameter eDir_monitor_ldap has invalid value [$MONITOR_LDAP]"
            rc=$OCF_ERR_ARGS;;
    esac

    # monitor_idm must be unambiguously resolvable to a truth value
    MONITOR_IDM=$(echo "$MONITOR_IDM" | tr [A-Z] [a-z])
    case "$MONITOR_IDM" in
        yes|true|1)
            MONITOR_IDM=1;;
        no|false|0)
            MONITOR_IDM=0;;
        *)
            ocf_log err "Configuration parameter eDir_monitor_idm has invalid value [$MONITOR_IDM]"
            rc=$OCF_ERR_ARGS;;
    esac

    # eDir_jvm_initial_heap must be blank or numeric
    if [ -n "$OCF_RESKEY_eDir_jvm_initial_heap" ] ; then
        if ! ocf_is_decimal "$OCF_RESKEY_eDir_jvm_initial_heap" ; then
            ocf_log err "Configuration parameter eDir_jvm_initial_heap has invalid" \
                        "value [$OCF_RESKEY_eDir_jvm_initial_heap]"
            rc=$OCF_ERR_ARGS
        fi
    fi

    # eDir_jvm_max_heap must be blank or numeric
    if [ -n "$OCF_RESKEY_eDir_jvm_max_heap" ] ; then
        if ! ocf_is_decimal "$OCF_RESKEY_eDir_jvm_max_heap" ; then
            ocf_log err "Configuration parameter eDir_jvm_max_heap has invalid" \
                         "value [$OCF_RESKEY_eDir_jvm_max_heap]"
            rc=$OCF_ERR_ARGS
        fi
    fi
    if [ $rc -ne $OCF_SUCCESS ] ; then
        ocf_log err "Invalid environment"
    fi
    return $rc
}

#
# Start of main logic
#

ocf_log debug "$0 started with arguments \"$@\""

NDSBASE=/opt/novell/eDirectory
NDSNLDAP=$NDSBASE/sbin/nldap
NDSMANAGE=$NDSBASE/bin/ndsmanage
NDSSTAT=$NDSBASE/bin/ndsstat
NDSTRACE=$NDSBASE/bin/ndstrace
NDSCONF=${OCF_RESKEY_eDir_config_file:-/etc/opt/novell/eDirectory/conf/nds.conf}
MONITOR_LDAP=${OCF_RESKEY_eDir_monitor_ldap:-0}
MONITOR_IDM=${OCF_RESKEY_eDir_monitor_idm:-0}


# What kind of method was invoked?
case "$1" in
    validate-all) eDir_validate;   exit $?;;
    meta-data)    eDir_meta_data;  exit $OCF_SUCCESS;;
    status)       if eDir_status ; then
                      ocf_log info "eDirectory instance is up ($NDSCONF)"
                      exit $OCF_SUCCESS
                  else
                      ocf_log info "eDirectory instance is down ($NDSCONF)"
                      exit $OCF_NOT_RUNNING
                  fi;;
    start)        : skip;;
    stop)         : skip;;
    monitor)      : skip;;
    usage)        usage; exit $OCF_SUCCESS;;
    *)            ocf_log err "Invalid argument [$1]"
                  usage; exit $OCF_ERR_ARGS;;
esac

# From now on we must have a valid environment to continue.
# stop goes in the list above as it should ideally be able to
# clean up after a start that failed due to bad args

eDir_validate
RC=$?
if [ $RC -ne $OCF_SUCCESS ]; then
    exit $RC
fi

case "$1" in
    start)      eDir_start;;
    stop)       eDir_stop;;
    monitor)    eDir_monitor;;
esac

exit $?