You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

54 lines
2.0 KiB

diff -uNr a/heartbeat/nfsserver b/heartbeat/nfsserver
--- a/heartbeat/nfsserver 2016-10-28 10:51:35.357385160 +0200
+++ b/heartbeat/nfsserver 2016-10-28 13:22:16.844380108 +0200
@@ -434,7 +434,12 @@
# 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
+ # 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
@@ -447,6 +452,11 @@
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"
@@ -477,14 +487,20 @@
# override local nfs config. preserve previous local config though.
if [ -s $tmpconfig ]; then
- cat $NFS_SYSCONFIG | grep -e "$NFS_SYSCONFIG_AUTOGEN_TAG"
+ 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
- echo "# $NFS_SYSCONFIG_AUTOGEN_TAG" > $NFS_SYSCONFIG
- echo "# local config backup stored here, '$NFS_SYSCONFIG_LOCAL_BACKUP'" >> $NFS_SYSCONFIG
- cat $tmpconfig >> $NFS_SYSCONFIG
+
+ 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
}