-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path01-download.bash
executable file
·77 lines (69 loc) · 2.73 KB
/
01-download.bash
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
72
73
74
75
76
77
#!/bin/bash
########################################################################
# 01-download.bash
# This script downloads the archlinux|ARM installation .tar.gz file
# from the official homepage based on the variable 'mydlurl'
# 'mydlurl' is set in the configuration file '00-a_client.conf'
########################################################################
########################################################################
# check prerequisites
########################################################################
# wget, curl or axel? axel is fastest!
#if command -v axel >/dev/null 2>&1
#then
# dlcmd='axel'
# elif command -v wget >/dev/null 2>&1
if command -v wget >/dev/null 2>&1
then
dlcmd='wget'
elif command -v curl >/dev/null 2>&1
then
dlcmd='curl'
else
#echo "Neither 'wget' nor 'curl' nor 'axel' is installed as download utility. Aborting."
echo "Neither 'wget' nor 'curl' is installed as download utility. Aborting."
exit 1
fi
########################################################################
# location of 00-a_client.conf to source it
########################################################################
configfile='./00-a_client.conf'
if [ ! -f "$configfile" ]; then echo "configuration file $configfile is missing. Aborting."; exit 1; fi
########################################################################
# source our variables from client.conf
########################################################################
unset mydlurl
unset myoutputfile
source "$configfile"
if [ -z ${mydlurl+x} ]; then echo "var mydlurl is not set. Aborting"; exit 1; fi
if [ -z ${myoutputfile+x} ]; then echo "var myoutputfile is not set. Aborting"; exit 1; fi
########################################################################
# Download root filesystem from archlinux|arm page
########################################################################
# decide between axel, curl or wget as download tool
echo -n "Downloading to $myoutputfile from $mydlurl using "
#if [ "${dlcmd}" = 'axel' ]
#then
# echo "axel..."
# ${dlcmd} -o "$myoutputfile" "${mydlurl}"
#fi
if [ "${dlcmd}" = 'curl' ]
then
echo "curl..."
${dlcmd} -L -o "$myoutputfile" "${mydlurl}"
fi
if [ ${dlcmd} = 'wget' ]
then
echo "wget..."
${dlcmd} -O "$myoutputfile" -q --show-progres "${mydlurl}"
fi
echo "...done"
if file --mime-type "$myoutputfile" | grep -q 'application/gzip'
then
echo -e "\e[92m[OK]\e[0m $myoutputfile has been downloaded."
else
echo -e "\e[91m[ERR]\e[0m $myoutputfile is missing or wrong mime type. Abort here!"
fi
########################################################################
# END END END END END END END END END END END END END END END END END #
########################################################################