From 81b60aa4ed0ec2aac804288dfb340e7ce1ae6195 Mon Sep 17 00:00:00 2001 From: bol-van Date: Tue, 31 Oct 2023 14:19:41 +0300 Subject: [PATCH] move fsleep to common --- blockcheck.sh | 34 ---------------------------------- common/base.sh | 34 ++++++++++++++++++++++++++++++++++ install_easy.sh | 20 +------------------- 3 files changed, 35 insertions(+), 53 deletions(-) diff --git a/blockcheck.sh b/blockcheck.sh index a99d064..07b86da 100755 --- a/blockcheck.sh +++ b/blockcheck.sh @@ -58,40 +58,6 @@ exitp() exit $1 } -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 -} - IPT() { $IPTABLES -C "$@" >/dev/null 2>/dev/null || $IPTABLES -I "$@" diff --git a/common/base.sh b/common/base.sh index 0d9cbef..7bd113a 100644 --- a/common/base.sh +++ b/common/base.sh @@ -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 +} diff --git a/install_easy.sh b/install_easy.sh index 31bb8f9..287f88c 100755 --- a/install_easy.sh +++ b/install_easy.sh @@ -27,24 +27,6 @@ GET_LIST="$IPSET_DIR/get_config.sh" MD5=md5sum exists $MD5 || MD5=md5 -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 - } -} - sedi() { # MacOS doesnt support -i without parameter. busybox doesnt support -i with parameter. @@ -852,7 +834,7 @@ check_prerequisites_openwrt() [ "$FSLEEP" = 0 ] && is_linked_to_busybox sleep && { echo echo no methods of sub-second sleep were found. - echo if you want to speed up blockcheck install coreutils-sleep + echo if you want to speed up blockcheck install coreutils-sleep. it requires about 40 Kb space if ask_yes_no N "do you want to install COREUTILS sleep"; then [ "$UPD" = "0" ] && { opkg update