File bsc956739_resource-agents.patch of Package resource-agents.2007
diff --git a/heartbeat/Makefile.am b/heartbeat/Makefile.am
index 73ce6b6..38d1016 100644
--- a/heartbeat/Makefile.am
+++ b/heartbeat/Makefile.am
@@ -144,12 +144,14 @@ ocfcommon_DATA = ocf-shellfuncs \
ocf-directories \
ocf-returncodes \
ocf-rarun \
+ ocf-distro \
apache-conf.sh \
http-mon.sh \
sapdb-nosha.sh \
sapdb.sh \
ora-common.sh \
mysql-common.sh \
+ nfsserver-redhat.sh \
findif.sh
# Legacy locations
diff --git a/heartbeat/nfsserver b/heartbeat/nfsserver
index de1a802..3cec5c8 100755
--- a/heartbeat/nfsserver
+++ b/heartbeat/nfsserver
@@ -12,6 +12,10 @@ else
. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
fi
+if is_redhat_based; then
+ . ${OCF_FUNCTIONS_DIR}/nfsserver-redhat.sh
+fi
+
DEFAULT_INIT_SCRIPT="/etc/init.d/nfsserver"
if ! [ -f $DEFAULT_INIT_SCRIPT ]; then
# On some systems, the script is just called nfs
@@ -26,9 +30,6 @@ EXEC_MODE=0
SELINUX_ENABLED=-1
STATD_PATH="/var/lib/nfs"
STATD_DIR=""
-NFS_SYSCONFIG="/etc/sysconfig/nfs"
-NFS_SYSCONFIG_LOCAL_BACKUP="/etc/sysconfig/nfs.ha.bu"
-NFS_SYSCONFIG_AUTOGEN_TAG="AUTOGENERATED by $0 high availability resource-agent"
nfsserver_meta_data() {
cat <<END
@@ -104,83 +105,6 @@ IP addresses.
<content type="string"/>
</parameter>
-<parameter name="nfsd_args" unique="0" required="0">
-<longdesc lang="en">
-Specifies what arguments to pass to the nfs daemon on startup. View the rpc.nfsd man page for information on what arguments are available.
-Note that setting this value will override all settings placed in the local /etc/sysconfig/nfs file.
-</longdesc>
-<shortdesc lang="en">
-rpc.nfsd options
-</shortdesc>
-<content type="string" />
-</parameter>
-
-<parameter name="lockd_udp_port" unique="0" required="0">
-<longdesc lang="en">
-The udp port lockd should listen on.
-Note that setting this value will override all settings placed in the local /etc/sysconfig/nfs file.
-</longdesc>
-<shortdesc lang="en">
-lockd udp port
-</shortdesc>
-<content type="integer" />
-</parameter>
-
-<parameter name="lockd_tcp_port" unique="0" required="0">
-<longdesc lang="en">
-The tcp port lockd should listen on.
-Note that setting this value will override all settings placed in the local /etc/sysconfig/nfs file.
-</longdesc>
-<shortdesc lang="en">
-lockd tcp port
-</shortdesc>
-<content type="integer" />
-</parameter>
-
-<parameter name="statd_outgoing_port" unique="0" required="0">
-<longdesc lang="en">
-The source port number sm-notify uses when sending reboot notifications.
-Note that setting this value will override all settings placed in the local /etc/sysconfig/nfs file.
-</longdesc>
-<shortdesc lang="en">
-sm-notify source port
-</shortdesc>
-<content type="integer" />
-</parameter>
-
-<parameter name="statd_port" unique="0" required="0">
-<longdesc lang="en">
-The port number used for RPC listener sockets.
-Note that setting this value will override all settings placed in the local /etc/sysconfig/nfs file.
-</longdesc>
-<shortdesc lang="en">
-rpc.statd listener port
-</shortdesc>
-<content type="integer" />
-</parameter>
-
-<parameter name="mountd_port" unique="0" required="0">
-<longdesc lang="en">
-The port number used for rpc.mountd listener sockets.
-Note that setting this value will override all settings placed in the local /etc/sysconfig/nfs file.
-</longdesc>
-<shortdesc lang="en">
-rpc.mountd listener port
-</shortdesc>
-<content type="integer" />
-</parameter>
-
-<parameter name="rquotad_port" unique="0" required="0">
-<longdesc lang="en">
-The port number used for rpc.rquotad.
-Note that setting this value will override all settings placed in the local /etc/sysconfig/nfs file.
-</longdesc>
-<shortdesc lang="en">
-rpc.rquotad port
-</shortdesc>
-<content type="integer" />
-</parameter>
-
<parameter name="nfs_shared_infodir" unique="0" required="0">
<longdesc lang="en">
The nfsserver resource agent will save nfs related information in this specific directory.
@@ -205,6 +129,10 @@ The mount point for the sunrpc file system.
<content type="string" default="$DEFAULT_RPCPIPEFS_DIR" />
</parameter>
+$(
+is_redhat_based && nfsserver_redhat_meta_data
+)
+
</parameters>
<actions>
@@ -272,7 +200,8 @@ fi
##
# EXEC_MODE values
# 1 user init script or default init script
-# 2 systemd
+# 2 systemd (with nfs-lock.service)
+# 3 systemd (with rpc-statd.service)
#
# On error, this function will terminate the process
# with error code $OCF_ERR_INSTALLED
@@ -307,7 +236,7 @@ set_exec_mode()
fi
##
- # Last of all, attempt systemd.
+ # Attempt systemd (with nfs-lock.service).
##
if which systemctl > /dev/null 2>&1; then
if systemctl list-unit-files | grep nfs-server > /dev/null && systemctl list-unit-files | grep nfs-lock > /dev/null; then
@@ -317,6 +246,16 @@ set_exec_mode()
fi
fi
+ ##
+ # Attempt systemd (with rpc-statd.service).
+ ##
+ if which systemctl > /dev/null 2>&1; then
+ if systemctl list-unit-files | grep nfs-server > /dev/null && systemctl list-unit-files | grep rpc-statd > /dev/null; then
+ EXEC_MODE=3
+ return 0
+ fi
+ fi
+
ocf_exit_reason "No init script or systemd unit file detected for nfs server"
exit $OCF_ERR_INSTALLED
}
@@ -332,6 +271,7 @@ nfs_exec()
case $EXEC_MODE in
1) ${OCF_RESKEY_nfs_init_script} $cmd;;
2) systemctl $cmd nfs-server.service ;;
+ 3) systemctl $cmd nfs-server.service ;;
esac
}
@@ -342,6 +282,8 @@ v3locking_exec()
if [ $EXEC_MODE -eq 2 ]; then
systemctl $cmd nfs-lock.service
+ elif [ $EXEC_MODE -eq 3 ]; then
+ systemctl $cmd rpc-statd.service
else
case $cmd in
start) locking_start;;
@@ -377,75 +319,6 @@ nfsserver_monitor ()
fi
}
-set_arg()
-{
- local key="$1"
- local value="$2"
- local file="$3"
- local requires_sysconfig="$4"
-
- if [ -z "$value" ]; then
- return
- fi
-
- # only write to the tmp /etc/sysconfig/nfs if sysconfig exists.
- # otherwise this distro does not support setting these options.
- if [ -d "/etc/sysconfig" ]; then
- echo "${key}=\"${value}\"" >> $file
- elif [ "$requires_sysconfig" = "true" ]; then
- ocf_log warn "/etc/sysconfig/nfs not found, unable to set port and nfsd args."
- fi
-
- export ${key}="${value}"
-}
-
-set_env_args()
-{
- local tmpconfig=$(mktemp ${HA_RSCTMP}/nfsserver-tmp-XXXXX)
- local statd_args
-
- # nfsd args
- set_arg "RPCNFSDARGS" "$OCF_RESKEY_nfsd_args" "$tmpconfig" "true"
-
- # mountd args
- if [ -n "$OCF_RESKEY_mountd_port" ]; then
- set_arg "RPCMOUNTDOPTS" "-p $OCF_RESKEY_mountd_port" "$tmpconfig" "true"
- fi
-
- # statd args. we always want to perform the notify using sm-notify after
- # both rpc.statd and the nfsd daemons are initialized
- statd_args="--no-notify"
- if [ -n "$OCF_RESKEY_statd_outgoing_port" ]; then
- statd_args="$statd_args -o $OCF_RESKEY_statd_outgoing_port"
- fi
- if [ -n "$OCF_RESKEY_statd_port" ]; then
- statd_args="$statd_args -p $OCF_RESKEY_statd_port"
- fi
- set_arg "STATDARG" "$statd_args" "$tmpconfig" "false"
-
- # lockd ports
- set_arg "LOCKD_UDPPORT" "$OCF_RESKEY_lockd_udp_port" "$tmpconfig" "true"
- set_arg "LOCKD_TCPPORT" "$OCF_RESKEY_lockd_tcp_port" "$tmpconfig" "true"
-
- # rquotad_port
- if [ -n "$OCF_RESKEY_rquotad_port" ]; then
- set_arg "RPCRQUOTADOPTS" "-p $OCF_RESKEY_rquotad_port" "$tmpconfig" "true"
- fi
-
- # override local nfs config. preserve previous local config though.
- if [ -s $tmpconfig ]; then
- cat $NFS_SYSCONFIG | grep -e "$NFS_SYSCONFIG_AUTOGEN_TAG"
- if [ $? -ne 0 ]; then
- # backup local nfs config if it doesn't have our HA autogen tag in it.
- mv -f $NFS_SYSCONFIG $NFS_SYSCONFIG_LOCAL_BACKUP
- fi
- echo "# $NFS_SYSCONFIG_AUTOGEN_TAG" > $NFS_SYSCONFIG
- echo "# local config backup stored here, '$NFS_SYSCONFIG_LOCAL_BACKUP'" >> $NFS_SYSCONFIG
- cat $tmpconfig >> $NFS_SYSCONFIG
- fi
- rm -f $tmpconfig
-}
-
prepare_directory ()
{
if [ -z "$fp" ]; then
@@ -460,14 +333,15 @@ prepare_directory ()
[ -d "$fp/$STATD_DIR/sm" ] || mkdir -p "$fp/$STATD_DIR/sm"
[ -d "$fp/$STATD_DIR/sm.ha" ] || mkdir -p "$fp/$STATD_DIR/sm.ha"
[ -d "$fp/$STATD_DIR/sm.bak" ] || mkdir -p "$fp/$STATD_DIR/sm.bak"
- [ -n "`id -u rpcuser`" -a "`id -g rpcuser`" ] && chown -R rpcuser.rpcuser "$fp/$STATD_DIR"
+ [ -n "`id -u rpcuser 2>/dev/null`" -a "`id -g rpcuser 2>/dev/null`" ] &&
+ chown -R rpcuser.rpcuser "$fp/$STATD_DIR"
[ -f "$fp/etab" ] || touch "$fp/etab"
[ -f "$fp/xtab" ] || touch "$fp/xtab"
[ -f "$fp/rmtab" ] || touch "$fp/rmtab"
- dd if=/dev/urandom of=$fp/$STATD_DIR/state bs=1 count=4 &> /dev/null
- [ -n "`id -u rpcuser`" -a "`id -g rpcuser`" ] && chown rpcuser.rpcuser "$fp/$STATD_DIR/state"
+ dd if=/dev/urandom of=$fp/$STATD_DIR/state bs=1 count=4 >/dev/null 2>&1
+ [ -n "`id -u rpcuser 2>/dev/null`" -a "`id -g rpcuser 2>/dev/null`" ] && chown rpcuser.rpcuser "$fp/$STATD_DIR/state"
[ $SELINUX_ENABLED -eq 0 ] && chcon -R "$SELINUX_LABEL" "$fp"
}
@@ -539,22 +413,22 @@ locking_start()
ocf_log err "Failed to start rpc.statd"
return $ret
fi
- touch /var/lock/subsys/nfslock
+ [ -d /var/lock/subsys ] && touch /var/lock/subsys/nfslock
return $ret
}
terminate()
{
- declare pids
- declare i=0
+ local pids
+ local i=0
while : ; do
pids=$(binary_status $1)
[ -z "$pids" ] && return 0
kill $pids
sleep 1
- ((i++))
+ i=$((i + 1))
[ $i -gt 3 ] && return 1
done
}
@@ -562,22 +436,22 @@ terminate()
killkill()
{
- declare pids
- declare i=0
+ local pids
+ local i=0
while : ; do
pids=$(binary_status $1)
[ -z "$pids" ] && return 0
kill -9 $pids
sleep 1
- ((i++))
+ i=$((i + 1))
[ $i -gt 3 ] && return 1
done
}
stop_process()
{
- declare process=$1
+ local process=$1
ocf_log info "Stopping $process"
if terminate $process; then
@@ -655,7 +529,7 @@ nfsserver_start ()
return $OCF_SUCCESS
fi
- set_env_args
+ is_redhat_based && set_env_args
prepare_directory
bind_tree
diff --git a/heartbeat/nfsserver-redhat.sh b/heartbeat/nfsserver-redhat.sh
new file mode 100644
index 0000000..cef0862
--- /dev/null
+++ b/heartbeat/nfsserver-redhat.sh
@@ -0,0 +1,169 @@
+NFS_SYSCONFIG="/etc/sysconfig/nfs"
+NFS_SYSCONFIG_LOCAL_BACKUP="/etc/sysconfig/nfs.ha.bu"
+NFS_SYSCONFIG_AUTOGEN_TAG="AUTOGENERATED by $0 high availability resource-agent"
+
+nfsserver_redhat_meta_data() {
+cat<<EOF
+<parameter name="nfsd_args" unique="0" required="0">
+<longdesc lang="en">
+Specifies what arguments to pass to the nfs daemon on startup. View the rpc.nfsd man page for information on what arguments are available.
+Note that setting this value will override all settings placed in the local /etc/sysconfig/nfs file.
+</longdesc>
+<shortdesc lang="en">
+rpc.nfsd options
+</shortdesc>
+<content type="string" />
+</parameter>
+
+<parameter name="lockd_udp_port" unique="0" required="0">
+<longdesc lang="en">
+The udp port lockd should listen on.
+Note that setting this value will override all settings placed in the local /etc/sysconfig/nfs file.
+</longdesc>
+<shortdesc lang="en">
+lockd udp port
+</shortdesc>
+<content type="integer" />
+</parameter>
+
+<parameter name="lockd_tcp_port" unique="0" required="0">
+<longdesc lang="en">
+The tcp port lockd should listen on.
+Note that setting this value will override all settings placed in the local /etc/sysconfig/nfs file.
+</longdesc>
+<shortdesc lang="en">
+lockd tcp port
+</shortdesc>
+<content type="integer" />
+</parameter>
+
+<parameter name="statd_outgoing_port" unique="0" required="0">
+<longdesc lang="en">
+The source port number sm-notify uses when sending reboot notifications.
+Note that setting this value will override all settings placed in the local /etc/sysconfig/nfs file.
+</longdesc>
+<shortdesc lang="en">
+sm-notify source port
+</shortdesc>
+<content type="integer" />
+</parameter>
+
+<parameter name="statd_port" unique="0" required="0">
+<longdesc lang="en">
+The port number used for RPC listener sockets.
+Note that setting this value will override all settings placed in the local /etc/sysconfig/nfs file.
+</longdesc>
+<shortdesc lang="en">
+rpc.statd listener port
+</shortdesc>
+<content type="integer" />
+</parameter>
+
+<parameter name="mountd_port" unique="0" required="0">
+<longdesc lang="en">
+The port number used for rpc.mountd listener sockets.
+Note that setting this value will override all settings placed in the local /etc/sysconfig/nfs file.
+</longdesc>
+<shortdesc lang="en">
+rpc.mountd listener port
+</shortdesc>
+<content type="integer" />
+</parameter>
+
+<parameter name="rquotad_port" unique="0" required="0">
+<longdesc lang="en">
+The port number used for rpc.rquotad.
+Note that setting this value will override all settings placed in the local /etc/sysconfig/nfs file.
+</longdesc>
+<shortdesc lang="en">
+rpc.rquotad port
+</shortdesc>
+<content type="integer" />
+</parameter>
+EOF
+}
+
+set_arg()
+{
+ local key="$1"
+ local value="$2"
+ local file="$3"
+ local requires_sysconfig="$4"
+
+ if [ -z "$value" ]; then
+ return
+ fi
+
+ # only write to the tmp /etc/sysconfig/nfs if sysconfig exists.
+ # otherwise this distro does not support setting these options.
+ if [ -d "/etc/sysconfig" ]; then
+ # replace if the value exists, append otherwise
+ if grep "^\s*${key}=" $file ; then
+ sed -i "s/\s*${key}=.*$/${key}=\"${value}\"/" $file
+ else
+ echo "${key}=\"${value}\"" >> $file
+ fi
+ elif [ "$requires_sysconfig" = "true" ]; then
+ ocf_log warn "/etc/sysconfig/nfs not found, unable to set port and nfsd args."
+ fi
+
+ export ${key}="${value}"
+}
+
+set_env_args()
+{
+ local tmpconfig=$(mktemp ${HA_RSCTMP}/nfsserver-tmp-XXXXX)
+ local statd_args
+
+ if [ -f "$NFS_SYSCONFIG" ]; then
+ ## Take the $NFS_SYSCONFIG file as our skeleton
+ cp $NFS_SYSCONFIG $tmpconfig
+ fi
+
+ # nfsd args
+ set_arg "RPCNFSDARGS" "$OCF_RESKEY_nfsd_args" "$tmpconfig" "true"
+
+ # mountd args
+ if [ -n "$OCF_RESKEY_mountd_port" ]; then
+ set_arg "RPCMOUNTDOPTS" "-p $OCF_RESKEY_mountd_port" "$tmpconfig" "true"
+ fi
+
+ # statd args. we always want to perform the notify using sm-notify after
+ # both rpc.statd and the nfsd daemons are initialized
+ statd_args="--no-notify"
+ if [ -n "$OCF_RESKEY_statd_outgoing_port" ]; then
+ statd_args="$statd_args -o $OCF_RESKEY_statd_outgoing_port"
+ fi
+ if [ -n "$OCF_RESKEY_statd_port" ]; then
+ statd_args="$statd_args -p $OCF_RESKEY_statd_port"
+ fi
+ set_arg "STATDARG" "$statd_args" "$tmpconfig" "false"
+
+ # lockd ports
+ set_arg "LOCKD_UDPPORT" "$OCF_RESKEY_lockd_udp_port" "$tmpconfig" "true"
+ set_arg "LOCKD_TCPPORT" "$OCF_RESKEY_lockd_tcp_port" "$tmpconfig" "true"
+
+ # rquotad_port
+ if [ -n "$OCF_RESKEY_rquotad_port" ]; then
+ set_arg "RPCRQUOTADOPTS" "-p $OCF_RESKEY_rquotad_port" "$tmpconfig" "true"
+ fi
+
+ # override local nfs config. preserve previous local config though.
+ if [ -s $tmpconfig ]; then
+ cat $NFS_SYSCONFIG | grep -q -e "$NFS_SYSCONFIG_AUTOGEN_TAG" > /dev/null 2>&1
+ if [ $? -ne 0 ]; then
+ # backup local nfs config if it doesn't have our HA autogen tag in it.
+ mv -f $NFS_SYSCONFIG $NFS_SYSCONFIG_LOCAL_BACKUP
+ fi
+
+ cat $tmpconfig | grep -q -e "$NFS_SYSCONFIG_AUTOGEN_TAG" > /dev/null 2>&1
+ if [ $? -ne 0 ]; then
+ echo "# $NFS_SYSCONFIG_AUTOGEN_TAG" > $NFS_SYSCONFIG
+ echo "# local config backup stored here, '$NFS_SYSCONFIG_LOCAL_BACKUP'" >> $NFS_SYSCONFIG
+ cat $tmpconfig >> $NFS_SYSCONFIG
+ else
+ cat $tmpconfig > $NFS_SYSCONFIG
+ fi
+ fi
+ rm -f $tmpconfig
+}
diff --git a/heartbeat/ocf-distro b/heartbeat/ocf-distro
new file mode 100644
index 0000000..530ee57
--- /dev/null
+++ b/heartbeat/ocf-distro
@@ -0,0 +1,47 @@
+#
+# This is OCF Linux distribution query support
+#
+# Currently needed for the nfsserver RA which has some already
+# released RH specific stuff (/etc/sysconfig/nfs editing)
+#
+
+_DEBIAN_VERSION_FILE="/etc/debian_version"
+_REDHAT_RELEASE_FILE="/etc/redhat-release"
+_SUSE_RELEASE_FILE="/etc/SuSE-release"
+_RELEASE_FILES="/etc/*-release"
+_REDHAT_BASED_DISTROS_RE='red *hat|fedora|centos|scientific linux'
+
+get_release_id() {
+ if which lsb_release >/dev/null 2>&1; then
+ lsb_release -si
+ elif [ -e $_DEBIAN_VERSION_FILE ]; then
+ echo Debian
+ elif [ -e $_SUSE_RELEASE_FILE ]; then
+ echo SUSE
+ elif [ -e $_REDHAT_RELEASE_FILE ]; then
+ echo Redhat
+ else # FIXME not exactly the id here, but will do for our purpose
+ cat $_RELEASE_FILES 2>/dev/null
+ fi
+}
+
+is_redhat_based() {
+ get_release_id | egrep -qsi "$_REDHAT_BASED_DISTROS_RE"
+}
+
+# get_os_ver() is currently unused
+get_os_ver() {
+ if which lsb_release >/dev/null 2>&1; then
+ OS=`lsb_release -si`
+ VER=`lsb_release -sr`
+ elif [ -f $_DEBIAN_VERSION_FILE ]; then
+ OS=Debian
+ VER=$(cat $_DEBIAN_VERSION_FILE)
+ elif [ -f $_REDHAT_RELEASE_FILE ]; then
+ OS=RedHat # redhat or similar
+ VER= # here some complex sed script
+ else
+ OS=$(uname -s)
+ VER=$(uname -r)
+ fi
+}
diff --git a/heartbeat/ocf-shellfuncs.in b/heartbeat/ocf-shellfuncs.in
index 2023661..2f5f684 100644
--- a/heartbeat/ocf-shellfuncs.in
+++ b/heartbeat/ocf-shellfuncs.in
@@ -57,6 +57,7 @@ fi
. ${OCF_FUNCTIONS_DIR}/ocf-returncodes
. ${OCF_FUNCTIONS_DIR}/ocf-directories
. ${OCF_FUNCTIONS_DIR}/ocf-rarun
+. ${OCF_FUNCTIONS_DIR}/ocf-distro
# Define OCF_RESKEY_CRM_meta_interval in case it isn't already set,
# to make sure that ocf_is_probe() always works
--
2.6.4