kusano 7d535a
#!/bin/sh
kusano 7d535a
##
kusano 7d535a
## Copyright (C) 2002-2008, Marcelo E. Magallon <mmagallo[]debian org=""></mmagallo[]debian>
kusano 7d535a
## Copyright (C) 2002-2008, Milan Ikits <milan ikits[]ieee="" org=""></milan>
kusano 7d535a
##
kusano 7d535a
## This program is distributed under the terms and conditions of the GNU
kusano 7d535a
## General Public License Version 2 as published by the Free Software
kusano 7d535a
## Foundation or, at your option, any later version.
kusano 7d535a
kusano 7d535a
set -e
kusano 7d535a
kusano 7d535a
if [ ! -d $1 ] ; then
kusano 7d535a
    mkdir $1
kusano 7d535a
fi
kusano 7d535a
cd $1
kusano 7d535a
kusano 7d535a
# wget used to return 0 (success), but more recent versions
kusano 7d535a
# don't so we don't want to bail out in failure mode
kusano 7d535a
# eventhough everything is fine.
kusano 7d535a
kusano 7d535a
set +e
kusano 7d535a
kusano 7d535a
wget                                                    \
kusano 7d535a
    --mirror                                            \
kusano 7d535a
    --no-parent                                         \
kusano 7d535a
    --no-host-directories                               \
kusano 7d535a
    --cut-dirs=2                                        \
kusano 7d535a
    --accept=txt,html                                   \
kusano 7d535a
    $2
kusano 7d535a
kusano 7d535a
echo 'wget exit code: ' $?
kusano 7d535a
kusano 7d535a
exit 0