From ed333c1251c99590ebb7bd7279b1b3dd366b6e08 Mon Sep 17 00:00:00 2001 From: bol-van Date: Thu, 2 Nov 2023 21:29:26 +0300 Subject: [PATCH] blockcheck: add lua sleep support in older openwrt --- common/base.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/common/base.sh b/common/base.sh index 9c42c78..2dd26fd 100644 --- a/common/base.sh +++ b/common/base.sh @@ -209,10 +209,13 @@ fsleep_setup() if [ -z "$errtext" ]; then FSLEEP=3 # newer openwrt has ucode with system function that supports timeout in ms - elif ucode -e "system(['sleep','1'], 1)"; then + elif ucode -e "system(['sleep','1'], 1)" 2>/dev/null; then FSLEEP=4 + # older openwrt may have lua and nixio lua module + elif lua -e 'local nixio = require "nixio"; nixio.nanosleep(0,1);' 2>/dev/null ; then + FSLEEP=5 else - FSLEEP=0 + FSLEEP=5 fi fi } @@ -232,6 +235,9 @@ minsleep() 4) ucode -e "system(['sleep','1'], 100)" ;; + 5) + lua -e 'local nixio = require "nixio"; nixio.nanosleep(0,100000000);' + ;; *) sleep 1 esac