diff --git a/heartbeat/exportfs b/heartbeat/exportfs index 00d7d53b6..095b732b6 100755 --- a/heartbeat/exportfs +++ b/heartbeat/exportfs @@ -1,356 +1,367 @@ #!/bin/sh # exportfs # # Description: Manages nfs exported file system. # # (c) 2010 Ben Timby, Florian Haas, Dejan Muhamedagic, # and Linux-HA contributors # # License: GNU General Public License v2 (GPLv2) and later ####################################################################### # Initialization: : ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat} . ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs # Defaults OCF_RESKEY_unlock_on_stop_default=1 OCF_RESKEY_wait_for_leasetime_on_stop_default=0 OCF_RESKEY_rmtab_backup_default=".rmtab" : ${OCF_RESKEY_unlock_on_stop=${OCF_RESKEY_unlock_on_stop_default}} : ${OCF_RESKEY_wait_for_leasetime_on_stop=${OCF_RESKEY_wait_for_leasetime_on_stop_default}} : ${OCF_RESKEY_rmtab_backup=${OCF_RESKEY_rmtab_backup_default}} ####################################################################### exportfs_meta_data() { cat < 1.0 Exportfs uses the exportfs command to add/remove nfs exports. It does NOT manage the nfs server daemon. It depends on Linux specific NFS implementation details, so is considered not portable to other platforms yet. Manages NFS exports The client specification allowing remote machines to mount the directory over NFS. Client ACL. The options to pass to exportfs for the exported directory. Export options. The directory which you wish to export using NFS. The directory to export. The fsid option to pass to exportfs. This can be a unique positive integer, a UUID, or the special string "root" which is functionally identical to numeric fsid of 0. 0 (root) identifies the export as the root of an NFSv4 pseudofilesystem -- avoid this setting unless you understand its special status. This value will override any fsid provided via the options parameter. Unique fsid within cluster. Relinquish NFS locks associated with this filesystem when the resource stops. Enabling this parameter is highly recommended unless the path exported by this ${__SCRIPT_NAME} resource is also exported by a different resource. Note: Unlocking is only possible on Linux systems where /proc/fs/nfsd/unlock_filesystem exists and is writable. If your system does not fulfill this requirement (on account of having an nonrecent kernel, for example), you may set this parameter to 0 to silence the associated warning. Unlock filesystem on stop? When stopping (unexporting), wait out the NFSv4 lease time. Only after all leases have expired does the NFS kernel server relinquish all server-side handles on the exported filesystem. If this ${__SCRIPT_NAME} resource manages an export that resides on a mount point designed to fail over along with the NFS export itself, then enabling this parameter will ensure such failover is working properly. Note that when this parameter is set, your stop timeout MUST accommodate for the wait period. This parameter is safe to disable if none of your NFS clients are using NFS version 4 or later. Ride out the NFSv4 lease time on resource stop? Back up those entries from the NFS rmtab that apply to the exported directory, to the specified backup file. The filename is interpreted as relative to the exported directory. This backup is required if clients are connecting to the export via NFSv3 over TCP. Note that a configured monitor operation is required for this functionality. To disable rmtab backups, set this parameter to the special string "none". Location of the rmtab backup, relative to directory. - + END return $OCF_SUCCESS } exportfs_methods() { cat <<-! start stop status monitor validate-all methods meta-data usage ! } backup_rmtab() { local rmtab_backup if [ ${OCF_RESKEY_rmtab_backup} != "none" ]; then rmtab_backup="${OCF_RESKEY_directory}/${OCF_RESKEY_rmtab_backup}" grep ":${OCF_RESKEY_directory}:" /var/lib/nfs/rmtab > ${rmtab_backup} fi } restore_rmtab() { local rmtab_backup if [ ${OCF_RESKEY_rmtab_backup} != "none" ]; then rmtab_backup="${OCF_RESKEY_directory}/${OCF_RESKEY_rmtab_backup}" if [ -r ${rmtab_backup} ]; then local tmpf=`mktemp` sort -u ${rmtab_backup} /var/lib/nfs/rmtab > $tmpf && install -o root -m 644 $tmpf /var/lib/nfs/rmtab rm -f $tmpf ocf_log debug "Restored `wc -l ${rmtab_backup}` rmtab entries from ${rmtab_backup}." else ocf_log warn "rmtab backup ${rmtab_backup} not found or not readable." fi fi } exportfs_usage() { cat <" instead of # "*" if [ $rc -eq 1 -a "${OCF_RESKEY_clientspec}" = "*" ]; then is_exported "${OCF_RESKEY_directory}" "" rc=$? fi #Adapt grep status code to OCF return code case $rc in 0) - ocf_log info "Directory ${OCF_RESKEY_directory} is exported to ${OCF_RESKEY_clientspec} (started)." + if [ "$__OCF_ACTION" = "start" ]; then + ocf_log info "Directory ${OCF_RESKEY_directory} is exported to ${OCF_RESKEY_clientspec} (started)." + fi # Backup the rmtab to ensure smooth NFS-over-TCP failover backup_rmtab return $OCF_SUCCESS ;; 1) ocf_log info "Directory ${OCF_RESKEY_directory} is not exported to ${OCF_RESKEY_clientspec} (stopped)." return $OCF_NOT_RUNNING;; *) ocf_log err "Unable to determine export status for ${OCF_RESKEY_directory}." return $OCF_ERR_GENERIC;; esac } exportfs_start () { if exportfs_monitor; then ocf_log debug "${OCF_RESKEY_directory} already exported" return $OCF_SUCCESS fi ocf_log info "Exporting file system ..." if [ ${OCF_RESKEY_options} ]; then OPTIONS="${OCF_RESKEY_options}" OPTPREFIX=',' fi if [ `echo ${OPTIONS} | grep fsid` ]; then #replace fsid provided in options list with one provided in fsid param. OPTIONS=`echo ${OPTIONS} | sed "s/fsid=[0-9]\+/fsid=${OCF_RESKEY_fsid}/g"` else #tack the fsid option onto our options list. OPTIONS="${OPTIONS}${OPTPREFIX}fsid=${OCF_RESKEY_fsid}" fi OPTIONS="-o ${OPTIONS}" ocf_run exportfs -v ${OPTIONS} ${OCF_RESKEY_clientspec}:${OCF_RESKEY_directory} || exit $OCF_ERR_GENERIC # Restore the rmtab to ensure smooth NFS-over-TCP failover restore_rmtab ocf_log info "File system exported" return $OCF_SUCCESS } unlock_fs() { local unlockfile unlockfile=/proc/fs/nfsd/unlock_filesystem if [ -w ${unlockfile} ]; then echo "${OCF_RESKEY_directory}" > ${unlockfile} ocf_log info "Unlocked NFS export ${OCF_RESKEY_directory}" else ocf_log warn "Unable to unlock NFS export ${OCF_RESKEY_directory}, ${unlockfile} not found or not writable" fi } wait_for_leasetime() { local leasetimefile local sleeptime leasetimefile=/proc/fs/nfsd/nfsv4leasetime if [ -r ${leasetimefile} ]; then sleeptime=$((`cat ${leasetimefile}`+2)) ocf_log info "Sleeping ${sleeptime} seconds to accommodate for NFSv4 lease expiry" sleep ${sleeptime}s else ocf_log warn "Unable to read NFSv4 lease time from ${leasetimefile}, file not found or not readable" fi } cleanup_export_cache() { # see if the cache is blocking unexport local contentfile=/proc/net/rpc/nfsd.export/content local fsid_re="fsid=$OCF_RESKEY_fsid," local i=1 while :; do fgrep -q "$fsid_re" $contentfile || break ocf_log info "Cleanup export cache ... (try $i)" ocf_run exportfs -f sleep 0.5 let i=$i+1 done } exportfs_stop () { exportfs_monitor if [ $? -eq $OCF_NOT_RUNNING ]; then ocf_log debug "${OCF_RESKEY_directory} not exported" return $OCF_SUCCESS fi ocf_log info "Un-exporting file system ..." # Backup the rmtab to ensure smooth NFS-over-TCP failover backup_rmtab ocf_run exportfs -v -u ${OCF_RESKEY_clientspec}:${OCF_RESKEY_directory} rc=$? if ocf_is_true ${OCF_RESKEY_unlock_on_stop}; then unlock_fs fi if ocf_is_true ${OCF_RESKEY_wait_for_leasetime_on_stop}; then wait_for_leasetime fi if [ $rc -eq 0 ]; then cleanup_export_cache ocf_log info "Un-exported file system" return $OCF_SUCCESS else ocf_log err "Failed to un-export file system" exit $OCF_ERR_GENERIC fi } exportfs_validate_all () { if [ ! -d $OCF_RESKEY_directory ]; then ocf_log err "$OCF_RESKEY_directory does not exist or is not a directory" return $OCF_ERR_INSTALLED fi } +# If someone puts a trailing slash at the end of the export directory, +# this agent is going to fail in some unexpected ways due to how +# export strings are matched. The simplest solution here is to strip off +# a trailing '/' in the directory before processing anything. +newdir=$(echo "$OCF_RESKEY_directory" | sed -n -e 's/^\(.*\)\/$/\1/p') +if [ -n "$newdir" ]; then + OCF_RESKEY_directory=$newdir +fi + OCF_REQUIRED_PARAMS="directory fsid clientspec" OCF_REQUIRED_BINARIES="exportfs" ocf_rarun $* diff --git a/heartbeat/nfsserver b/heartbeat/nfsserver index fdb08316a..288575421 100755 --- a/heartbeat/nfsserver +++ b/heartbeat/nfsserver @@ -1,489 +1,621 @@ #!/bin/sh # nfsserver # # Description: Manages nfs server as OCF resource # by hxinwei@gmail.com # License: GNU General Public License v2 (GPLv2) and later if [ -n "$OCF_DEBUG_LIBRARY" ]; then . $OCF_DEBUG_LIBRARY else : ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat} . ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs fi DEFAULT_INIT_SCRIPT="/etc/init.d/nfsserver" +if ! [ -f $DEFAULT_INIT_SCRIPT ]; then + # On some systems, the script is just called nfs + DEFAULT_INIT_SCRIPT="/etc/init.d/nfs" +fi + DEFAULT_NOTIFY_CMD=`which sm-notify` DEFAULT_NOTIFY_CMD=${DEFAULT_NOTIFY_CMD:-"/sbin/sm-notify"} DEFAULT_NOTIFY_FOREGROUND="false" DEFAULT_RPCPIPEFS_DIR="/var/lib/nfs/rpc_pipefs" EXEC_MODE=0 SELINUX_ENABLED=-1 STATD_PATH="/var/lib/nfs" STATD_DIR="" nfsserver_meta_data() { cat < 1.0 Nfsserver helps to manage the Linux nfs server as a failover-able resource in Linux-HA. It depends on Linux specific NFS implementation details, so is considered not portable to other platforms yet. Manages an NFS server The default init script shipped with the Linux distro. The nfsserver resource agent offloads the start/stop/monitor work to the init script because the procedure to start/stop/monitor nfsserver varies on different Linux distro. In the event that this option is not set, this agent will attempt to use an init script at this location, ${DEFAULT_INIT_SCRIPT}, or detect a systemd unit-file to use in the event that no init script is detected. Init script for nfsserver - + -The tool to send out NSM reboot notification; it should be either sm-notify or rpc.statd. -Failover of nfsserver can be considered as rebooting to different machines. -The nfsserver resource agent use this command to notify all clients about the occurrence of failover. +Keeps the sm-notify attached to its controlling terminal and running in the foreground. -The tool to send out notification. +Keeps the notify tool running in the foreground. - + - + -Keeps the notify tool attached to its controlling terminal and running in the foreground. +Comma separated list of floating IP addresses used to access the nfs service -Keeps the notify tool running in the foreground. +IP addresses. - + Specifies the length of sm-notify retry time, in minutes, to continue retrying notifications to unresponsive hosts. If this option is not specified, sm-notify attempts to send notifications for 15 minutes. Specifying a value of 0 causes sm-notify to continue sending notifications to unresponsive peers until it is manually killed. Specifies the length of sm-notify retry time (minutes). The nfsserver resource agent will save nfs related information in this specific directory. And this directory must be able to fail-over before nfsserver itself. Directory to store nfs server related information. - - -Comma separated list of floating IP addresses used to access the nfs service - - -IP addresses. - - - - The mount point for the sunrpc file system. Default is $DEFAULT_RPCPIPEFS_DIR. This script will mount (bind) nfs_shared_infodir on /var/lib/nfs/ (cannot be changed), and this script will mount the sunrpc file system on $DEFAULT_RPCPIPEFS_DIR (default, can be changed by this parameter). If you want to move only rpc_pipefs/ (e.g. to keep rpc_pipefs/ local) from default, please set this value. The mount point for the sunrpc file system. END return $OCF_SUCCESS } nfsserver_usage() { cat < /dev/null 2>&1 && selinuxenabled SELINUX_ENABLED=$? if [ $SELINUX_ENABLED -eq 0 ]; then export SELINUX_LABEL="$(ls -ldZ $STATD_PATH | cut -f4 -d' ')" fi ## # EXEC_MODE values # 1 user init script or default init script # 2 systemd # # On error, this function will terminate the process # with error code $OCF_ERR_INSTALLED ## set_exec_mode() { ## # If EXEC_MODE is already set, we don't need to run this function again. ## if [ $EXEC_MODE -ne 0 ]; then return 0; fi ## # If the user defined an init script, It must exist for us to continue ## if [ -n "$OCF_RESKEY_nfs_init_script" ]; then # check_binary will exit the process if init script does not exist check_binary ${OCF_RESKEY_nfs_init_script} EXEC_MODE=1 return 0 fi ## # Check to see if the default init script exists, if so we'll use that. ## if which $DEFAULT_INIT_SCRIPT > /dev/null 2>&1; then OCF_RESKEY_nfs_init_script=$DEFAULT_INIT_SCRIPT EXEC_MODE=1 return 0 fi ## # Last of all, attempt systemd. ## 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 EXEC_MODE=2 + # when using systemd, the nfs-lock service file handles nfsv3 locking daemons for us. return 0 fi fi ocf_log err "No init script or systemd unit file detected for nfs server" exit $OCF_ERR_INSTALLED } -nfs_systemd_exec() -{ - local cmd=$1 - local server_res - local lock_res - - if [ "$cmd" = "stop" ]; then - systemctl $cmd nfs-server.service - server_res=$? - systemctl $cmd nfs-lock.service - lock_res=$? - else - systemctl $cmd nfs-lock.service - lock_res=$? - systemctl $cmd nfs-server.service - server_res=$? - fi - - if [ $lock_res -ne $server_res ]; then - # If one is running and the other isn't, or for whatever other reason - # the return code's aren't the same, this is bad. - ocf_log err "Systemd services nfs-lock and nfs-server are not in the same state after attempting $cmd command" - return $OCF_ERR_GENERIC - fi - return $server_res -} - ## # wrapper for init script and systemd calls. ## nfs_exec() { local cmd=$1 set_exec_mode case $EXEC_MODE in 1) ${OCF_RESKEY_nfs_init_script} $cmd;; - 2) nfs_systemd_exec $cmd;; + 2) systemctl $cmd nfs-server.service esac } +v3locking_exec() +{ + local cmd=$1 + set_exec_mode + + if [ $EXEC_MODE -eq 2 ]; then + systemctl $cmd nfs-lock.service + else + case $cmd in + start) locking_start;; + stop) locking_stop;; + status) locking_status;; + esac + fi +} + nfsserver_monitor () { fn=`mktemp` nfs_exec status > $fn 2>&1 rc=$? ocf_log debug `cat $fn` rm -f $fn -#Adapte LSB status code to OCF return code + #Adapte LSB status code to OCF return code if [ $rc -eq 0 ]; then - return $OCF_SUCCESS + # don't report success if nfs servers are up + # without locking daemons. + v3locking_exec "status" + rc=$? + if [ $rc -ne 0 ]; then + ocf_log error "NFS server is up, but the locking daemons are down" + rc=$OCF_ERR_GENERIC + fi + return $rc elif [ $rc -eq 3 ]; then return $OCF_NOT_RUNNING else return $OCF_ERR_GENERIC fi } prepare_directory () { [ -d "$fp" ] || mkdir -p $fp [ -d "$rpcpipefs_make_dir" ] || mkdir -p $rpcpipefs_make_dir [ -d "$fp/v4recovery" ] || mkdir -p $fp/v4recovery [ -d "$fp/$STATD_DIR" ] || mkdir -p "$fp/$STATD_DIR" [ -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" [ -f "$fp/etab" ] || touch "$fp/etab" [ -f "$fp/xtab" ] || touch "$fp/xtab" [ -f "$fp/rmtab" ] || touch "$fp/rmtab" [ $SELINUX_ENABLED -eq 0 ] && chcon -R "$SELINUX_LABEL" "$fp" } is_bound () { if mount | grep -q "on $1 type"; then return 0 fi return 1 } bind_tree () { if is_bound /var/lib/nfs; then ocf_log debug "$fp is already bound to /var/lib/nfs" return 0 fi mount --bind $fp /var/lib/nfs [ $SELINUX_ENABLED -eq 0 ] && restorecon /var/lib/nfs } unbind_tree () { if `mount | grep -q " on $rpcpipefs_umount_dir"`; then umount -t rpc_pipefs $rpcpipefs_umount_dir fi if is_bound /var/lib/nfs; then umount /var/lib/nfs fi } +binary_status() +{ + local binary=$1 + local pid + + pid=$(pgrep ${binary}) + case $? in + 0) + echo "$pid" + return $OCF_SUCCESS;; + 1) + return $OCF_NOT_RUNNING;; + *) + return $OCF_ERR_GENERIC;; + esac +} + +locking_status() +{ + binary_status "rpc.statd" > /dev/null 2>&1 +} + +locking_start() +{ + local ret=$OCF_SUCCESS + + ocf_log info "Starting rpc.statd." + + if [ -n "$OCF_RESKEY_nfs_ip" ]; then + rm -rf $STATD_PATH/sm.ha.save > /dev/null 2>&1 + cp -rpf $STATD_PATH/sm.ha $STATD_PATH/sm.ha.save > /dev/null 2>&1 + for ip in `echo ${OCF_RESKEY_nfs_ip} | sed 's/,/ /g'`; do + rpc.statd -n $ip -P $STATD_PATH/sm.ha + ret=$? + if [ $ret -eq 0 ]; then + break + fi + rm -rf $STATD_PATH/sm.ha > /dev/null 2>&1 + cp -rpf $STATD_PATH/sm.ha.save $STATD_PATH/sm.ha > /dev/null 2>&1 + done + else + rpc.statd -d + fi + + ret=$? + if [ $ret -ne 0 ]; then + ocf_log err "Failed to start rpc.statd" + return $ret + fi + touch /var/lock/subsys/nfslock + + return $ret +} + +terminate() +{ + declare pids + declare i=0 + + while : ; do + pids=$(binary_status $1) + [ -z "$pids" ] && return 0 + kill $pids + sleep 1 + ((i++)) + [ $i -gt 3 ] && return 1 + done +} + + +killkill() +{ + declare pids + declare i=0 + + while : ; do + pids=$(binary_status $1) + [ -z "$pids" ] && return 0 + kill -9 $pids + sleep 1 + ((i++)) + [ $i -gt 3 ] && return 1 + done +} + +stop_process() +{ + declare process=$1 + + ocf_log info "Stopping $process" + if terminate $process; then + ocf_log debug "$process is stopped" + else + if killkill $process; then + ocf_log debug "$process is stopped" + else + ocf_log debug "Failed to stop $process" + return 1 + fi + fi + return 0 +} + +locking_stop() +{ + ret=0 + + # sm-notify can prevent umount of /var/lib/nfs/statd if + # it is still trying to notify unresponsive clients. + stop_process sm-notify + if [ $? -ne 0]; then + ret=$OCF_ERR_GENERIC + fi + + stop_process rpc.statd + if [ $? -ne 0]; then + ret=$OCF_ERR_GENERIC + fi + + return $ret +} + +renotify_locks() +{ + # run in foreground, if requested + if ocf_is_true "$OCF_RESKEY_nfs_notify_foreground"; then + opts="-d" + fi + + if [ -n "$OCF_RESKEY_nfs_smnotify_retry_time" ]; then + opts="$opts -m $OCF_RESKEY_nfs_smnotify_retry_time" + fi + + # forces re-notificaiton regardless if notifies have already gone out + opts="$opts -f" + + ocf_log info "executing sm-notify" + + if [ -n "$OCF_RESKEY_nfs_ip" ]; then + rm -rf $STATD_PATH/sm.ha.save > /dev/null 2>&1 + cp -rpf $STATD_PATH/sm.ha $STATD_PATH/sm.ha.save > /dev/null 2>&1 + for ip in `echo ${OCF_RESKEY_nfs_ip} | sed 's/,/ /g'`; do + sm-notify $opts -v $ip -P $STATD_PATH/sm.ha + rm -rf $STATD_PATH/sm.ha > /dev/null 2>&1 + cp -rpf $STATD_PATH/sm.ha.save $STATD_PATH/sm.ha > /dev/null 2>&1 + done + else + sm-notify $opts + fi +} + nfsserver_start () { + local notifies_sent=0; + local rc; + if nfsserver_monitor; then ocf_log debug "NFS server is already started" return $OCF_SUCCESS fi prepare_directory bind_tree + # remove the sm-notify pid so sm-notify will be allowed to run again without requiring a reboot. + rm -f /var/run/sm-notify.pid rm -rf $STATD_PATH/sm.ha/* > /dev/null 2>&1 - cp -rf $STATD_PATH/sm $STATD_PATH/sm.bak /var/lib/nfs/state $STATD_PATH/sm.ha > /dev/null 2>&1 + cp -rpf $STATD_PATH/sm $STATD_PATH/sm.bak /var/lib/nfs/state $STATD_PATH/sm.ha > /dev/null 2>&1 ocf_log info "Starting NFS server ..." + # check to see if we need to start rpc.statd + v3locking_exec "status" + if [ $? -ne $OCF_SUCCESS ]; then + v3locking_exec "start" + rc=$? + if [ $rc -ne 0 ]; then + ocf_log error "Failed to start NFS server locking daemons" + return $rc + fi + # rpc.statd sends notifies automatically + notifies_sent=1 + else + ocf_log info "rpc.statd already up" + fi + fn=`mktemp` nfs_exec start > $fn 2>&1 rc=$? ocf_log debug `cat $fn` rm -f $fn if [ $rc -ne 0 ]; then ocf_log err "Failed to start NFS server" return $rc fi - #Notify the nfs server has been moved or rebooted - #The init script do that already, but with the hostname, which may be ignored by client - #we have to do it again with the nfs_ip - local opts - - case ${OCF_RESKEY_nfs_notify_cmd##*/} in - sm-notify) - # run in foreground, if requested - if ocf_is_true "$OCF_RESKEY_nfs_notify_foreground"; then - opts="-d" - fi - - if [ -n "$OCF_RESKEY_nfs_smnotify_retry_time" ]; then - opts="$opts -m $OCF_RESKEY_nfs_smnotify_retry_time" - fi - - opts="$opts -f -v" - ;; - - rpc.statd) - if ocf_is_true "$OCF_RESKEY_nfs_notify_foreground"; then - opts="-F" - fi - opts="$opts -n" - ;; - - esac - - rm -rf $STATD_PATH/sm.ha.save > /dev/null 2>&1 - cp -rf $STATD_PATH/sm.ha $STATD_PATH/sm.ha.save > /dev/null 2>&1 - for ip in `echo ${OCF_RESKEY_nfs_ip} | sed 's/,/ /g'`; do - ${OCF_RESKEY_nfs_notify_cmd} $opts $ip -P $STATD_PATH/sm.ha - rm -rf $STATD_PATH/sm.ha > /dev/null 2>&1 - cp -rf $STATD_PATH/sm.ha.save $STATD_PATH/sm.ha > /dev/null 2>&1 - done - + # notify peers using sm-notify if rpc.statd was already initialized. + # Otherwise the initalization of rpc.statd started sm-notify for us. + if [ $notifies_sent -eq 0 ]; then + renotify_locks + fi ocf_log info "NFS server started" return $OCF_SUCCESS } nfsserver_stop () { ocf_log info "Stopping NFS server ..." fn=`mktemp` nfs_exec stop > $fn 2>&1 rc=$? ocf_log debug `cat $fn` rm -f $fn + v3locking_exec "stop" + if [ $? -ne 0 ]; then + ocf_log err "Failed to stop NFS locking daemons" + rc=$OCF_ERR_GENERIC + fi + if [ $rc -eq 0 ]; then unbind_tree ocf_log info "NFS server stopped" return $OCF_SUCCESS fi ocf_log err "Failed to stop NFS server" return $rc } nfsserver_validate () { ## # set_exec_mode will exit if nfs server is not installed ## set_exec_mode check_binary ${OCF_RESKEY_nfs_notify_cmd} - if [ x = x"${OCF_RESKEY_nfs_ip}" ]; then - ocf_log err "nfs_ip not set" - exit $OCF_ERR_CONFIGURED - fi - if [ x = "x$OCF_RESKEY_nfs_shared_infodir" ]; then ocf_log err "nfs_shared_infodir not set" exit $OCF_ERR_CONFIGURED fi if [ -n "$OCF_RESKEY_nfs_smnotify_retry_time" ]; then if ! ocf_is_decimal "$OCF_RESKEY_nfs_smnotify_retry_time"; then ocf_log err "Invalid nfs_smnotify_retry_time [$OCF_RESKEY_nfs_smnotify_retry_time]" exit $OCF_ERR_CONFIGURED fi fi case ${OCF_RESKEY_nfs_notify_cmd##*/} in sm-notify|rpc.statd) ;; *) ocf_log err "Invalid nfs_notify_cmd [$OCF_RESKEY_nfs_notify_cmd]" exit $OCF_ERR_CONFIGURED ;; esac return $OCF_SUCCESS } if [ -n "$OCF_RESKEY_CRM_meta_clone" ]; then - ocf_log err "THIS RA DO NOT SUPPORT CLONE MODE!" + ocf_log err "THIS RA DOES NOT SUPPORT CLONE MODE!" exit $OCF_ERR_CONFIGURED fi nfsserver_validate case $__OCF_ACTION in start) nfsserver_start ;; stop) nfsserver_stop ;; monitor) nfsserver_monitor ;; validate-all) exit $OCF_SUCCESS ;; *) nfsserver_usage exit $OCF_ERR_UNIMPLEMENTED ;; esac