This repository has been archived by the owner on Apr 28, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
jsitecopy
91 lines (90 loc) · 2.72 KB
/
jsitecopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/bash
BASEDIR=`dirname "${0}"`
cd "$BASEDIR"
if dpkg -s wget > /dev/null
then
echo
else
echo -e "\n*****wget isn't installed, trying to install*****\n"
sudo apt-get -y install wget
fi
while true
do
read -e -p "Enter URL of the website you want to copy (include www and/or http/s): " url
if wget -q $url -O /dev/null
then
echo "$url is valid"
break
else
echo -e "\n$url is invalid\n"
fi
done
while true
do
read -e -p "Enter directory path where you want to save it: " folder
folder=${folder/\~/$HOME}
if [ "$folder" == "" ]; then
folder="$BASEDIR"
echo "Saving into $folder"
break
else
mkdir -p "$folder"
if [ -d "$folder" ]; then
break
else
echo -e "\nCouldn't create directory...\n"
fi
fi
done
read -e -p "Enter interval wait in seconds (default= 5): " sec
if [[ $sec =~ ^[\-0-9]+$ ]] && (( sec >= 0)); then
sec=$sec
else
sec=5
fi
secmin=`echo 0.5*$sec | bc`
secmax=`echo 1.5*$sec | bc`
echo "Interval wait will be randomized between $secmin ~ $secmax"
read -e -p "Allow verbose mode (y/n)?: " verb
custom_option="--continue"
if [ "$verb" == "y" ] || [ "$verb" == "Y" ]; then
custom_option="$custom_option --verbose"
else
custom_option="$custom_option --no-verbose"
fi
read -e -p "Want to run this process in backgroud (y/n)?: " back
if [ "$back" == "y" ] || [ "$back" == "Y" ]; then
echo -e "\n***Starting in the background. You can close this window.***\n***Enter command 'killall wget' in any terminal to stop download.***\n"
wget $custom_option -b \
--mirror \
--no-clobber \
--page-requisites \
--adjust-extension \
--convert-links \
--restrict-file-names=windows \
--no-parent \
-e robots=off \
--wait=$sec \
--random-wait \
-U mozilla \
--directory-prefix="$folder" \
--waitretry=$sec \
$url &
else
echo -e "\n*****Starting wget process.*****\nIf you close this terminal it will run in the background.\n***Enter command 'killall wget' in any terminal to stop download.***\n"
wget $custom_option \
--mirror \
--no-clobber \
--page-requisites \
--adjust-extension \
--convert-links \
--restrict-file-names=windows \
--no-parent \
-e robots=off \
--wait=$sec \
--random-wait \
-U mozilla \
--directory-prefix="$folder" \
--waitretry=$sec \
$url
fi