-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaccess.rh-iso-downloader.sh
executable file
·88 lines (78 loc) · 2.03 KB
/
access.rh-iso-downloader.sh
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
78
79
80
81
82
83
84
85
86
#!/bin/bash
#
# Download ISO content from RH and name the file correctly
# TODO: Review for improvements
# ## This was thrown together quickly and likely has room for \
# ## many enhancements, but it did what I needed when I needed \
# ## and I've not come back to it sense. Probably won't until \
# ## I need it (or similar functionality) again...
# perform sha256sum verification?
# VERIFY=[y|n]
VERIFY=y
# set proxy vars if needed
# examples
#http_proxy="http://localhost:3128/"
#https_proxy="http://localhost:3128/"
#
#export https_proxy="http://localhost:8080/"
if [ "${#}" -lt 1 ]; then
echo "Usage: $(basename ${0}) ...URLs..."
fi
function verify-file()
{
echo -n "Results: "
echo -n "${SHA} ${NAME}" | sha256sum -c
SHAEXIT="$?"
return ${SHAEXIT}
}
function dl-file()
{
wget --no-check-certificate -O ${NAME} -c ${VAR}
}
for VAR in "${@}"
do
NAME="$(echo "${VAR}" | sed -e 's|^htt.*/\(.*\)?.*$|\1|g')"
SHA="$( echo "${VAR}" | sed -e 's|^htt.*/\([a-f0-9]\{64\}\)/.*$|\1|g')"
SHAEXIT='0'
if [ "${VERIFY}" == "y" ]; then
if [ -f "${NAME}" ]; then
echo "Verifying: ${NAME}"
verify-file
fi
if [ "${SHAEXIT}" -gt 0 ]; then
dl-file
else
continue
fi
else
dl-file
fi
if [ "${VERIFY}" == "y" ]; then
echo "Verifying: ${NAME}"
verify-file
if [ "${SHAEXIT}" -gt 0 ]; then
rm -fv "${NAME}"
dl-file
else
continue
fi
echo "Verifying: ${NAME}"
verify-file
if [ "${SHAEXIT}" -gt 0 ]; then
dl-file
else
continue
fi
echo "Verifying: ${NAME}"
verify-file
if [ "${SHAEXIT}" -gt 0 ]; then
echo; echo; echo;
echo "Aborting for ${NAME}. Continued verification failures."
echo "Manual intervention required to correct"
echo; echo; echo;
sleep 5;
else
continue
fi
fi
done