make.sh: Introduce DEFAULT_PARALLELISM
[ipfire-2.x.git] / src / installer / downloadsource.sh
CommitLineData
0f680bcc
AF
1#!/bin/sh
2###############################################################################
3# #
4# IPFire.org - A linux based firewall #
5# Copyright (C) 2010 IPFire Team <info@ipfire.org> #
6# #
7# This program is free software: you can redistribute it and/or modify #
8# it under the terms of the GNU General Public License as published by #
9# the Free Software Foundation, either version 3 of the License, or #
10# (at your option) any later version. #
11# #
12# This program is distributed in the hope that it will be useful, #
13# but WITHOUT ANY WARRANTY; without even the implied warranty of #
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15# GNU General Public License for more details. #
16# #
17# You should have received a copy of the GNU General Public License #
18# along with this program. If not, see <http://www.gnu.org/licenses/>. #
19# #
20###############################################################################
21
c0511f3a
MT
22function download() {
23 wget -U "IPFire-NetInstall/2.x" "$@"
24}
25
26if [ $# -lt 2 ]; then
27 echo "$0: Insufficient number of arguments" >&2
28 exit 2
29fi
30
31OUTPUT="${1}"
32URL="${2}"
33
3e1145e1
MT
34# Mount a tmpfs which is big enough to hold the ISO image
35OUTPUT_DIR="${OUTPUT%/*}"
36
37mkdir -p "${OUTPUT_DIR}"
38if ! mount -t tmpfs none "${OUTPUT_DIR}" -o size=512M; then
39 echo "Could not mount tmpfs to ${OUTPUT_DIR}" >&2
40 exit 1
41fi
42
c0511f3a
MT
43echo "Downloading ${URL}..."
44if ! download -O "${OUTPUT}" "${URL}"; then
45 echo "Download failed" >&2
46
47 rm -f "${OUTPUT}"
48 exit 1
0f680bcc
AF
49fi
50
c0511f3a
MT
51# Download went well. Checking for MD5 sum
52if download -O "${OUTPUT}.md5" "${URL}.md5" &>/dev/null; then
53 # Read downloaded checksum
54 read -r md5sum rest < "${OUTPUT}.md5"
55 rm -f "${OUTPUT}.md5"
56
57 # Compute checkum of downloaded image file
58 read -r md5sum_image rest <<< "$(md5sum "${OUTPUT}")"
59
60 if [ "${md5sum}" != "${md5sum_image}" ]; then
61 echo "MD5 sum mismatch: ${md5sum} != ${md5sum_image}" >&2
62 exit 2
63 fi
0f680bcc 64fi
c0511f3a
MT
65
66exit 0