update.sh - jscancer - Javascript crap (relatively small)
(HTM) git clone git://git.codemadness.org/jscancer
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
update.sh (786B)
---
1 #!/bin/sh
2 # tested on OpenBSD
3
4 rc="$HOME/.sfeed/narrowcasting/sfeedrc"
5 test -f "$rc" || exit 1
6
7 sfeed_update "$rc"
8
9 cd ~/.sfeed/narrowcasting/feeds/ || exit 1
10
11 d="/var/www/htdocs/narrowcasting/data"
12 test -d "$d" || exit 1
13
14 # timestamp of today
15 todaydate="$(date +'%Y-%m-%d')"
16 today="$(date -j -f '%Y-%m-%d %H:%M:%S' "$todaydate 00:00:00" +'%s')"
17
18 # remove some unused fields and reduce filesize of output.
19 reduce() {
20 LC_ALL=C awk -v "today=$today" '
21 BEGIN {
22 FS = OFS = "\t";
23 }
24 # filter items of today after 00:00.
25 $1 > today {
26 # remove content and content-type
27 $4 = "";
28 $5 = "";
29 print $0;
30 }'
31 }
32
33 # create JSON files.
34 tmp=$(mktemp)
35 for f in *; do
36 test -f "$f" || continue
37
38 reduce < "$f" | sfeed_json > "$tmp"
39
40 o="$d/$f.json"
41 cp -f "$tmp" "$o"
42 chmod 666 "$o"
43 done
44
45 rm -f "$tmp"