examples/bin/setup-example.sh
author Paul Groth <p.t.groth@vu.nl>
Fri, 07 Jun 2013 20:21:19 +0200
changeset 6412 600c6fd1fdb4
parent 1748 898d5f69c252
permissions -rwxr-xr-x
minor updates to address dong's comments
     1 #!/bin/bash
     2 #
     3 # Script to setup directory structure according to
     4 # http://www.w3.org/2011/prov/wiki/PROV_examples_-_directory_conventions
     5 # Run without arguments for usage.
     6 
     7 if [[ $# -eq 0 || "$1" == "--help" ]]; then
     8    echo "usage: bin/`basename $0` [-n] title-using-dashes {asn, rdf, xml, json}+"
     9    echo "  invoke from http://dvcs.w3.org/hg/prov/file/tip/examples"
    10    echo "  -n : dry run; do not make the directory"
    11    exit 1
    12 fi
    13 
    14 dryRun="no"
    15 if [ "$1" == "-n" ]; then
    16    dryRun="yes" 
    17    shift
    18 fi
    19 
    20 if [ "$1" == "--id" ]; then # Hidden feature
    21    count="$2"
    22    shift 2
    23 else
    24    count=`find . -maxdepth 1 -name "eg-*" | wc -l`
    25    let "count=count+1"
    26 fi
    27 
    28 title="$1"
    29 shift
    30 
    31 eg="eg-$count-$title" 
    32 echo $eg
    33 
    34 echo "   $eg/document/homepage"
    35 if [ $dryRun == "no" ]; then
    36    mkdir -p $eg/document
    37    echo "http://www.w3.org/2011/prov/wiki/E${eg#e}"         > $eg/document/homepage
    38    echo "http://dvcs.w3.org/hg/prov/file/tip/examples/$eg" >> $eg/document/homepage
    39 fi
    40 
    41 while [ $# -gt 0 ]; do
    42    format="$1"
    43 
    44    echo
    45    echo "   $eg/$format"
    46    if [ $dryRun == "no" ]; then
    47       mkdir -p $eg/$format
    48    fi
    49 
    50    for stub in `find eg-?-$format-stub/$format -name "eg-?-$format-stub.*"`; do
    51       ext=${stub#*stub.}
    52       echo "   $eg/$format/$eg.$ext <- $stub"
    53       if [ $dryRun == "no" ]; then
    54          if [ $format == "rdf" ]; then
    55             cat $stub | sed "s/eg-2-rdf-stub/$eg/g" > $eg/$format/$eg.$ext
    56          else
    57             cp $stub $eg/$format/$eg.$ext
    58          fi
    59       fi
    60    done
    61 
    62    shift
    63 done
    64 
    65 echo
    66 echo "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "
    67 echo "Go start your wiki page at http://www.w3.org/2011/prov/wiki/E${eg#e}, putting this into the page:"
    68 echo
    69 echo "{{PROV example}}"
    70 echo
    71 echo "* author:"
    72 echo
    73 echo "== Identify the problem =="
    74 echo "== The use of provenance =="
    75 echo "== The PROV example =="
    76 echo "* http://dvcs.w3.org/hg/prov/file/tip/examples/$eg"
    77 echo "== How PROV is accessed and queried? =="
    78 echo
    79 echo "[[Category:PROV example]]"