diff options
Diffstat (limited to 'odin/strm/rss_staggered')
-rwxr-xr-x | odin/strm/rss_staggered | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/odin/strm/rss_staggered b/odin/strm/rss_staggered new file mode 100755 index 00000000..54bbd1a3 --- /dev/null +++ b/odin/strm/rss_staggered | |||
@@ -0,0 +1,32 @@ | |||
1 | #!@zsh@/bin/zsh | ||
2 | |||
3 | delta_t=20 | ||
4 | interval=3600 | ||
5 | |||
6 | staggerFile=~/.rss-stagger | ||
7 | |||
8 | [[ "${FLOCKER}" != "$0" ]] && exec env FLOCKER="$0" flock -x "${staggerFile}" "$0" "$@" || : | ||
9 | |||
10 | feeds=$(@rss2email@/bin/r2e list | awk -F ':' 'END { print $1; }') | ||
11 | max=$(($feeds + 1)) | ||
12 | num=$(((max * delta_t) / interval)) | ||
13 | [[ $num -lt 1 ]] && num=1 | ||
14 | |||
15 | now=$(cat ${staggerFile} || echo 0) | ||
16 | now=$((now % max)) | ||
17 | |||
18 | typeset -a run | ||
19 | run=() | ||
20 | typeset -a names | ||
21 | names=() | ||
22 | |||
23 | n=0 | ||
24 | |||
25 | for i in $(seq $((now + 1)) $((now + num + 1))); do | ||
26 | n=$((i % max)) | ||
27 | run+=$n | ||
28 | done | ||
29 | |||
30 | echo $n >! ${staggerFile} | ||
31 | |||
32 | exec @rss2email@/bin/r2e run $run | ||