blockcheck: add lua sleep support in older openwrt

This commit is contained in:
bol-van 2023-11-02 21:29:26 +03:00
parent dcd73e3371
commit ed333c1251

View File

@ -209,10 +209,13 @@ fsleep_setup()
if [ -z "$errtext" ]; then if [ -z "$errtext" ]; then
FSLEEP=3 FSLEEP=3
# newer openwrt has ucode with system function that supports timeout in ms # 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 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 else
FSLEEP=0 FSLEEP=5
fi fi
fi fi
} }
@ -232,6 +235,9 @@ minsleep()
4) 4)
ucode -e "system(['sleep','1'], 100)" ucode -e "system(['sleep','1'], 100)"
;; ;;
5)
lua -e 'local nixio = require "nixio"; nixio.nanosleep(0,100000000);'
;;
*) *)
sleep 1 sleep 1
esac esac