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