#!/bin/sh [ "$#" -lt 1 ] && { echo "savesite - save local copy of a website USAGE: savesite [DEST_DIR]"; exit 1; } url="$1" site="${2:-"$(echo "$url" | sed 's|\(https\?://\)\?\([A-Za-z0-9.-]*\)/.*|\2|')"}" WGETLOGS="${3:-.logs/$site.log}" started="$(date)" touch "$WGETLOGS" || exit printf ":: Downloading site: %s\n" "$site" printf ":: Logging to: %s\n" "$WGETLOGS" { setsid wget \ --continue \ --recursive \ --no-clobber \ --page-requisites \ --html-extension \ --convert-links \ --restrict-file-names=windows \ --domains "$site" \ --no-parent \ --output-file "$WGETLOGS" \ "$url" [ -n "$DISPLAY" ] && notify-send "savesite: finished downloading" "$site" printf "%s\n" ":: Finished downloading site: $site" \ ":: Started at: $started" \ ":: Finished at: $(date)" >> "$WGETLOGS" } & tail -f "$WGETLOGS"