diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2018-04-06 19:54:03 +0200 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2018-04-06 19:54:03 +0200 |
commit | e52e5ea5494319f158e9d9c1425b16b9986e929a (patch) | |
tree | 7330667fc281e6de00b968bd31ff7ca5e5234f41 /odin/strm | |
parent | a29c95fe7335167cc3012dedfef2c4afbe1392c7 (diff) | |
download | nixos-e52e5ea5494319f158e9d9c1425b16b9986e929a.tar nixos-e52e5ea5494319f158e9d9c1425b16b9986e929a.tar.gz nixos-e52e5ea5494319f158e9d9c1425b16b9986e929a.tar.bz2 nixos-e52e5ea5494319f158e9d9c1425b16b9986e929a.tar.xz nixos-e52e5ea5494319f158e9d9c1425b16b9986e929a.zip |
rss_staggered
Diffstat (limited to 'odin/strm')
-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 | ||