move fsleep to common

This commit is contained in:
bol-van
2023-10-31 14:19:41 +03:00
parent c9f34a064e
commit 81b60aa4ed
3 changed files with 35 additions and 53 deletions

View File

@@ -196,3 +196,37 @@ fix_sbin_path()
printf "%s\n" $PATH | grep -Fxq '/sbin' || PATH="/sbin:$PATH"
export PATH
}
fsleep_setup()
{
[ -n "$FSLEEP" ] || {
if sleep 0.1 2>/dev/null; then
FSLEEP=1
elif busybox usleep 1 2>/dev/null; then
FSLEEP=2
else
local errtext=$(read -t 0.001 2>&1)
if [ -z "$errtext" ]; then
FSLEEP=3
else
FSLEEP=0
fi
fi
}
}
minsleep()
{
case "$FSLEEP" in
1)
sleep 0.1
;;
2)
busybox usleep 100000
;;
3)
read -t 0.1
;;
*)
sleep 1
esac
}