downloadsource.sh
490 Bytes
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
# !/bin/bash
if [ $# -lt 3 ];
then
echo "Usage: $0 {link} {destdir} {md5sum}"
exit -1
fi
link=$1
dest=$2
checksum=$3
packdir=packages
fname=`basename $link`
cname=`basename $checksum`
if [ ! -f $packdir/$fname ];
then
wget $link -O $dest/$fname
fi
if [ ! -f $packdir/$cname ];
then
wget $checksum -O $packdir/$cname
fi
cd $packdir
if ! md5sum -c $cname;
then
echo "$fname is corrupted!"
exit -2
fi
cd ..
mkdir -p $dest
tar vxzf $packdir/$fname -C $dest --strip-components=1