home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
linuxmafia.com 2016
/
linuxmafia.com.tar
/
linuxmafia.com
/
pub
/
linux
/
network
/
wotfaq.dragonmount.com.sh
< prev
next >
Wrap
Linux/UNIX/POSIX Shell Script
|
2013-02-04
|
6KB
|
112 lines
#!/bin/sh
##
## Simple shell script to create a local static HTML mirror of the current
## contents of http://wotfaq.dragonmount.com/. Last modified 2010-11-07.
## Copyright (C) Rick Moen <rick@linuxmafia.com>, 2010. Do anything you
## want with this script, without restriction or limitation.
##
## If borrowing this script, replace target '/var/www/jordan' with
## the local folder inside your Web server's public tree that
## you wish to house your WOTFAQ mirror. Also, you will want to
## remove lines unique to linuxmafia.com from near the bottom.
##
mkdir /tmp/wotfaq/
wget --mirror --random-wait --page-requisites --html-extension \
--convert-links --no-host-directories \
--reject robots.txt rss.xml --exclude-directories=user \
--user-agent="Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)" \
-P /tmp/wotfaq \
http://wotfaq.dragonmount.com/
##
## Most of the remainder of this script are manual steps to compensate
## for the fact that wget, as of v. 1.12, doesn't yet fetch all
## referenced elements in the HTML, and hence also doesn't convert the
## links to them to relative links. A lot of the latter correction
## is necessitated by Dragonmount.com's reliance on Drupal, whose
## annoying tendency to put absolute links in HTML and CSS needs to
## be overcome to create self-sufficient static HTML mirror copies.
##
cd /tmp/wotfaq
wget -c http://wotfaq.dragonmount.com/themes/abarre/favicon.ico
wget -c http://wotfaq.dragonmount.com/modules/aggregator/aggregator.css
wget -c http://wotfaq.dragonmount.com/modules/book/book.css
wget -c http://wotfaq.dragonmount.com/modules/poll/poll.css
wget -c http://wotfaq.dragonmount.com/modules/system/defaults.css
wget -c http://wotfaq.dragonmount.com/modules/system/system.css
wget -c http://wotfaq.dragonmount.com/modules/system/system-menus.css
wget -c http://wotfaq.dragonmount.com/modules/user/user.css
wget -c http://wotfaq.dragonmount.com/themes/abarre/style.css
wget -c http://wotfaq.dragonmount.com/themes/abarre/css/ie6.css
wget -c http://wotfaq.dragonmount.com/themes/abarre/css/ie7.css
wget -c http://wotfaq.dragonmount.com/sites/default/files/abarre_logo.gif
cp *.ico *.css *.gif node/
cp *.ico *.css *.gif book/export/html/
mkdir images
##
## The following section is needed because style.css references a bunch
## of GIFs from a Drupal theme directory, again using absolute links
## (which will be corrected later on, but first we must create local
## files to point to).
##
mkdir node/images
cd images
wget -c http://wotfaq.dragonmount.com/themes/abarre/images/bg.gif
wget -c http://wotfaq.dragonmount.com/themes/abarre/images/footer-corner.gif
wget -c http://wotfaq.dragonmount.com/themes/abarre/images/header-side.gif
wget -c http://wotfaq.dragonmount.com/themes/abarre/images/block.gif
wget -c http://wotfaq.dragonmount.com/themes/abarre/images/side-li.gif
wget -c http://wotfaq.dragonmount.com/themes/abarre/images/side-li-active.gif
wget -c http://wotfaq.dragonmount.com/themes/abarre/images/primary.gif
wget -c http://wotfaq.dragonmount.com/themes/abarre/images/primary-active.gif
wget -c http://wotfaq.dragonmount.com/themes/abarre/images/bullet.gif
wget -c http://wotfaq.dragonmount.com/themes/abarre/images/shadow-bottom.gif
wget -c http://wotfaq.dragonmount.com/themes/abarre/images/comment.gif
wget -c http://wotfaq.dragonmount.com/themes/abarre/images/edit.gif
wget -c http://wotfaq.dragonmount.com/themes/abarre/images/delete.gif
wget -c http://wotfaq.dragonmount.com/themes/abarre/images/reply.gif
wget -c http://wotfaq.dragonmount.com/themes/abarre/images/footer-corner2.gif
cp * ../node/images
##
## And this is where all those absolute links get bulk-converted into
## local relative URLs, by searching for the URLs in all non-directory
## files in the FAQ tree, and replacing them with links to local files,
## and with relative pathing so that this FAQ copy will be valid on any host.
##
cd /tmp/wotfaq
find . -type f -print0 | xargs -0 sed -i 's_http://wotfaq.dragonmount.com/themes/abarre/favicon.ico_favicon.ico_'
find . -type f -print0 | xargs -0 sed -i 's_http://wotfaq.dragonmount.com/modules/aggregator/aggregator.css?y_aggregator.css?y_'
find . -type f -print0 | xargs -0 sed -i 's_http://wotfaq.dragonmount.com/modules/book/book.css?y_book.css?y_'
find . -type f -print0 | xargs -0 sed -i 's_http://wotfaq.dragonmount.com/modules/node/node.css?y_node.css?y_'
find . -type f -print0 | xargs -0 sed -i 's_http://wotfaq.dragonmount.com/modules/poll/poll.css?y_poll.css?y_'
find . -type f -print0 | xargs -0 sed -i 's_http://wotfaq.dragonmount.com/modules/system/defaults.css?y_defaults.css?y_'
find . -type f -print0 | xargs -0 sed -i 's_http://wotfaq.dragonmount.com/modules/system/system.css?y_system.css?y_'
find . -type f -print0 | xargs -0 sed -i 's_http://wotfaq.dragonmount.com/modules/system/system-menus.css?y_system-menus.css?y_'
find . -type f -print0 | xargs -0 sed -i 's_http://wotfaq.dragonmount.com/modules/user/user.css?y_user.css?y_'
find . -type f -print0 | xargs -0 sed -i 's_http://wotfaq.dragonmount.com/themes/abarre/style.css?y_style.css?y_'
find . -type f -print0 | xargs -0 sed -i 's_http://wotfaq.dragonmount.com/themes/abarre/css/ie6.css?y_ie6.css?y_'
F
find . -type f -print0 | xargs -0 sed -i 's_http://wotfaq.dragonmount.com/themes/abarre/css/ie7.css?y_ie7.css?y_'
find . -type f -print0 | xargs -0 sed -i 's%http://wotfaq.dragonmount.com/sites/default/files/abarre_logo.gif%abarre_logo.gif?y%'
##
## Creation of the Zipped version of the FAQ.
##
cd /tmp
zip -r TGS-FAQ.zip wotfaq/
mv TGS-WOTFAQ.zip wotfaq/
##
## Now that everything's complete and correct, deploy en-masse into
## the system Web document tree. The 'cp' method avoids meddling with
## subdirectories containing earlier editions of the FAQ.
##
cp -R /tmp/wotfaq/* /var/www/jordan/
##
## Beginning of steps unique to linuxmafia.com, implementing load-balancing.
##
cd /var/www/jordan
cat redirect.php index.html > index.php
rm index.html
##
## End of steps unique to linuxmafia.com.
##
rm -r /tmp/wotfaq