Update sync.sh

This commit is contained in:
Andrew Hurley 2021-08-07 23:11:46 +10:00 committed by GitHub
parent 9217651875
commit cf064bf0a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -72,16 +72,19 @@ while true; do
fi
# Sleep
modulus=4
for expiration in $(sslmate list -z --columns=expiration); do
timeleft=$(( expiration - $(date +"%s") ))
echo -n "timeleft: $timeleft "
if (( timeleft <= 0 )); then
r=$((RANDOM%4))
r=$((RANDOM%modulus))
if [[ -v $sleeptime ]]; then
sleeptime=$(( sleeptime > r ? r : sleeptime ))
else
sleeptime=$r
fi
modulus=$(( modulus*2 ))
modulus=$(( modulus > 32768 ? 256 : modulus ))
else
r=$((timeleft*9/10))
if [[ -v $sleeptime ]]; then
@ -89,6 +92,7 @@ while true; do
else
sleeptime=$r
fi
modulus=4
fi
done
echo "- sleeping for $sleeptime seconds"