aboutsummaryrefslogtreecommitdiff
path: root/lib/httracker/functions
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2013-08-25 21:58:38 -0300
committerSilvio Rhatto <rhatto@riseup.net>2013-08-25 21:58:38 -0300
commitafa9ae1f6a3f12e0bc7a30ee0a6c1c606e667511 (patch)
tree5e5810fd377fe6ff72fed827bfd5eed4fe5cfcc4 /lib/httracker/functions
parent2f3b2d3684068987691242da4dbda2f09828a56c (diff)
downloadhttruta-afa9ae1f6a3f12e0bc7a30ee0a6c1c606e667511.tar.gz
httruta-afa9ae1f6a3f12e0bc7a30ee0a6c1c606e667511.tar.bz2
Merge common options
Diffstat (limited to 'lib/httracker/functions')
-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() {