]> git.ipfire.org Git - ipfire-2.x.git/blame - src/installer/downloadsource.sh
installer: Initialize console font
[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
34echo "Downloading ${URL}..."
35if ! download -O "${OUTPUT}" "${URL}"; then
36 echo "Download failed" >&2
37
38 rm -f "${OUTPUT}"
39 exit 1
0f680bcc
AF
40fi
41
c0511f3a
MT
42# Download went well. Checking for MD5 sum
43if download -O "${OUTPUT}.md5" "${URL}.md5" &>/dev/null; then
44 # Read downloaded checksum
45 read -r md5sum rest < "${OUTPUT}.md5"
46 rm -f "${OUTPUT}.md5"
47
48 # Compute checkum of downloaded image file
49 read -r md5sum_image rest <<< "$(md5sum "${OUTPUT}")"
50
51 if [ "${md5sum}" != "${md5sum_image}" ]; then
52 echo "MD5 sum mismatch: ${md5sum} != ${md5sum_image}" >&2
53 exit 2
54 fi
0f680bcc 55fi
c0511f3a
MT
56
57exit 0