# HG changeset patch # User Matti Hamalainen # Date 1360952000 -7200 # Node ID 891bd3c93f9674feddf09e7cf6d98a801240ad1b # Parent 055c33cba66ebc09eaf7b5f88caf0c1de09ef0d1 Modularize update script and fetch list of classes data separately from the actual class data. diff -r 055c33cba66e -r 891bd3c93f96 update.sh --- a/update.sh Tue Feb 05 11:18:34 2013 +0200 +++ b/update.sh Fri Feb 15 20:13:20 2013 +0200 @@ -8,6 +8,21 @@ fi } +function fetch() +{ +URLPREFIX="$1" +CLASSFILE="$2" +LISTFILE="$2.tmp" +PATPREFIX="$3" + +if wget -q -O "$LISTFILE" "$URLPREFIX"; then + perl -ne "if (//) { print \"\$1\n\"; }" < "$LISTFILE" > "$CLASSFILE" + echo -n "* Fetched classfile $CLASSFILE: " + cat "$CLASSFILE" | wc -l +fi +} + + function parse() { # Create cache directories, if they do not exist @@ -17,17 +32,10 @@ URLPREFIX="$1" CLASSFILE="$2" -LISTFILE="$2.tmp" PATPREFIX="$3" echo "" > "${CACHEDIR}baseuri.data"; -if wget -q -O "$LISTFILE" "$URLPREFIX"; then - perl -ne "if (//) { print \"\$1\n\"; }" < "$LISTFILE" > "$CLASSFILE" - echo -n "* Fetched classfile $CLASSFILE: " - cat "$CLASSFILE" | wc -l -fi - if test -e "$CLASSFILE"; then echo "* Processing $CLASSFILE ..." cat "$CLASSFILE" | while read i; do @@ -79,8 +87,9 @@ chmod 751 . && chmod 644 *.php *.css && chmod 600 coursecache.txt classes.txt classes_next.txt CACHEDIR="cache/" +fetch "http://www.oamk.fi/tyojarjestykset/otek/luokat/" "classes.txt" "OR_" +fetch "http://www.oamk.fi/~heikkim/riihi3/Luokat/" "classes.txt" "Ryh._" parse "http://www.oamk.fi/tyojarjestykset/otek/luokat/" "classes.txt" "OR_" -#parse "http://www.oamk.fi/~heikkim/riihi2/Oppilaat/" "classes.txt" "Ryh._" CACHEDIR="cache-next/" -parse "http://www.oamk.fi/~heikkim/riihi3/Luokat/" "classes_next.txt" "Ryh._" +parse "http://www.oamk.fi/~heikkim/riihi4/luokat/" "classes_next.txt" "Ryh._"