diff --git a/heartbeat/nfsserver-redhat.sh b/heartbeat/nfsserver-redhat.sh index cef0862ee..73a70c186 100644 --- a/heartbeat/nfsserver-redhat.sh +++ b/heartbeat/nfsserver-redhat.sh @@ -1,169 +1,171 @@ 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< 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. rpc.nfsd options The udp port lockd should listen on. Note that setting this value will override all settings placed in the local /etc/sysconfig/nfs file. lockd udp port The tcp port lockd should listen on. Note that setting this value will override all settings placed in the local /etc/sysconfig/nfs file. lockd tcp port 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. sm-notify source port 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. rpc.statd listener port 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. rpc.mountd listener port The port number used for rpc.rquotad. Note that setting this value will override all settings placed in the local /etc/sysconfig/nfs file. rpc.rquotad port 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 + if [ -f "$NFS_SYSCONFIG" ]; 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 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 }