This file is indexed.

/usr/share/cluster/ocf-shellfuncs is in resource-agents 1:3.9.2-5ubuntu4.

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
#! /bin/bash
#
# 	$Id$
#
# 	Common helper functions for the OCF Resource Agents supplied by
# 	heartbeat.
#
# Copyright (C) 2004 SUSE LINUX AG, Lars Marowsky-Bree. All Rights Reserved.
#

# TODO: Some of this should probably split out into a generic OCF
# library for shell scripts, but for the time being, we'll just use it
# ourselves...
#

# TODO wish-list:
# - Generic function for evaluating version numbers
# - Generic function(s) to extract stuff from our own meta-data
# - Logging function which automatically adds resource identifier etc
#   prefixes
# TODO: Move more common functionality for OCF RAs here.
#
__SCRIPT_NAME=`basename $0`

# lhh - determine if we're a dumb terminal
consoletype &> /dev/null
if [ $? -eq 1 ]; then
	__SERIAL="yes"
fi

__LOG_PID=$PPID
__LOG_NAME=$(basename $(readlink /proc/$PPID/exe))

pretty_echo() {
	declare pretty
	declare n=""
        declare __OCF_PRIO="$1"
        shift
        declare __OCF_MSG="$*"

	if [ -n "$__SERIAL" ]; then
		echo "<$__OCF_PRIO> $__OCF_MSG"
		return 0
	fi

	case $__OCF_PRIO in
	emerg)		pretty="";;
	alert)		pretty="";;
        crit|critical)	pretty="";;
        err|error)	pretty="";;
        warn|warning)	pretty="";;
	note|notice)	pretty="";;
        info)		pretty="";;
        debug|dbg)	pretty="";;
        *)		pretty="";;
	esac

	echo "$n<$pretty$__OCF_PRIO$n> $__OCF_MSG"
	return 0
}

__ocf_set_defaults() {
	__OCF_ACTION="$1"

	# Return to sanity for the agents...
	unset LANG
	LC_ALL=C
	export LC_ALL

	# TODO: Review whether we really should source this. Or rewrite
	# to match some emerging helper function syntax...? This imports
	# things which no OCF RA should be using...

	OCF_SUCCESS=0
	OCF_ERR_GENERIC=1
	OCF_ERR_ARGS=2
	OCF_ERR_UNIMPLEMENTED=3
	OCF_ERR_PERM=4
	OCF_ERR_INSTALLED=5
	OCF_ERR_CONFIGURED=6
	OCF_NOT_RUNNING=7

	if [ -z "$OCF_RESOURCE_TYPE" ]; then
		: ${OCF_RESOURCE_TYPE:=$__SCRIPT_NAME}
	fi

	if [ -z "$OCF_RA_VERSION_MAJOR" ]; then
		: We are being invoked as an init script.
		: Fill in some things with reasonable values.
		: ${OCF_RESOURCE_INSTANCE:="default"}
		return 0
        fi

	if [ -z "$OCF_ROOT" ]; then
		OCF_ROOT=$(dirname $0)
	fi
	if [ ! -d "$OCF_ROOT" ]; then
		ocf_log err "OCF_ROOT points to non-directory $OCF_ROOT."
		exit $OCF_ERR_GENERIC
	fi

	# TODO: Anything else we should be setting and thus checking?
        # There is nothing in this script which depends on the version
	# of the API.  TESTING THIS HERE IS A BUG.  THIS SHOULD BE
	# tested by the script that's invoked us.  FIXME!!
	if [ "x$OCF_RA_VERSION_MAJOR" != "x1" ]; then
		ocf_log err "This script is OCF RA API 1.x compliant only!"
		exit $OCF_ERR_UNIMPLEMENTED
	fi
	# TODO: Should the minor level really be a number and not rather
	# a list of flags...?
        # AlanR says -- absolutely not -- a list of flags is good for a list
	# of implemented features, not a version compiliance
	# perhaps some future version might have such a list of
	# flags, but that would be _in addition to_ the minor version number
	if [ -z "$OCF_RA_VERSION_MINOR" ]; then
		ocf_log err "No OCF RA minor version set."
		exit $OCF_ERR_UNIMPLEMENTED
	fi

	if [ "x$__OCF_ACTION" = "xmeta-data" ]; then
		OCF_RESOURCE_INSTANCE="undef"
	fi	

	if [ -z "$OCF_RESOURCE_INSTANCE" ]; then
		ocf_log err "Need to tell us our resource instance name."
		exit $OCF_ERR_ARGS
	fi
}


ocf_log() {
	# TODO: Revisit and implement internally.
	if
          [ $# -lt 2 ]
        then
          ocf_log err "Not enough arguments [$#] to ocf_log."
        fi

        declare __OCF_PRIO="$1"
	declare -i __OCF_PRIO_N

        shift

        declare __OCF_MSG="$*"

        case "${__OCF_PRIO}" in
	emerg)		__OCF_PRIO_N=0;; # Not in original ocf-shellfuncs
	alert)		__OCF_PRIO_N=1;; # Not in original ocf-shellfuncs
        crit|critical)	__OCF_PRIO_N=2;;
        err|error)	__OCF_PRIO_N=3;;
        warn|warning)	__OCF_PRIO_N=4;;
	note|notice)	__OCF_PRIO_N=5;; # Not in original ocf-shellfuncs
        info)		__OCF_PRIO_N=6;;
        debug|dbg)	__OCF_PRIO_N=7;;
        *)		__OCF_PRIO_N=5;; # Defaults to INFO
	esac

	pretty_echo $__OCF_PRIO "$__OCF_MSG"

	if [ -z "`which clulog 2> /dev/null`" ]; then
		return 0
	fi
	clulog -m "$OCF_RESOURCE_TYPE" -s $__OCF_PRIO_N "$__OCF_MSG"
}

__ocf_set_defaults "$@"