summaryrefslogtreecommitdiffstats
path: root/scripts/bootstrap/builder_sleep.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/bootstrap/builder_sleep.sh')
-rw-r--r--scripts/bootstrap/builder_sleep.sh22
1 files changed, 22 insertions, 0 deletions
diff --git a/scripts/bootstrap/builder_sleep.sh b/scripts/bootstrap/builder_sleep.sh
new file mode 100644
index 0000000..a8f8a90
--- /dev/null
+++ b/scripts/bootstrap/builder_sleep.sh
@@ -0,0 +1,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