aboutsummaryrefslogtreecommitdiffstats
path: root/runcheck
blob: 2763703ff1e757563609159112603f82c03ad751 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/sh

set -e

file=urls-test.txt

if [ "$1" ] ; then
    file="$1"
fi

cat $file | while read url ; do
    case "$url" in
      http*)
        # Save with URL as filename, replacing / with % and dropping trailing slash.
        filename=$(echo "$url" | sed 's%/$%%' |tr / %)
        harfile="har-data/$filename.har"
        if [ ! -e "$harfile" ] ; then
            echo "testing $url"
            if phantomjs netsniff.js "$url" > "$harfile.new" && 
                [ -s "$harfile.new" ]; then
                mv "$harfile.new" "$harfile"
            else
                rm "$harfile.new"
            fi
        else
            echo found $harfile, not downloading
        fi
        if [ -e "$harfile" ] && grep -q google-analytics.com "$harfile" ; then
           echo "NSA/FRA warning for $url"
        fi
        ;;
    esac
done