nutools/umirror

45 lines
1.2 KiB
Plaintext
Raw Normal View History

2013-08-27 15:14:44 +04:00
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname -- "$0")/lib/ulib/auto" || exit 1
2013-08-27 15:14:44 +04:00
function display_help() {
uecho "$scriptname: faire un miroir d'un site web
USAGE
$scriptname [options] url [wget_options]
OPTIONS
-l, --local
Convertir les liens pour consultation locale
-g, --no-robots
Ne pas tenir compte du fichier robots.txt
-n, --no-index
Ne pas télécharger les fichiers de la forme 'index.html*'. Utile pour
faire un miroir d'un site ftp qui est servi en http."
2013-08-27 15:14:44 +04:00
}
local=
no_robots=
no_index=
2013-08-27 15:14:44 +04:00
parse_opts + "${PRETTYOPTS[@]}" \
--help '$exit_with display_help' \
-l,--local local=1 \
-g,--no-robots no_robots=1 \
-n,--no-index no_index=1 \
2013-08-27 15:14:44 +04:00
@ args -- "$@" && set -- "${args[@]}" || die "$args"
url="$1"; shift
[ -n "$url" ] || exit_with display_help
if ! ask_yesno -c "\
Voulez-vous télécharger et faire un mirroir du site${local:+ (les liens seront convertis pour consultation locale)}
'$url'?" O; then
exit 1
fi
args=(-m -p -np)
[ -n "$local" ] && args=("${args[@]}" -k -K)
[ -n "$no_robots" ] && args=("${args[@]}" -e robots=off)
[ -n "$no_index" ] && args=("${args[@]}" -R "index.html*")
2013-08-27 15:14:44 +04:00
wget "${args[@]}" "$@" "$url"