Skip to content
Snippets Groups Projects
Commit bffa9f22 authored by Recolic's avatar Recolic :house_with_garden:
Browse files

.

parent 73624e8e
No related branches found
No related tags found
No related merge requests found
...@@ -16,25 +16,43 @@ check_reachability() { ...@@ -16,25 +16,43 @@ check_reachability() {
return $HMS_BAD # Host is unreachable return $HMS_BAD # Host is unreachable
fi fi
} }
check_mounted() {
df -T | grep nfs && return $HMS_GOOD || return $HMS_BAD
}
prev_stat=$HMS_GOOD #prev_stat=$HMS_GOOD
while true; do while true; do
check_reachability check_reachability
stat=$? net_stat=$?
if [ $stat != $prev_stat ]; then check_mounted
nfs_stat=$?
if [ $net_stat != $nfs_stat ]; then
# Two more double-confirmation. If difference fixed, do not update prev_stat and continue. # Two more double-confirmation. If difference fixed, do not update prev_stat and continue.
sleep 1 ; check_reachability ; [ $? = $prev_stat ] && continue sleep 1 ; check_reachability ; [ $? = $nfs_stat ] && continue
sleep 1 ; check_reachability ; [ $? = $prev_stat ] && continue sleep 1 ; check_reachability ; [ $? = $nfs_stat ] && continue
echo "$(date) State change from $prev_stat to $stat" echo "$(date) State mismatch detected, network $net_stat but nfs $nfs_stat"
# If still doesn't match prev_stat, do something. if [ $net_stat = $HMS_BAD ]; then
if [ $stat = $HMS_BAD ]; then
umount -f -l /home/recolic/nfs umount -f -l /home/recolic/nfs
else else
mount -o bg,intr,soft,timeo=1,retrans=1,actimeo=1,retry=1 hms.r:/ /home/recolic/nfs mount -o bg,intr,soft,timeo=1,retrans=1,actimeo=1,retry=1 hms.r:/ /home/recolic/nfs
fi fi
fi fi
prev_stat=$stat # if [ $stat != $prev_stat ]; then
# # Two more double-confirmation. If difference fixed, do not update prev_stat and continue.
# sleep 1 ; check_reachability ; [ $? = $prev_stat ] && continue
# sleep 1 ; check_reachability ; [ $? = $prev_stat ] && continue
# echo "$(date) State change from $prev_stat to $stat"
#
# # If still doesn't match prev_stat, do something.
# if [ $stat = $HMS_BAD ]; then
# umount -f -l /home/recolic/nfs
# else
# mount -o bg,intr,soft,timeo=1,retrans=1,actimeo=1,retry=1 hms.r:/ /home/recolic/nfs
# fi
# fi
# prev_stat=$stat
sleep 3 # Sleep for 3 seconds sleep 3 # Sleep for 3 seconds
done done
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment