functions: Add umount attemps counter

This commit is contained in:
timoxa0 2024-11-03 13:23:15 +05:00
parent fdec5d69bc
commit 7f5f41575e

View file

@ -25,7 +25,7 @@ mkdir_if_not_exists ()
umount_if_mouted() umount_if_mouted()
{ {
[ ! -d "$1" ] && return 0 [ ! -d "$1" ] && return 1
if grep -qs "$(realpath "$1")" /proc/mounts; then if grep -qs "$(realpath "$1")" /proc/mounts; then
umount "$1" umount "$1"
return $? return $?
@ -36,8 +36,8 @@ umount_if_mouted()
umount_force() umount_force()
{ {
[ ! -d "$1" ] && return 0 [ ! -d "$1" ] && return 1
while true; do for run in {1..5}; do
umount_if_mouted "$1" && break umount_if_mouted "$1" && break
log "Failed to umount $1. Trying again after 3 seconds" ierror log "Failed to umount $1. Trying again after 3 seconds" ierror
sleep 3 sleep 3