-
Notifications
You must be signed in to change notification settings - Fork 3
/
dld-client.sh
executable file
·85 lines (73 loc) · 1.93 KB
/
dld-client.sh
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
#!/bin/bash
#
# Distributed downloading script for me.com/mac.com.
#
# This will get a username from the tracker and download data
# from web.me.com, homepage.mac.com, public.me.com and
# gallery.me.com.
#
# You need wget-warc to run this script. Please compile it and
# copy the wget executable as wget-warc to the same directory
# as these scripts.
#
# Usage: dld-client.sh ${YOURALIAS}
#
# To stop the script gracefully, touch STOP in the script's
# working directory. The script will then finish the current
# user and stop.
#
# this script needs wget-warc, which you can find on the ArchiveTeam wiki.
# copy the wget executable to this script's working directory and rename
# it to wget-warc
if [ ! -x ./wget-warc ]
then
echo "wget-warc not found. Download and compile wget-warc and save the"
echo "executable as ./wget-warc"
exit 3
fi
# the script also needs curl with SSL support
if ! builtin type -p curl &>/dev/null
then
echo "You don't have curl."
exit 3
fi
if ! curl -V | grep -q SSL
then
echo "Your version of curl doesn't have SSL support."
exit 3
fi
youralias="$1"
if [[ ! $youralias =~ ^[-A-Za-z0-9_]+$ ]]
then
echo "Usage: $0 {nickname}"
echo "Run with a nickname with only A-Z, a-z, 0-9, - and _"
exit 4
fi
initial_stop_mtime='0'
if [ -f STOP ]
then
initial_stop_mtime=$( ./filemtime-helper.sh STOP )
fi
while [ ! -f STOP ] || [[ $( ./filemtime-helper.sh STOP ) -le $initial_stop_mtime ]]
do
# request a username
echo -n "Getting next username from tracker..."
tracker_no=$(( RANDOM % 3 ))
tracker_host="memac-${tracker_no}.heroku.com"
username=$( curl -s -f -d "{\"downloader\":\"${youralias}\"}" http://${tracker_host}/request )
# empty?
if [ -z $username ]
then
echo
echo "No username. Sleeping for 30 seconds..."
echo
sleep 30
else
echo " done."
if ! ./dld-single.sh "$youralias" "$username"
then
echo "Error downloading '$username'."
exit 6
fi
fi
done