Skip to content

Commit 0136734

Browse files
First working copy
1 parent 3262a1c commit 0136734

File tree

2 files changed

+66
-6
lines changed

2 files changed

+66
-6
lines changed

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ $ wgetmd5 ftp://ftp.gimp.org/pub/gimp/v2.8/gimp-2.8.0.tar.bz2 ftp://ftp.gimp.org
2424
License
2525
-------
2626

27-
The source files are made available under the terms of the GNU Affero General Public Licence (AGPL).
27+
The source files are made available under the terms of the GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
28+
29+
2830

2931

3032
____ __ __

wgetmd5

+63-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,70 @@
1-
#bin/bash
1+
#!/bin/bash
22

3+
# ____ __ __
4+
# / __ \___ _ __/ / / /___ __ __________
5+
# / / / / _ \ | / / /_/ / __ \/ / / / ___/ _ \
6+
# / /_/ / __/ |/ / __ / /_/ / /_/ (__ ) __/
7+
# /_____/\___/|___/_/ /_/\____/\__,_/____/\___/ . com . br
8+
#
9+
# Created by Leonardo Lima de Vasconcellos on 08-19-2012
10+
11+
#
12+
# * This script requires bash 4 or later
13+
#
14+
15+
# Default language is English
16+
language="en"
317

18+
# if system language is Portuguese then set language to portuguese
19+
if [ `expr match "$LANG" "pt_BR"` -gt 0 ] || [ `expr match "$LANG" "pt_PT"` -gt 0 ] ; then
20+
language="pt"
21+
fi
422

5-
if
23+
# definition of messages
24+
if [ "$language" == "pt" ] ; then
25+
declare -A messages=(
26+
["error_no_arguments"]="\n\033[1;31mFaltam argumentos.\033[0m\n\n\tUso:\n\n\t$ wgetmd5 url_arquivo url_arquivo_md5\n\n"
27+
["download_started"]="\n\n\033[1;32mIniciando download...\033[0m\n\n"
28+
["download_success"]="\n\n\033[1;32mDownload concluido com sucesso!\033[0m\n\n"
29+
["download_fail"]="\n\n\033[1;31mDownload corrompido!\033[0m\n\n"
30+
)
31+
else
32+
declare -A messages=(
33+
["error_no_arguments"]="\n\033[1;31mArgument missing.\033[0m\n\n\tUsage:\n\n\t$ wgetmd5 file_url md5_file_url\n\n"
34+
["download_started"]="\n\n\033[1;32mStarting download...\033[0m\n\n"
35+
["download_success"]="\n\n\033[1;32mDownload successful!\033[0m\n\n"
36+
["download_fail"]="\n\n\033[1;31mDownload corrupted!\033[0m\n\n"
37+
)
38+
fi
639

40+
# if no arguments print usage message
741
if [ ! $1 ] && [ ! $2 ] ; then
8-
echo "Strings \"$1\" and \"$2\" are null."
9-
exit 1
42+
echo -e ${messages["error_no_arguments"]}
43+
exit 1
1044
fi
1145

12-
# echo "O arquivo para download é: $1";
46+
47+
# extract file names
48+
filename=`basename $1`
49+
md5filename=`basename $2`
50+
51+
# start download
52+
echo -e ${messages["download_started"]}
53+
wget $1 $2
54+
55+
# check md5sum from downloaded file
56+
md5test=`md5sum "$filename" | awk '{print $1}'`
57+
58+
# extract md5sum string from downloaded md5 file
59+
md5string=`cat "$md5filename" | awk '{print $1}'`
60+
61+
# if strings match then download ok
62+
if [ "$md5test" == "$md5string" ] ; then
63+
echo -e ${messages["download_success"]}
64+
echo -e "$md5test" "==" "$md5string" "\n\n"
65+
exit 0
66+
else
67+
echo -e ${messages["download_fail"]}
68+
echo -e "$md5test" "!=" "$md5string" "\n\n"
69+
exit 1
70+
fi

0 commit comments

Comments
 (0)