|
|
4efcdb |
diff -uNr a/heartbeat/nfsserver b/heartbeat/nfsserver
|
|
|
4efcdb |
--- a/heartbeat/nfsserver 2016-02-05 09:04:19.350003826 +0100
|
|
|
4efcdb |
+++ b/heartbeat/nfsserver 2016-02-05 09:04:58.463395839 +0100
|
|
|
4efcdb |
@@ -208,9 +208,9 @@
|
|
|
4efcdb |
</parameters>
|
|
|
4efcdb |
|
|
|
4efcdb |
<actions>
|
|
|
4efcdb |
-<action name="start" timeout="90" />
|
|
|
4efcdb |
-<action name="stop" timeout="60s" />
|
|
|
4efcdb |
-<action name="monitor" depth="0" timeout="30s" interval="10" />
|
|
|
4efcdb |
+<action name="start" timeout="40" />
|
|
|
4efcdb |
+<action name="stop" timeout="20s" />
|
|
|
4efcdb |
+<action name="monitor" depth="0" timeout="20s" interval="10" />
|
|
|
4efcdb |
<action name="meta-data" timeout="5" />
|
|
|
4efcdb |
<action name="validate-all" timeout="30" />
|
|
|
4efcdb |
</actions>
|
|
|
4efcdb |
@@ -327,11 +327,12 @@
|
|
|
4efcdb |
nfs_exec()
|
|
|
4efcdb |
{
|
|
|
4efcdb |
local cmd=$1
|
|
|
4efcdb |
+ local svc=$2
|
|
|
4efcdb |
set_exec_mode
|
|
|
4efcdb |
|
|
|
4efcdb |
case $EXEC_MODE in
|
|
|
4efcdb |
1) ${OCF_RESKEY_nfs_init_script} $cmd;;
|
|
|
4efcdb |
- 2) systemctl $cmd nfs-server.service ;;
|
|
|
4efcdb |
+ 2) systemctl $cmd ${svc}.service ;;
|
|
|
4efcdb |
esac
|
|
|
4efcdb |
}
|
|
|
4efcdb |
|
|
|
4efcdb |
@@ -353,21 +354,117 @@
|
|
|
4efcdb |
|
|
|
4efcdb |
nfsserver_monitor ()
|
|
|
4efcdb |
{
|
|
|
4efcdb |
+ # Skip trying to start processes once before failing
|
|
|
4efcdb |
+ # when run from nfsserver_start ()
|
|
|
4efcdb |
+ if [ "$1" == "fromstart" ]; then
|
|
|
4efcdb |
+ ocf_log info "fromstart"
|
|
|
4efcdb |
+ fromstart=1
|
|
|
4efcdb |
+ else
|
|
|
4efcdb |
+ tries=1
|
|
|
4efcdb |
+ fi
|
|
|
4efcdb |
+
|
|
|
4efcdb |
+ # systemd
|
|
|
4efcdb |
+ if [ "$EXEC_MODE" -eq "2" ]; then
|
|
|
4efcdb |
+ ocf_log info "Status: rpcbind"
|
|
|
4efcdb |
+ rpcinfo &> /dev/null
|
|
|
4efcdb |
+ rc=$?
|
|
|
4efcdb |
+ if [ "$rc" -ne "0" ]; then
|
|
|
4efcdb |
+ if [ ! "$fromstart" ] && [ "$tries" -gt "0" ]; then
|
|
|
4efcdb |
+ nfsserver_start frommonitor
|
|
|
4efcdb |
+ rc=$?
|
|
|
4efcdb |
+ let tries=$tries-1
|
|
|
4efcdb |
+ fi
|
|
|
4efcdb |
+ if [ "$rc" -ne "0" ]; then
|
|
|
4efcdb |
+ ocf_exit_reason "rpcbind is not running"
|
|
|
4efcdb |
+ return $OCF_NOT_RUNNING
|
|
|
4efcdb |
+ fi
|
|
|
4efcdb |
+ fi
|
|
|
4efcdb |
+
|
|
|
4efcdb |
+ ocf_log info "Status: nfs-mountd"
|
|
|
4efcdb |
+ rpcinfo -t localhost 100005 &> /dev/null
|
|
|
4efcdb |
+ rc=$?
|
|
|
4efcdb |
+ if [ "$rc" -ne "0" ]; then
|
|
|
4efcdb |
+ if [ ! "$fromstart" ] && [ "$tries" -gt "0" ]; then
|
|
|
4efcdb |
+ nfsserver_start frommonitor
|
|
|
4efcdb |
+ rc=$?
|
|
|
4efcdb |
+ let tries=$tries-1
|
|
|
4efcdb |
+ fi
|
|
|
4efcdb |
+ if [ "$rc" -ne "0" ]; then
|
|
|
4efcdb |
+ ocf_exit_reason "nfs-mountd is not running"
|
|
|
4efcdb |
+ return $OCF_NOT_RUNNING
|
|
|
4efcdb |
+ fi
|
|
|
4efcdb |
+ fi
|
|
|
4efcdb |
+
|
|
|
4efcdb |
+ ocf_log info "Status: nfs-idmapd"
|
|
|
4efcdb |
+ fn=`mktemp`
|
|
|
4efcdb |
+ nfs_exec status nfs-idmapd > $fn 2>&1
|
|
|
4efcdb |
+ rc=$?
|
|
|
4efcdb |
+ ocf_log debug "$(cat $fn)"
|
|
|
4efcdb |
+ rm -f $fn
|
|
|
4efcdb |
+ if [ "$rc" -ne "0" ]; then
|
|
|
4efcdb |
+ if [ ! "$fromstart" ] && [ "$tries" -gt "0" ]; then
|
|
|
4efcdb |
+ nfsserver_start frommonitor
|
|
|
4efcdb |
+ rc=$?
|
|
|
4efcdb |
+ ocf_log info "Tried to start services: rc: $rc"
|
|
|
4efcdb |
+ let tries=$tries-1
|
|
|
4efcdb |
+ fi
|
|
|
4efcdb |
+ if [ "$rc" -ne "0" ]; then
|
|
|
4efcdb |
+ ocf_exit_reason "nfs-idmapd is not running"
|
|
|
4efcdb |
+ return $OCF_NOT_RUNNING
|
|
|
4efcdb |
+ fi
|
|
|
4efcdb |
+ fi
|
|
|
4efcdb |
+
|
|
|
4efcdb |
+ ocf_log info "Status: rpc-statd"
|
|
|
4efcdb |
+ rpcinfo -t localhost 100024 &> /dev/null
|
|
|
4efcdb |
+ rc=$?
|
|
|
4efcdb |
+ if [ "$rc" -ne "0" ]; then
|
|
|
4efcdb |
+ if [ ! "$fromstart" ] && [ "$tries" -gt "0" ]; then
|
|
|
4efcdb |
+ nfsserver_start frommonitor
|
|
|
4efcdb |
+ rc=$?
|
|
|
4efcdb |
+ let tries=$tries-1
|
|
|
4efcdb |
+ fi
|
|
|
4efcdb |
+ if [ "$rc" -ne "0" ]; then
|
|
|
4efcdb |
+ ocf_exit_reason "rpc-statd is not running"
|
|
|
4efcdb |
+ return $OCF_NOT_RUNNING
|
|
|
4efcdb |
+ fi
|
|
|
4efcdb |
+ fi
|
|
|
4efcdb |
+ fi
|
|
|
4efcdb |
+
|
|
|
4efcdb |
fn=`mktemp`
|
|
|
4efcdb |
- nfs_exec status > $fn 2>&1
|
|
|
4efcdb |
+ nfs_exec status nfs-server > $fn 2>&1
|
|
|
4efcdb |
rc=$?
|
|
|
4efcdb |
ocf_log debug "$(cat $fn)"
|
|
|
4efcdb |
rm -f $fn
|
|
|
4efcdb |
|
|
|
4efcdb |
- #Adapte LSB status code to OCF return code
|
|
|
4efcdb |
+ tfn="/proc/fs/nfsd/threads"
|
|
|
4efcdb |
+ if [ ! -f "$tfn" ] || [ "$(cat $tfn)" -le "0" ]; then
|
|
|
4efcdb |
+ if [ ! "$fromstart" ] && [ "$tries" -gt "0" ]; then
|
|
|
4efcdb |
+ nfsserver_start frommonitor
|
|
|
4efcdb |
+ rc=$?
|
|
|
4efcdb |
+ let tries=$tries-1
|
|
|
4efcdb |
+ fi
|
|
|
4efcdb |
+ if [ "$rc" -ne "0" ]; then
|
|
|
4efcdb |
+ ocf_exit_reason "NFS server not running: /proc/fs/nfsd/threads"
|
|
|
4efcdb |
+ return $OCF_NOT_RUNNING
|
|
|
4efcdb |
+ fi
|
|
|
4efcdb |
+ fi
|
|
|
4efcdb |
+
|
|
|
4efcdb |
+ #Adapt LSB status code to OCF return code
|
|
|
4efcdb |
if [ $rc -eq 0 ]; then
|
|
|
4efcdb |
# don't report success if nfs servers are up
|
|
|
4efcdb |
# without locking daemons.
|
|
|
4efcdb |
v3locking_exec "status"
|
|
|
4efcdb |
rc=$?
|
|
|
4efcdb |
if [ $rc -ne 0 ]; then
|
|
|
4efcdb |
- ocf_exit_reason "NFS server is up, but the locking daemons are down"
|
|
|
4efcdb |
- rc=$OCF_ERR_GENERIC
|
|
|
4efcdb |
+ if [ ! "$fromstart" ] && [ $tries -gt "0" ]; then
|
|
|
4efcdb |
+ nfsserver_start frommonitor
|
|
|
4efcdb |
+ rc=$?
|
|
|
4efcdb |
+ let tries=$tries-1
|
|
|
4efcdb |
+ fi
|
|
|
4efcdb |
+ if [ "$rc" -ne "0" ]; then
|
|
|
4efcdb |
+ ocf_exit_reason "NFS server is up, but the locking daemons are down"
|
|
|
4efcdb |
+ rc=$OCF_ERR_GENERIC
|
|
|
4efcdb |
+ fi
|
|
|
4efcdb |
fi
|
|
|
4efcdb |
return $rc
|
|
|
4efcdb |
elif [ $rc -eq 3 ]; then
|
|
|
4efcdb |
@@ -391,12 +488,7 @@
|
|
|
4efcdb |
# only write to the tmp /etc/sysconfig/nfs if sysconfig exists.
|
|
|
4efcdb |
# otherwise this distro does not support setting these options.
|
|
|
4efcdb |
if [ -d "/etc/sysconfig" ]; then
|
|
|
4efcdb |
- # replace if the value exists, append otherwise
|
|
|
4efcdb |
- if grep "^\s*${key}=" $file ; then
|
|
|
4efcdb |
- sed -i "s/\s*${key}=.*$/${key}=\"${value}\"/" $file
|
|
|
4efcdb |
- else
|
|
|
4efcdb |
- echo "${key}=\"${value}\"" >> $file
|
|
|
4efcdb |
- fi
|
|
|
4efcdb |
+ echo "${key}=\"${value}\"" >> $file
|
|
|
4efcdb |
elif [ "$requires_sysconfig" = "true" ]; then
|
|
|
4efcdb |
ocf_log warn "/etc/sysconfig/nfs not found, unable to set port and nfsd args."
|
|
|
4efcdb |
fi
|
|
|
4efcdb |
@@ -409,11 +501,6 @@
|
|
|
4efcdb |
local tmpconfig=$(mktemp ${HA_RSCTMP}/nfsserver-tmp-XXXXX)
|
|
|
4efcdb |
local statd_args
|
|
|
4efcdb |
|
|
|
4efcdb |
- if [ -f "$NFS_SYSCONFIG" ]; then
|
|
|
4efcdb |
- ## Take the $NFS_SYSCONFIG file as our skeleton
|
|
|
4efcdb |
- cp $NFS_SYSCONFIG $tmpconfig
|
|
|
4efcdb |
- fi
|
|
|
4efcdb |
-
|
|
|
4efcdb |
# nfsd args
|
|
|
4efcdb |
set_arg "RPCNFSDARGS" "$OCF_RESKEY_nfsd_args" "$tmpconfig" "true"
|
|
|
4efcdb |
|
|
|
4efcdb |
@@ -444,20 +531,14 @@
|
|
|
4efcdb |
|
|
|
4efcdb |
# override local nfs config. preserve previous local config though.
|
|
|
4efcdb |
if [ -s $tmpconfig ]; then
|
|
|
4efcdb |
- cat $NFS_SYSCONFIG | grep -q -e "$NFS_SYSCONFIG_AUTOGEN_TAG" > /dev/null 2>&1
|
|
|
4efcdb |
+ cat $NFS_SYSCONFIG | grep -e "$NFS_SYSCONFIG_AUTOGEN_TAG"
|
|
|
4efcdb |
if [ $? -ne 0 ]; then
|
|
|
4efcdb |
# backup local nfs config if it doesn't have our HA autogen tag in it.
|
|
|
4efcdb |
mv -f $NFS_SYSCONFIG $NFS_SYSCONFIG_LOCAL_BACKUP
|
|
|
4efcdb |
fi
|
|
|
4efcdb |
-
|
|
|
4efcdb |
- cat $tmpconfig | grep -q -e "$NFS_SYSCONFIG_AUTOGEN_TAG" > /dev/null 2>&1
|
|
|
4efcdb |
- if [ $? -ne 0 ]; then
|
|
|
4efcdb |
- echo "# $NFS_SYSCONFIG_AUTOGEN_TAG" > $NFS_SYSCONFIG
|
|
|
4efcdb |
- echo "# local config backup stored here, '$NFS_SYSCONFIG_LOCAL_BACKUP'" >> $NFS_SYSCONFIG
|
|
|
4efcdb |
- cat $tmpconfig >> $NFS_SYSCONFIG
|
|
|
4efcdb |
- else
|
|
|
4efcdb |
- cat $tmpconfig > $NFS_SYSCONFIG
|
|
|
4efcdb |
- fi
|
|
|
4efcdb |
+ echo "# $NFS_SYSCONFIG_AUTOGEN_TAG" > $NFS_SYSCONFIG
|
|
|
4efcdb |
+ echo "# local config backup stored here, '$NFS_SYSCONFIG_LOCAL_BACKUP'" >> $NFS_SYSCONFIG
|
|
|
4efcdb |
+ cat $tmpconfig >> $NFS_SYSCONFIG
|
|
|
4efcdb |
fi
|
|
|
4efcdb |
rm -f $tmpconfig
|
|
|
4efcdb |
}
|
|
|
4efcdb |
@@ -476,14 +557,13 @@
|
|
|
4efcdb |
[ -d "$fp/$STATD_DIR/sm" ] || mkdir -p "$fp/$STATD_DIR/sm"
|
|
|
4efcdb |
[ -d "$fp/$STATD_DIR/sm.ha" ] || mkdir -p "$fp/$STATD_DIR/sm.ha"
|
|
|
4efcdb |
[ -d "$fp/$STATD_DIR/sm.bak" ] || mkdir -p "$fp/$STATD_DIR/sm.bak"
|
|
|
4efcdb |
- [ -n "`id -u rpcuser 2>/dev/null`" -a "`id -g rpcuser 2>/dev/null`" ] &&
|
|
|
4efcdb |
- chown -R rpcuser.rpcuser "$fp/$STATD_DIR"
|
|
|
4efcdb |
+ [ -n "`id -u rpcuser`" -a "`id -g rpcuser`" ] && chown -R rpcuser.rpcuser "$fp/$STATD_DIR"
|
|
|
4efcdb |
|
|
|
4efcdb |
[ -f "$fp/etab" ] || touch "$fp/etab"
|
|
|
4efcdb |
[ -f "$fp/xtab" ] || touch "$fp/xtab"
|
|
|
4efcdb |
[ -f "$fp/rmtab" ] || touch "$fp/rmtab"
|
|
|
4efcdb |
|
|
|
4efcdb |
- dd if=/dev/urandom of=$fp/$STATD_DIR/state bs=1 count=4 >/dev/null 2>&1
|
|
|
4efcdb |
+ dd if=/dev/urandom of=$fp/$STATD_DIR/state bs=1 count=4 &> /dev/null
|
|
|
4efcdb |
[ -n "`id -u rpcuser`" -a "`id -g rpcuser`" ] && chown rpcuser.rpcuser "$fp/$STATD_DIR/state"
|
|
|
4efcdb |
[ $SELINUX_ENABLED -eq 0 ] && chcon -R "$SELINUX_LABEL" "$fp"
|
|
|
4efcdb |
}
|
|
|
4efcdb |
@@ -563,15 +643,15 @@
|
|
|
4efcdb |
|
|
|
4efcdb |
terminate()
|
|
|
4efcdb |
{
|
|
|
4efcdb |
- local pids
|
|
|
4efcdb |
- local i=0
|
|
|
4efcdb |
+ declare pids
|
|
|
4efcdb |
+ declare i=0
|
|
|
4efcdb |
|
|
|
4efcdb |
while : ; do
|
|
|
4efcdb |
pids=$(binary_status $1)
|
|
|
4efcdb |
[ -z "$pids" ] && return 0
|
|
|
4efcdb |
kill $pids
|
|
|
4efcdb |
sleep 1
|
|
|
4efcdb |
- i=$((i + 1))
|
|
|
4efcdb |
+ ((i++))
|
|
|
4efcdb |
[ $i -gt 3 ] && return 1
|
|
|
4efcdb |
done
|
|
|
4efcdb |
}
|
|
|
4efcdb |
@@ -579,22 +659,22 @@
|
|
|
4efcdb |
|
|
|
4efcdb |
killkill()
|
|
|
4efcdb |
{
|
|
|
4efcdb |
- local pids
|
|
|
4efcdb |
- local i=0
|
|
|
4efcdb |
+ declare pids
|
|
|
4efcdb |
+ declare i=0
|
|
|
4efcdb |
|
|
|
4efcdb |
while : ; do
|
|
|
4efcdb |
pids=$(binary_status $1)
|
|
|
4efcdb |
[ -z "$pids" ] && return 0
|
|
|
4efcdb |
kill -9 $pids
|
|
|
4efcdb |
sleep 1
|
|
|
4efcdb |
- i=$((i + 1))
|
|
|
4efcdb |
+ ((i++))
|
|
|
4efcdb |
[ $i -gt 3 ] && return 1
|
|
|
4efcdb |
done
|
|
|
4efcdb |
}
|
|
|
4efcdb |
|
|
|
4efcdb |
stop_process()
|
|
|
4efcdb |
{
|
|
|
4efcdb |
- local process=$1
|
|
|
4efcdb |
+ declare process=$1
|
|
|
4efcdb |
|
|
|
4efcdb |
ocf_log info "Stopping $process"
|
|
|
4efcdb |
if terminate $process; then
|
|
|
4efcdb |
@@ -665,9 +745,14 @@
|
|
|
4efcdb |
|
|
|
4efcdb |
nfsserver_start ()
|
|
|
4efcdb |
{
|
|
|
4efcdb |
+ # Skip monitor check when run from nfsserver_monitor ()
|
|
|
4efcdb |
+ if [ "$1" == "frommonitor" ]; then
|
|
|
4efcdb |
+ frommonitor=1
|
|
|
4efcdb |
+ fi
|
|
|
4efcdb |
+
|
|
|
4efcdb |
local rc;
|
|
|
4efcdb |
|
|
|
4efcdb |
- if nfsserver_monitor; then
|
|
|
4efcdb |
+ if [ ! "$frommonitor" ] && nfsserver_monitor fromstart; then
|
|
|
4efcdb |
ocf_log debug "NFS server is already started"
|
|
|
4efcdb |
return $OCF_SUCCESS
|
|
|
4efcdb |
fi
|
|
|
4efcdb |
@@ -693,11 +778,32 @@
|
|
|
4efcdb |
modprobe nfsd
|
|
|
4efcdb |
fi
|
|
|
4efcdb |
|
|
|
4efcdb |
+ # systemd
|
|
|
4efcdb |
+ if [ "$EXEC_MODE" -eq "2" ]; then
|
|
|
4efcdb |
+ nfs_exec start rpcbind
|
|
|
4efcdb |
+ local i=10
|
|
|
4efcdb |
+ while [ "$i" -gt 0 ]; do
|
|
|
4efcdb |
+ ocf_log info "Start: rpcbind i: $i"
|
|
|
4efcdb |
+ rpcinfo &> /dev/null
|
|
|
4efcdb |
+ rc=$?
|
|
|
4efcdb |
+ if [ "$rc" -eq "0" ]; then
|
|
|
4efcdb |
+ break;
|
|
|
4efcdb |
+ fi
|
|
|
4efcdb |
+ sleep 1
|
|
|
4efcdb |
+ let i=$i-1
|
|
|
4efcdb |
+ done
|
|
|
4efcdb |
+ if [ "$i" -eq 0 ]; then
|
|
|
4efcdb |
+ ocf_exit_reason "Failed to start rpcbind"
|
|
|
4efcdb |
+ return $OCF_ERR_GENERIC
|
|
|
4efcdb |
+ fi
|
|
|
4efcdb |
+ fi
|
|
|
4efcdb |
+
|
|
|
4efcdb |
# check to see if we need to start rpc.statd
|
|
|
4efcdb |
v3locking_exec "status"
|
|
|
4efcdb |
if [ $? -ne $OCF_SUCCESS ]; then
|
|
|
4efcdb |
v3locking_exec "start"
|
|
|
4efcdb |
rc=$?
|
|
|
4efcdb |
+ ocf_log info "Start: v3locking: $rc"
|
|
|
4efcdb |
if [ $rc -ne 0 ]; then
|
|
|
4efcdb |
ocf_exit_reason "Failed to start NFS server locking daemons"
|
|
|
4efcdb |
return $rc
|
|
|
4efcdb |
@@ -706,8 +812,65 @@
|
|
|
4efcdb |
ocf_log info "rpc.statd already up"
|
|
|
4efcdb |
fi
|
|
|
4efcdb |
|
|
|
4efcdb |
+ # systemd
|
|
|
4efcdb |
+ if [ "$EXEC_MODE" -eq "2" ]; then
|
|
|
4efcdb |
+ nfs_exec start nfs-mountd
|
|
|
4efcdb |
+ local i=10
|
|
|
4efcdb |
+ while [ "$i" -gt 0 ]; do
|
|
|
4efcdb |
+ ocf_log info "Start: nfs-mountd i: $i"
|
|
|
4efcdb |
+ rpcinfo -t localhost 100005 &> /dev/null
|
|
|
4efcdb |
+ rc=$?
|
|
|
4efcdb |
+ if [ "$rc" -eq "0" ]; then
|
|
|
4efcdb |
+ break;
|
|
|
4efcdb |
+ fi
|
|
|
4efcdb |
+ sleep 1
|
|
|
4efcdb |
+ let i=$i-1
|
|
|
4efcdb |
+ done
|
|
|
4efcdb |
+ if [ "$i" -eq 0 ]; then
|
|
|
4efcdb |
+ ocf_exit_reason "Failed to start nfs-mountd"
|
|
|
4efcdb |
+ return $OCF_ERR_GENERIC
|
|
|
4efcdb |
+ fi
|
|
|
4efcdb |
+
|
|
|
4efcdb |
+ nfs_exec start nfs-idmapd
|
|
|
4efcdb |
+ local i=10
|
|
|
4efcdb |
+ while [ "$i" -gt 0 ]; do
|
|
|
4efcdb |
+ ocf_log info "Start: nfs-idmapd i: $i"
|
|
|
4efcdb |
+ fn=`mktemp`
|
|
|
4efcdb |
+ nfs_exec status nfs-idmapd > $fn 2>&1
|
|
|
4efcdb |
+ rc=$?
|
|
|
4efcdb |
+ ocf_log debug "$(cat $fn)"
|
|
|
4efcdb |
+ rm -f $fn
|
|
|
4efcdb |
+ if [ "$rc" -eq "0" ]; then
|
|
|
4efcdb |
+ break;
|
|
|
4efcdb |
+ fi
|
|
|
4efcdb |
+ sleep 1
|
|
|
4efcdb |
+ let i=$i-1
|
|
|
4efcdb |
+ done
|
|
|
4efcdb |
+ if [ "$i" -eq 0 ]; then
|
|
|
4efcdb |
+ ocf_exit_reason "Failed to start nfs-idmapd"
|
|
|
4efcdb |
+ return $OCF_ERR_GENERIC
|
|
|
4efcdb |
+ fi
|
|
|
4efcdb |
+
|
|
|
4efcdb |
+ nfs_exec start rpc-statd
|
|
|
4efcdb |
+ local i=10
|
|
|
4efcdb |
+ while [ "$i" -gt 0 ]; do
|
|
|
4efcdb |
+ ocf_log info "Start: rpc-statd i: $i"
|
|
|
4efcdb |
+ rpcinfo -t localhost 100024 &> /dev/null
|
|
|
4efcdb |
+ rc=$?
|
|
|
4efcdb |
+ if [ "$rc" -eq "0" ]; then
|
|
|
4efcdb |
+ break;
|
|
|
4efcdb |
+ fi
|
|
|
4efcdb |
+ sleep 1
|
|
|
4efcdb |
+ let i=$i-1
|
|
|
4efcdb |
+ done
|
|
|
4efcdb |
+ if [ "$i" -eq 0 ]; then
|
|
|
4efcdb |
+ ocf_exit_reason "Failed to start rpc-statd"
|
|
|
4efcdb |
+ return $OCF_ERR_GENERIC
|
|
|
4efcdb |
+ fi
|
|
|
4efcdb |
+ fi
|
|
|
4efcdb |
+
|
|
|
4efcdb |
fn=`mktemp`
|
|
|
4efcdb |
- nfs_exec start > $fn 2>&1
|
|
|
4efcdb |
+ nfs_exec start nfs-server > $fn 2>&1
|
|
|
4efcdb |
rc=$?
|
|
|
4efcdb |
ocf_log debug "$(cat $fn)"
|
|
|
4efcdb |
rm -f $fn
|
|
|
4efcdb |
@@ -717,6 +880,12 @@
|
|
|
4efcdb |
return $rc
|
|
|
4efcdb |
fi
|
|
|
4efcdb |
|
|
|
4efcdb |
+ tfn="/proc/fs/nfsd/threads"
|
|
|
4efcdb |
+ if [ ! -f "$tfn" ] || [ "$(cat $tfn)" -le "0" ]; then
|
|
|
4efcdb |
+ ocf_exit_reason "Failed to start NFS server: /proc/fs/nfsd/threads"
|
|
|
4efcdb |
+ return $OCF_ERR_GENERIC
|
|
|
4efcdb |
+ fi
|
|
|
4efcdb |
+
|
|
|
4efcdb |
notify_locks
|
|
|
4efcdb |
|
|
|
4efcdb |
ocf_log info "NFS server started"
|
|
|
4efcdb |
@@ -733,24 +902,71 @@
|
|
|
4efcdb |
cp -rpf $STATD_PATH/sm $STATD_PATH/sm.bak /var/lib/nfs/state $STATD_PATH/sm.ha > /dev/null 2>&1
|
|
|
4efcdb |
|
|
|
4efcdb |
fn=`mktemp`
|
|
|
4efcdb |
- nfs_exec stop > $fn 2>&1
|
|
|
4efcdb |
+ nfs_exec stop nfs-server > $fn 2>&1
|
|
|
4efcdb |
rc=$?
|
|
|
4efcdb |
ocf_log debug "$(cat $fn)"
|
|
|
4efcdb |
rm -f $fn
|
|
|
4efcdb |
|
|
|
4efcdb |
+ if [ $rc -ne 0 ]; then
|
|
|
4efcdb |
+ ocf_exit_reason "Failed to stop NFS server"
|
|
|
4efcdb |
+ return $rc
|
|
|
4efcdb |
+ fi
|
|
|
4efcdb |
+
|
|
|
4efcdb |
+ # systemd
|
|
|
4efcdb |
+ if [ "$EXEC_MODE" -eq "2" ]; then
|
|
|
4efcdb |
+ ocf_log info "Stop: threads"
|
|
|
4efcdb |
+ tfn="/proc/fs/nfsd/threads"
|
|
|
4efcdb |
+ if [ -f "$tfn" ] && [ "$(cat $tfn)" -gt "0" ]; then
|
|
|
4efcdb |
+ ocf_exit_reason "NFS server failed to stop: /proc/fs/nfsd/threads"
|
|
|
4efcdb |
+ return $OCF_ERR_GENERIC
|
|
|
4efcdb |
+ fi
|
|
|
4efcdb |
+
|
|
|
4efcdb |
+ nfs_exec stop rpc-statd &> /dev/null
|
|
|
4efcdb |
+ ocf_log info "Stop: rpc-statd"
|
|
|
4efcdb |
+ rpcinfo -t localhost 100024 &> /dev/null
|
|
|
4efcdb |
+ rc=$?
|
|
|
4efcdb |
+ if [ "$rc" -eq "0" ]; then
|
|
|
4efcdb |
+ ocf_exit_reason "Failed to stop rpc-statd"
|
|
|
4efcdb |
+ return $OCF_ERR_GENERIC
|
|
|
4efcdb |
+ fi
|
|
|
4efcdb |
+
|
|
|
4efcdb |
+ nfs_exec stop nfs-idmapd &> /dev/null
|
|
|
4efcdb |
+ ocf_log info "Stop: nfs-idmapd"
|
|
|
4efcdb |
+ fn=`mktemp`
|
|
|
4efcdb |
+ nfs_exec status nfs-idmapd > $fn 2>&1
|
|
|
4efcdb |
+ rc=$?
|
|
|
4efcdb |
+ ocf_log debug "$(cat $fn)"
|
|
|
4efcdb |
+ rm -f $fn
|
|
|
4efcdb |
+ if [ "$rc" -eq "0" ]; then
|
|
|
4efcdb |
+ ocf_exit_reason "Failed to stop nfs-idmapd"
|
|
|
4efcdb |
+ return $OCF_ERR_GENERIC
|
|
|
4efcdb |
+ fi
|
|
|
4efcdb |
+
|
|
|
4efcdb |
+ nfs_exec stop nfs-mountd &> /dev/null
|
|
|
4efcdb |
+ ocf_log info "Stop: nfs-mountd"
|
|
|
4efcdb |
+ rpcinfo -t localhost 100005 &> /dev/null
|
|
|
4efcdb |
+ rc=$?
|
|
|
4efcdb |
+ if [ "$rc" -eq "0" ]; then
|
|
|
4efcdb |
+ ocf_exit_reason "Failed to stop nfs-mountd"
|
|
|
4efcdb |
+ return $OCF_ERR_GENERIC
|
|
|
4efcdb |
+ fi
|
|
|
4efcdb |
+ fi
|
|
|
4efcdb |
+
|
|
|
4efcdb |
v3locking_exec "stop"
|
|
|
4efcdb |
if [ $? -ne 0 ]; then
|
|
|
4efcdb |
ocf_exit_reason "Failed to stop NFS locking daemons"
|
|
|
4efcdb |
rc=$OCF_ERR_GENERIC
|
|
|
4efcdb |
fi
|
|
|
4efcdb |
|
|
|
4efcdb |
- if [ $rc -eq 0 ]; then
|
|
|
4efcdb |
- unbind_tree
|
|
|
4efcdb |
- ocf_log info "NFS server stopped"
|
|
|
4efcdb |
- else
|
|
|
4efcdb |
- ocf_exit_reason "Failed to stop NFS server"
|
|
|
4efcdb |
+ # systemd
|
|
|
4efcdb |
+ if [ "$EXEC_MODE" -eq "2" ]; then
|
|
|
4efcdb |
+ nfs_exec stop rpcbind &> /dev/null
|
|
|
4efcdb |
+ ocf_log info "Stop: rpcbind"
|
|
|
4efcdb |
fi
|
|
|
4efcdb |
- return $rc
|
|
|
4efcdb |
+
|
|
|
4efcdb |
+ unbind_tree
|
|
|
4efcdb |
+ ocf_log info "NFS server stopped"
|
|
|
4efcdb |
+ return 0
|
|
|
4efcdb |
}
|
|
|
4efcdb |
|
|
|
4efcdb |
nfsserver_validate ()
|