-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_lfs_source.sh
executable file
·71 lines (56 loc) · 1022 Bytes
/
get_lfs_source.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
#!/bin/bash
# create by Raiden Awkward <raiden.ht@gmail.com>
# on 20111124
# for downloading sources from wget-list
DOWNLOADER=wget
LOGFILE="./log"
##
function usage_print {
echo usage : SCRIPT [wget-list] [target path]
}
function peel_file_name {
echo ${1##*/}
}
if [ -z $1 ] || [ -z $2 ]
then
usage_print
exit 1
fi
URL_LIST=$1
TARGET_PATH=$2
if ! [ -f $URL_LIST ]
then
echo file $URL_LIST not exits
exit 1
fi
if ! [ -d $TARGET_PATH ]
then
mkdir -p $TARGET_PATH
if ! [ $? -eq 0 ]
then
exit 1
fi
fi
echo "this is a log from $0" > $LOGFILE
echo `date` >> $LOGFILE
echo >> $LOGFILE
cat $URL_LIST | while read line
do
file=`peel_file_name $line`
echo $TARGET_PATH/$file
if [ -f $TARGET_PATH/$file ]
then
echo skipped existed file $file
echo "[skipped] $line >>" $LOGFILE
continue
fi
$DOWNLOADER -O $TARGET_PATH/$file $line
if ! [ $? -eq 0 ]
then
echo failed downloading $line
echo "[failed] $line" >> $LOGFILE
else
echo "[succeed] $line" >> $LOGFILE
fi
done
echo all done