summaryrefslogtreecommitdiffstats
path: root/scripts/bootstrap/builder_sleep.sh
blob: a8f8a907ab2d849a2edc6216e5509a946a794bb4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#! /bin/bash

SLEEP_DURATION=0
[ -n "$1" ] && SLEEP_DURATION=$(($1 * 86400))
SLEEP_INTERVAL=${REACTION_TIME:-600}

WAKE_FILE="/tmp/wake"
SYNC_FILE="/tmp/sync"

rm -f "$WAKE_FILE"
rm -f "$SYNC_FILE"

sum=0
while [ 1 ]; do
    sleep "$SLEEP_INTERVAL"

    sum=$(($sum + $SLEEP_INTERVAL))
    [ $SLEEP_DURATION -gt 0 -a $sum > $SLEEP_DURATION ] && break
    [ -f "$WAKE_FILE" ] && break
done

[ -f "$SYNC_FILE" ] && bash /etc/portage/scripts/bootstrap/builder_sync.sh