|
|
261ad6 |
From 6900fcb7b014bd0177c44f20447caca4658b45c6 Mon Sep 17 00:00:00 2001
|
|
|
261ad6 |
From: David Vossel <dvossel@redhat.com>
|
|
|
261ad6 |
Date: Wed, 29 Apr 2015 11:12:23 -0500
|
|
|
261ad6 |
Subject: [PATCH 2/6] nfsserver updates
|
|
|
261ad6 |
|
|
|
261ad6 |
---
|
|
|
261ad6 |
heartbeat/nfsserver | 51 ++++++++++++++++++++++++++++++++++-----------------
|
|
|
261ad6 |
1 file changed, 34 insertions(+), 17 deletions(-)
|
|
|
261ad6 |
|
|
|
261ad6 |
diff --git a/heartbeat/nfsserver b/heartbeat/nfsserver
|
|
|
261ad6 |
index de1a802..33cb607 100755
|
|
|
261ad6 |
--- a/heartbeat/nfsserver
|
|
|
261ad6 |
+++ b/heartbeat/nfsserver
|
|
|
261ad6 |
@@ -208,9 +208,9 @@ The mount point for the sunrpc file system.
|
|
|
261ad6 |
</parameters>
|
|
|
261ad6 |
|
|
|
261ad6 |
<actions>
|
|
|
261ad6 |
-<action name="start" timeout="40" />
|
|
|
261ad6 |
-<action name="stop" timeout="20s" />
|
|
|
261ad6 |
-<action name="monitor" depth="0" timeout="20s" interval="10" />
|
|
|
261ad6 |
+<action name="start" timeout="90" />
|
|
|
261ad6 |
+<action name="stop" timeout="60s" />
|
|
|
261ad6 |
+<action name="monitor" depth="0" timeout="30s" interval="10" />
|
|
|
261ad6 |
<action name="meta-data" timeout="5" />
|
|
|
261ad6 |
<action name="validate-all" timeout="30" />
|
|
|
261ad6 |
</actions>
|
|
|
261ad6 |
@@ -391,7 +391,12 @@ set_arg()
|
|
|
261ad6 |
# only write to the tmp /etc/sysconfig/nfs if sysconfig exists.
|
|
|
261ad6 |
# otherwise this distro does not support setting these options.
|
|
|
261ad6 |
if [ -d "/etc/sysconfig" ]; then
|
|
|
261ad6 |
- echo "${key}=\"${value}\"" >> $file
|
|
|
261ad6 |
+ # replace if the value exists, append otherwise
|
|
|
261ad6 |
+ if grep "^\s*${key}=" $file ; then
|
|
|
261ad6 |
+ sed -i "s/\s*${key}=.*$/${key}=\"${value}\"/" $file
|
|
|
261ad6 |
+ else
|
|
|
261ad6 |
+ echo "${key}=\"${value}\"" >> $file
|
|
|
261ad6 |
+ fi
|
|
|
261ad6 |
elif [ "$requires_sysconfig" = "true" ]; then
|
|
|
261ad6 |
ocf_log warn "/etc/sysconfig/nfs not found, unable to set port and nfsd args."
|
|
|
261ad6 |
fi
|
|
|
261ad6 |
@@ -404,6 +409,11 @@ set_env_args()
|
|
|
261ad6 |
local tmpconfig=$(mktemp ${HA_RSCTMP}/nfsserver-tmp-XXXXX)
|
|
|
261ad6 |
local statd_args
|
|
|
261ad6 |
|
|
|
261ad6 |
+ if [ -f "$NFS_SYSCONFIG" ]; then
|
|
|
261ad6 |
+ ## Take the $NFS_SYSCONFIG file as our skeleton
|
|
|
261ad6 |
+ cp $NFS_SYSCONFIG $tmpconfig
|
|
|
261ad6 |
+ fi
|
|
|
261ad6 |
+
|
|
|
261ad6 |
# nfsd args
|
|
|
261ad6 |
set_arg "RPCNFSDARGS" "$OCF_RESKEY_nfsd_args" "$tmpconfig" "true"
|
|
|
261ad6 |
|
|
|
261ad6 |
@@ -434,14 +444,20 @@ set_env_args()
|
|
|
261ad6 |
|
|
|
261ad6 |
# override local nfs config. preserve previous local config though.
|
|
|
261ad6 |
if [ -s $tmpconfig ]; then
|
|
|
261ad6 |
- cat $NFS_SYSCONFIG | grep -e "$NFS_SYSCONFIG_AUTOGEN_TAG"
|
|
|
261ad6 |
+ cat $NFS_SYSCONFIG | grep -q -e "$NFS_SYSCONFIG_AUTOGEN_TAG" > /dev/null 2>&1
|
|
|
261ad6 |
if [ $? -ne 0 ]; then
|
|
|
261ad6 |
# backup local nfs config if it doesn't have our HA autogen tag in it.
|
|
|
261ad6 |
mv -f $NFS_SYSCONFIG $NFS_SYSCONFIG_LOCAL_BACKUP
|
|
|
261ad6 |
fi
|
|
|
261ad6 |
- echo "# $NFS_SYSCONFIG_AUTOGEN_TAG" > $NFS_SYSCONFIG
|
|
|
261ad6 |
- echo "# local config backup stored here, '$NFS_SYSCONFIG_LOCAL_BACKUP'" >> $NFS_SYSCONFIG
|
|
|
261ad6 |
- cat $tmpconfig >> $NFS_SYSCONFIG
|
|
|
261ad6 |
+
|
|
|
261ad6 |
+ cat $tmpconfig | grep -q -e "$NFS_SYSCONFIG_AUTOGEN_TAG" > /dev/null 2>&1
|
|
|
261ad6 |
+ if [ $? -ne 0 ]; then
|
|
|
261ad6 |
+ echo "# $NFS_SYSCONFIG_AUTOGEN_TAG" > $NFS_SYSCONFIG
|
|
|
261ad6 |
+ echo "# local config backup stored here, '$NFS_SYSCONFIG_LOCAL_BACKUP'" >> $NFS_SYSCONFIG
|
|
|
261ad6 |
+ cat $tmpconfig >> $NFS_SYSCONFIG
|
|
|
261ad6 |
+ else
|
|
|
261ad6 |
+ cat $tmpconfig > $NFS_SYSCONFIG
|
|
|
261ad6 |
+ fi
|
|
|
261ad6 |
fi
|
|
|
261ad6 |
rm -f $tmpconfig
|
|
|
261ad6 |
}
|
|
|
261ad6 |
@@ -460,13 +476,14 @@ prepare_directory ()
|
|
|
261ad6 |
[ -d "$fp/$STATD_DIR/sm" ] || mkdir -p "$fp/$STATD_DIR/sm"
|
|
|
261ad6 |
[ -d "$fp/$STATD_DIR/sm.ha" ] || mkdir -p "$fp/$STATD_DIR/sm.ha"
|
|
|
261ad6 |
[ -d "$fp/$STATD_DIR/sm.bak" ] || mkdir -p "$fp/$STATD_DIR/sm.bak"
|
|
|
261ad6 |
- [ -n "`id -u rpcuser`" -a "`id -g rpcuser`" ] && chown -R rpcuser.rpcuser "$fp/$STATD_DIR"
|
|
|
261ad6 |
+ [ -n "`id -u rpcuser 2>/dev/null`" -a "`id -g rpcuser 2>/dev/null`" ] &&
|
|
|
261ad6 |
+ chown -R rpcuser.rpcuser "$fp/$STATD_DIR"
|
|
|
261ad6 |
|
|
|
261ad6 |
[ -f "$fp/etab" ] || touch "$fp/etab"
|
|
|
261ad6 |
[ -f "$fp/xtab" ] || touch "$fp/xtab"
|
|
|
261ad6 |
[ -f "$fp/rmtab" ] || touch "$fp/rmtab"
|
|
|
261ad6 |
|
|
|
261ad6 |
- dd if=/dev/urandom of=$fp/$STATD_DIR/state bs=1 count=4 &> /dev/null
|
|
|
261ad6 |
+ dd if=/dev/urandom of=$fp/$STATD_DIR/state bs=1 count=4 >/dev/null 2>&1
|
|
|
261ad6 |
[ -n "`id -u rpcuser`" -a "`id -g rpcuser`" ] && chown rpcuser.rpcuser "$fp/$STATD_DIR/state"
|
|
|
261ad6 |
[ $SELINUX_ENABLED -eq 0 ] && chcon -R "$SELINUX_LABEL" "$fp"
|
|
|
261ad6 |
}
|
|
|
261ad6 |
@@ -546,15 +563,15 @@ locking_start()
|
|
|
261ad6 |
|
|
|
261ad6 |
terminate()
|
|
|
261ad6 |
{
|
|
|
261ad6 |
- declare pids
|
|
|
261ad6 |
- declare i=0
|
|
|
261ad6 |
+ local pids
|
|
|
261ad6 |
+ local i=0
|
|
|
261ad6 |
|
|
|
261ad6 |
while : ; do
|
|
|
261ad6 |
pids=$(binary_status $1)
|
|
|
261ad6 |
[ -z "$pids" ] && return 0
|
|
|
261ad6 |
kill $pids
|
|
|
261ad6 |
sleep 1
|
|
|
261ad6 |
- ((i++))
|
|
|
261ad6 |
+ i=$((i + 1))
|
|
|
261ad6 |
[ $i -gt 3 ] && return 1
|
|
|
261ad6 |
done
|
|
|
261ad6 |
}
|
|
|
261ad6 |
@@ -562,22 +579,22 @@ terminate()
|
|
|
261ad6 |
|
|
|
261ad6 |
killkill()
|
|
|
261ad6 |
{
|
|
|
261ad6 |
- declare pids
|
|
|
261ad6 |
- declare i=0
|
|
|
261ad6 |
+ local pids
|
|
|
261ad6 |
+ local i=0
|
|
|
261ad6 |
|
|
|
261ad6 |
while : ; do
|
|
|
261ad6 |
pids=$(binary_status $1)
|
|
|
261ad6 |
[ -z "$pids" ] && return 0
|
|
|
261ad6 |
kill -9 $pids
|
|
|
261ad6 |
sleep 1
|
|
|
261ad6 |
- ((i++))
|
|
|
261ad6 |
+ i=$((i + 1))
|
|
|
261ad6 |
[ $i -gt 3 ] && return 1
|
|
|
261ad6 |
done
|
|
|
261ad6 |
}
|
|
|
261ad6 |
|
|
|
261ad6 |
stop_process()
|
|
|
261ad6 |
{
|
|
|
261ad6 |
- declare process=$1
|
|
|
261ad6 |
+ local process=$1
|
|
|
261ad6 |
|
|
|
261ad6 |
ocf_log info "Stopping $process"
|
|
|
261ad6 |
if terminate $process; then
|
|
|
261ad6 |
--
|
|
|
261ad6 |
1.8.4.2
|
|
|
261ad6 |
|