/usr/share/cluster/script.sh is in resource-agents 1:4.1.0~rc1-1ubuntu1.
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 | #!/bin/bash
#
# Script to handle a non-OCF script (e.g. a normal init-script)
#
#
# Copyright (C) 1997-2003 Sistina Software, Inc. All rights reserved.
# Copyright (C) 2004-2011 Red Hat, 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.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
LC_ALL=C
LANG=C
PATH=/bin:/sbin:/usr/bin:/usr/sbin
export LC_ALL LANG PATH
. $(dirname $0)/ocf-shellfuncs
meta_data()
{
cat <<EOT
<?xml version="1.0"?>
<resource-agent version="rgmanager 2.0" name="script">
<version>1.0</version>
<longdesc lang="en">
The script resource allows a standard LSB-compliant init script
to be used to start a clustered service.
</longdesc>
<shortdesc lang="en">
LSB-compliant init script as a clustered resource.
</shortdesc>
<parameters>
<parameter name="name" unique="1" primary="1">
<longdesc lang="en">
Name
</longdesc>
<shortdesc lang="en">
Name
</shortdesc>
<content type="string"/>
</parameter>
<parameter name="file" unique="1" required="1">
<longdesc lang="en">
Path to script
</longdesc>
<shortdesc lang="en">
Path to script
</shortdesc>
<content type="string"/>
</parameter>
<parameter name="service_name" inherit="service%name">
<longdesc lang="en">
Inherit the service name, in case the
script wants to know this information.
</longdesc>
<shortdesc lang="en">
Inherit the service name.
</shortdesc>
<content type="string"/>
</parameter>
</parameters>
<actions>
<action name="start" timeout="0"/>
<action name="stop" timeout="0"/>
<!-- This is just a wrapper for LSB init scripts, so monitor
and status can't have a timeout, nor do they do any extra
work regardless of the depth -->
<action name="status" interval="30s" timeout="0"/>
<action name="monitor" interval="30s" timeout="0"/>
<action name="meta-data" timeout="0"/>
<action name="validate-all" timeout="0"/>
</actions>
</resource-agent>
EOT
}
validate_all()
{
if [ -z "${OCF_RESKEY_file}" ]; then
ocf_log err "No file provided"
return $OCF_ERR_ARGS # Invalid Argument
fi
if ! [ -e "${OCF_RESKEY_file}" ]; then
ocf_log err "${OCF_RESKEY_file} does not exist"
return $OCF_ERR_INSTALLED # Program not installed
fi
if [ -b "${OCF_RESKEY_file}" ]; then
ocf_log err "${OCF_RESKEY_file} is a block device"
return $OCF_ERR_ARGS # Invalid Argument
fi
if [ -d "${OCF_RESKEY_file}" ]; then
ocf_log err "${OCF_RESKEY_file} is a directory"
return $OCF_ERR_ARGS # Invalid Argument
fi
if [ -c "${OCF_RESKEY_file}" ]; then
ocf_log err "${OCF_RESKEY_file} is a character device"
return $OCF_ERR_ARGS # Invalid Argument
fi
if [ -p "${OCF_RESKEY_file}" ]; then
ocf_log err "${OCF_RESKEY_file} is a named pipe"
return $OCF_ERR_ARGS # Invalid Argument
fi
if [ -S "${OCF_RESKEY_file}" ]; then
ocf_log err "${OCF_RESKEY_file} is a socket"
return $OCF_ERR_ARGS # Invalid Argument
fi
if ! [ -s "${OCF_RESKEY_file}" ]; then
ocf_log err "${OCF_RESKEY_file} is empty"
return $OCF_ERR_GENERIC # ???
fi
if ! [ -x "${OCF_RESKEY_file}" ]; then
ocf_log err "${OCF_RESKEY_file} is not executable"
return $OCF_ERR_PERM
fi
return 0
}
case $1 in
meta-data)
meta_data
exit 0
;;
validate-all)
validate_all
exit $?
;;
*)
;;
esac
validate_all || exit $?
# Execute the script
ocf_log info "Executing ${OCF_RESKEY_file} $1"
${OCF_RESKEY_file} $1
declare -i rv=$?
if [ $rv -ne 0 ]; then
ocf_log err "script:$OCF_RESKEY_name: $1 of $OCF_RESKEY_file failed (returned $rv)"
exit $OCF_ERR_GENERIC
fi
|