aboutsummaryrefslogtreecommitdiffstats
path: root/runcheck
blob: 2a8e2d9e1166325db449ce29ce3fb7dabad5eee8 (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
34
35
#!/bin/sh

basedir="$(cd $(dirname $0); pwd)"

set -e

file=urls-test.txt

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

if [ ! -d har-data ]; then mkdir har-data ; 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 --ssl-protocol any $basedir/netsniff.js "$url" > "$harfile.new" &&
                [ -s "$harfile.new" ]; then
                mv "$harfile.new" "$harfile"
            else
                if ! rm "$harfile.new" ; then
                    echo "error: unable to remove $harfile.new"
                fi
            fi
        else
            echo "info: not contacting "$url", already had $harfile"
        fi
        ;;
    esac
done