manbytesgnu_site

Source files for manbytesgnu.org
git clone git://holbrook.no/manbytesgnu_site.git
Info | Log | Files | Refs

webshot.sh (606B)


      1 #!/bin/bash
      2 
      3 f=${WEBSHOT_OUTPUT_DIR:-/tmp}
      4 url=$1
      5 title=$2
      6 >&2 echo using outdir $f
      7 
      8 set +e
      9 
     10 # prepare 
     11 d=`TZ=UTC date +%Y%m%d%H%M`
     12 t=`mktemp -d`
     13 pushd $t
     14 
     15 # store raw outputs
     16 echo $1 > url.txt
     17 curl -s -I $1 > headers.txt
     18 curl -s -X GET $1 > contents.txt
     19 z=`sha256sum contents.txt`
     20 echo $z > contents.txt.sha256
     21 h=`echo -n $z | awk '{ print $1; }'`
     22 
     23 if [ -z "$title" ]; then
     24 	title=$h
     25 fi
     26 >&2 echo using title $title
     27 
     28 # rendered snapshot
     29 chromium --headless --print-to-pdf $url
     30 n=${d}_${h}
     31 mv output.pdf $n.pdf
     32 
     33 # store result
     34 mkdir -p "$f/$title"
     35 tar -zcvf "$f/$title/$n.tar.gz" *
     36 
     37 # clean up
     38 popd
     39 
     40 set -e