Skip to content
This repository was archived by the owner on Aug 12, 2022. It is now read-only.

Commit b7636e5

Browse files
authored
httrack easy use script uploaded
1 parent ae8c505 commit b7636e5

File tree

1 file changed

+148
-0
lines changed

1 file changed

+148
-0
lines changed

heus.sh

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
#!/bin/bash
2+
3+
# hhsd-aup-download.sh
4+
# Script Description:
5+
# ~
6+
# This script uses httrack
7+
# to download the contents
8+
# of a website and all files
9+
# in the links, instead of
10+
# just saving the website.
11+
12+
# Variables:
13+
# mirror site
14+
website="$1"
15+
# save location for mirror
16+
location="$2"
17+
# mirror depth
18+
depth="$3"
19+
20+
# Functions:
21+
# help function for -h or incorrect use of script
22+
function help_func {
23+
echo "`basename "$0"` Help Command `basename "$0"`
24+
25+
Name
26+
`basename "$0"` - an easy use script for httrack
27+
28+
Synopsis
29+
`basename "$0"` [-h] [url] [directory] [depth]
30+
31+
Description
32+
An easy script for httrack
33+
34+
EXAMPLES
35+
`basename "$0"` www.someweb.com/bob/ ~/Downloads 4
36+
mirror site www.someweb.com/bob/ with the download directory
37+
to the home folder with a mirror depth of 4
38+
39+
`basename "$0"` -f www.someweb.com/bob/ ~/Downloads 4
40+
mirror site www.someweb.com/bob/ with the download directory
41+
to the home folder with a mirror depth of 4 and overwrites
42+
the files in the download directory
43+
44+
OPTIONS
45+
General options:
46+
-h displays this description
47+
48+
COPYRIGHT
49+
Copyright (C) 2022 Gabriel Morales
50+
51+
This program is free software; you can redistribute it and/or modify
52+
it under the terms of the GNU General Public License as published by
53+
the Free Software Foundation; either version 2 of the License, or
54+
(at your option) any later version.
55+
56+
This program is distributed in the hope that it will be useful,
57+
but WITHOUT ANY WARRANTY; without even the implied warranty of
58+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
59+
GNU General Public License for more details.
60+
61+
You should have received a copy of the GNU General Public License along
62+
with this program; if not, write to the Free Software Foundation, Inc.,
63+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
64+
65+
httrack:
66+
Copyright (C) 1998-2017 Xavier Roche and other contributors
67+
68+
This program is free software: you can redistribute it and/or
69+
modify it under the terms of the GNU General Public License
70+
as published by the Free Software Foundation, either version
71+
3 of the License, or (at your option) any later version.
72+
73+
This program is distributed in the hope that it will be
74+
useful, but WITHOUT ANY WARRANTY; without even the implied
75+
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
76+
PURPOSE. See the GNU General Public License for more details.
77+
78+
You should have received a copy of the GNU General Public
79+
License along with this program. If not, see
80+
<http://www.gnu.org/licenses/>.
81+
82+
AVAILABILITY
83+
The most recent and updated version of the script can be found at:
84+
https://github.com/moral-g/hhsd-aup
85+
86+
httrack:
87+
The most recent released version of httrack can be found
88+
at: http://www.httrack.com
89+
90+
AUTHOR
91+
Gabriel Morales <[email protected]>
92+
93+
httrack:
94+
Xavier Roche <[email protected]>
95+
96+
SEE ALSO
97+
The script history is hosted at and part of this project:
98+
https://github.com/moral-g/hhsd-aup
99+
100+
httrack:
101+
The HTML documentation available online at :
102+
http://www.httrack.com/html/ contains
103+
more detailed information. Please also
104+
refer to the httrack FAQ available online at:
105+
http://www.httrack.com/html/faq.html
106+
107+
Process:
108+
written on my ipad :)" >&2
109+
exit 1
110+
}
111+
112+
# checks if all required arguments satisfied
113+
function check_all_arg_sat_func {
114+
if [ -z "$website" ] 2> /dev/null || [ -z "$location" ] 2> /dev/null || [ -z "$depth" ] 2> /dev/null; then
115+
echo -e "Invalid use of the script: not all required arguments passed"
116+
echo -e "Usage: `basename "$0"` -h"
117+
exit 1
118+
fi
119+
}
120+
121+
# checks if website arg is websites, folder is folder ... etc
122+
function check_args_use_func {
123+
ping "$website" -qc 1 > /dev/null || error_func "ping $website"
124+
! [ -d "$location" ] && mkdir $location
125+
echo -e "Directory made: $location"
126+
}
127+
128+
# error function catch
129+
function error_func {
130+
echo -e "* Error at: $1\nUnsucessful run!"
131+
exit 1
132+
}
133+
134+
# checks flags
135+
while getopts "fh" opt; do
136+
case $opt in
137+
h) help_func >&2;;
138+
esac
139+
done
140+
# check if all arguments used
141+
check_all_arg_sat_func
142+
check_args_use_func
143+
echo -e "From: $website\nDownloading mirror of depth $depth to: $location\n"
144+
httrack $website -O "$location" -%v -r$depth || error_func "httrack $website -O "$location" -%v -r$depth"
145+
146+
147+
148+
# httrack https://www.hatboro-horsham.org/Page/716 -O "/home/moralg/websites/hhsd-aup" -%v -r3

0 commit comments

Comments
 (0)