home *** CD-ROM | disk | FTP | other *** search
/ linuxmafia.com 2016 / linuxmafia.com.tar / linuxmafia.com / pub / linux / network / wotfaq.dragonmount.com.sh < prev    next >
Linux/UNIX/POSIX Shell Script  |  2013-02-04  |  6KB  |  112 lines

  1. #!/bin/sh
  2. ##
  3. ## Simple shell script to create a local static HTML mirror of the current 
  4. ## contents of http://wotfaq.dragonmount.com/.  Last modified 2010-11-07.
  5. ## Copyright (C) Rick Moen <rick@linuxmafia.com>, 2010.  Do anything you 
  6. ## want with this script, without restriction or limitation.
  7. ##
  8. ## If borrowing this script, replace target '/var/www/jordan' with 
  9. ## the local folder inside your Web server's public tree that 
  10. ## you wish to house your WOTFAQ mirror.  Also, you will want to 
  11. ## remove lines unique to linuxmafia.com from near the bottom.
  12. ##
  13. mkdir /tmp/wotfaq/
  14. wget --mirror --random-wait --page-requisites --html-extension \
  15.      --convert-links --no-host-directories \
  16.      --reject robots.txt rss.xml --exclude-directories=user \
  17.      --user-agent="Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)" \
  18.       -P /tmp/wotfaq \
  19.      http://wotfaq.dragonmount.com/
  20. ##
  21. ## Most of the remainder of this script are manual steps to compensate 
  22. ## for the fact that wget, as of v. 1.12, doesn't yet fetch all 
  23. ## referenced elements in the HTML, and hence also doesn't convert the
  24. ## links to them to relative links.  A lot of the latter correction
  25. ## is necessitated by Dragonmount.com's reliance on Drupal, whose 
  26. ## annoying tendency to put absolute links in HTML and CSS needs to
  27. ## be overcome to create self-sufficient static HTML mirror copies.
  28. ##
  29. cd /tmp/wotfaq
  30. wget -c http://wotfaq.dragonmount.com/themes/abarre/favicon.ico
  31. wget -c http://wotfaq.dragonmount.com/modules/aggregator/aggregator.css
  32. wget -c http://wotfaq.dragonmount.com/modules/book/book.css
  33. wget -c http://wotfaq.dragonmount.com/modules/poll/poll.css
  34. wget -c http://wotfaq.dragonmount.com/modules/system/defaults.css
  35. wget -c http://wotfaq.dragonmount.com/modules/system/system.css
  36. wget -c http://wotfaq.dragonmount.com/modules/system/system-menus.css
  37. wget -c http://wotfaq.dragonmount.com/modules/user/user.css
  38. wget -c http://wotfaq.dragonmount.com/themes/abarre/style.css
  39. wget -c http://wotfaq.dragonmount.com/themes/abarre/css/ie6.css
  40. wget -c http://wotfaq.dragonmount.com/themes/abarre/css/ie7.css
  41. wget -c http://wotfaq.dragonmount.com/sites/default/files/abarre_logo.gif
  42. cp *.ico *.css *.gif node/
  43. cp *.ico *.css *.gif book/export/html/
  44. mkdir images
  45. ##
  46. ## The following section is needed because style.css references a bunch
  47. ## of GIFs from a Drupal theme directory, again using absolute links
  48. ## (which will be corrected later on, but first we must create local
  49. ## files to point to).
  50. ##
  51. mkdir node/images
  52. cd images
  53. wget -c http://wotfaq.dragonmount.com/themes/abarre/images/bg.gif
  54. wget -c http://wotfaq.dragonmount.com/themes/abarre/images/footer-corner.gif
  55. wget -c http://wotfaq.dragonmount.com/themes/abarre/images/header-side.gif
  56. wget -c http://wotfaq.dragonmount.com/themes/abarre/images/block.gif
  57. wget -c http://wotfaq.dragonmount.com/themes/abarre/images/side-li.gif
  58. wget -c http://wotfaq.dragonmount.com/themes/abarre/images/side-li-active.gif
  59. wget -c http://wotfaq.dragonmount.com/themes/abarre/images/primary.gif
  60. wget -c http://wotfaq.dragonmount.com/themes/abarre/images/primary-active.gif
  61. wget -c http://wotfaq.dragonmount.com/themes/abarre/images/bullet.gif
  62. wget -c http://wotfaq.dragonmount.com/themes/abarre/images/shadow-bottom.gif
  63. wget -c http://wotfaq.dragonmount.com/themes/abarre/images/comment.gif
  64. wget -c http://wotfaq.dragonmount.com/themes/abarre/images/edit.gif
  65. wget -c http://wotfaq.dragonmount.com/themes/abarre/images/delete.gif
  66. wget -c http://wotfaq.dragonmount.com/themes/abarre/images/reply.gif
  67. wget -c http://wotfaq.dragonmount.com/themes/abarre/images/footer-corner2.gif
  68. cp * ../node/images
  69. ## 
  70. ## And this is where all those absolute links get bulk-converted into
  71. ## local relative URLs, by searching for the URLs in all non-directory
  72. ## files in the FAQ tree, and replacing them with links to local files,
  73. ## and with relative pathing so that this FAQ copy will be valid on any host.
  74. ##
  75. cd /tmp/wotfaq
  76. find . -type f -print0 | xargs -0 sed -i 's_http://wotfaq.dragonmount.com/themes/abarre/favicon.ico_favicon.ico_'
  77. find . -type f -print0 | xargs -0 sed -i 's_http://wotfaq.dragonmount.com/modules/aggregator/aggregator.css?y_aggregator.css?y_'
  78. find . -type f -print0 | xargs -0 sed -i 's_http://wotfaq.dragonmount.com/modules/book/book.css?y_book.css?y_'
  79. find . -type f -print0 | xargs -0 sed -i 's_http://wotfaq.dragonmount.com/modules/node/node.css?y_node.css?y_'
  80. find . -type f -print0 | xargs -0 sed -i 's_http://wotfaq.dragonmount.com/modules/poll/poll.css?y_poll.css?y_'
  81. find . -type f -print0 | xargs -0 sed -i 's_http://wotfaq.dragonmount.com/modules/system/defaults.css?y_defaults.css?y_'
  82. find . -type f -print0 | xargs -0 sed -i 's_http://wotfaq.dragonmount.com/modules/system/system.css?y_system.css?y_'
  83. find . -type f -print0 | xargs -0 sed -i 's_http://wotfaq.dragonmount.com/modules/system/system-menus.css?y_system-menus.css?y_'
  84. find . -type f -print0 | xargs -0 sed -i 's_http://wotfaq.dragonmount.com/modules/user/user.css?y_user.css?y_'
  85. find . -type f -print0 | xargs -0 sed -i 's_http://wotfaq.dragonmount.com/themes/abarre/style.css?y_style.css?y_'
  86. find . -type f -print0 | xargs -0 sed -i 's_http://wotfaq.dragonmount.com/themes/abarre/css/ie6.css?y_ie6.css?y_'
  87. F
  88. find . -type f -print0 | xargs -0 sed -i 's_http://wotfaq.dragonmount.com/themes/abarre/css/ie7.css?y_ie7.css?y_'
  89. find . -type f -print0 | xargs -0 sed -i 's%http://wotfaq.dragonmount.com/sites/default/files/abarre_logo.gif%abarre_logo.gif?y%'
  90. ## 
  91. ## Creation of the Zipped version of the FAQ.
  92. ##
  93. cd /tmp
  94. zip -r TGS-FAQ.zip wotfaq/
  95. mv TGS-WOTFAQ.zip wotfaq/
  96. ## 
  97. ## Now that everything's complete and correct, deploy en-masse into
  98. ## the system Web document tree.  The 'cp' method avoids meddling with
  99. ## subdirectories containing earlier editions of the FAQ.
  100. ##
  101. cp -R /tmp/wotfaq/* /var/www/jordan/
  102. ##
  103. ## Beginning of steps unique to linuxmafia.com, implementing load-balancing.
  104. ##
  105. cd /var/www/jordan
  106. cat redirect.php index.html > index.php
  107. rm index.html
  108. ##
  109. ## End of steps unique to linuxmafia.com.
  110. ##
  111. rm -r /tmp/wotfaq
  112.