aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/httracker/functions54
1 files changed, 27 insertions, 27 deletions
diff --git a/lib/httracker/functions b/lib/httracker/functions
index 33152b1..1a4fa7f 100644
--- a/lib/httracker/functions
+++ b/lib/httracker/functions
@@ -3,11 +3,25 @@
# Misc httracker functions.
#
+function httracker_opts {
+ OPTS=" --mirror \
+ --continue \
+ --depth=${DEPTH} \
+ --ext-depth ${EXT_DEPTH} \
+ --near \
+ --purge-old=0 \
+ --index \
+ --cookies=1 \
+ --path ${target}"
+}
+
function httracker_get {
+ # Options
local url="$1"
local hash="`echo $1 | sha1sum | cut -d ' ' -f 1`"
local target="$MIRRORS/$hash"
+ # Make sure that target exists
mkdir -p $target
# We already got this one
@@ -15,28 +29,21 @@ function httracker_get {
return
fi
+ # Basic options
+ httracker_opts
+
+ # Additional options
if [ "`whoami`" == "root" ]; then
- OPTS="--user $USER"
- else
- OPTS=""
+ OPTS="$OPTS --user $USER"
fi
+ # Fix permissions
if [ "`whoami`" != "$USER" ] && [ "`whoami`" == "root" ]; then
chown -R $USER.$GROUP $target/
fi
# Get each URL
- httrack \
- --mirror \
- --continue \
- --depth=${DEPTH} \
- --ext-depth ${EXT_DEPTH} \
- --near \
- --purge-old=0 \
- --index \
- --cookies=1 \
- --path ${target} \
- ${OPTS} ${url}
+ httrack ${OPTS} ${url}
if [ "$?" == "0" ]; then
# Mark as downloaded
@@ -55,26 +62,19 @@ function httracker_get_incremental {
target=${MIRRORDIR}/${year}/${month}
sudo -u links mkdir -p ${target}
+ # Basic options
+ httracker_opts
+
+ # Additional options
if [ "`whoami`" == "root" ]; then
OPTS="--user $USER"
- else
- OPTS=""
fi
# Grabs URLs from the network
- httrack \
- --mirror \
- --continue \
- --depth=${DEPTH} \
- --ext-depth ${EXT_DEPTH} \
- --near \
- --purge-old=0 \
- --index \
- --cookies=1 \
+ httrack ${OPTS} \
--user links \
--list ${URLS} \
- --path ${target} ${OPTS}
-
+ --path ${target}
}
function httracker_scuttle_config() {