oddmuse2svg.sh 1013 B

12345678910111213141516171819202122232425262728293031323334
  1. #!/bin/bash
  2. #
  3. # Import SVG from Oddmuse wiki
  4. ODD_STUB="$1"
  5. # get the page name,
  6. WIKI_DIR=`dirname "$ODD_STUB"`
  7. PAGENAME=`basename "$ODD_STUB"`
  8. PAGENAME="${PAGENAME%.odd}Source"
  9. echo "WIKI_DIR: $WIKI_DIR" > "/tmp/oddmuse2svg.report"
  10. echo "PAGENAME: $PAGENAME" >> "/tmp/oddmuse2svg.report"
  11. # download it
  12. NOTES="$WIKI_DIR/notes.txt"
  13. URLBASE=`cat "$NOTES" | grep -e "^urlbase" | cut -d" " -f2`
  14. FULLURL="${URLBASE}download/${PAGENAME}"
  15. echo "NOTES: $NOTES" >> "/tmp/oddmuse2svg.report"
  16. echo "URLBASE: $URLBASE" >> "/tmp/oddmuse2svg.report"
  17. echo "FULLURL: $FULLURL" >> "/tmp/oddmuse2svg.report"
  18. WGET=`which wget`
  19. CURL=`which CURL`
  20. if test -x "$WGET"; then
  21. echo "USERAGENT: wget" >> "/tmp/oddmuse2svg.report"
  22. $WGET "$FULLURL" -o "$WIKI_DIR"/download.log -nv -O-
  23. elif test -x "$CURL"; then
  24. echo "USERAGENT: curl" >> "/tmp/oddmuse2svg.report"
  25. $CURL --silent --show-error "$FULLURL"
  26. else
  27. echo "USERAGENT: none" >> "/tmp/oddmuse2svg.report"
  28. echo Neither wget nor curl were found in $PATH 1>&2
  29. fi