forked from TermuxArch/TermuxArch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
getimagefunctions.bash
114 lines (111 loc) · 3.94 KB
/
getimagefunctions.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/usr/bin/env bash
## Copyright 2017-2022 by SDRausty. All rights reserved. 🌎 🌍 🌏 🌐 🗺
## Hosted sdrausty.github.io/TermuxArch courtesy https://pages.github.com
## https://sdrausty.github.io/TermuxArch/README has info about this project.
## https://sdrausty.github.io/TermuxArch/CONTRIBUTORS Thank you for your help.
################################################################################
_FTCHIT_() {
_PRINT_DOWNLOADING_FTCHIT_
if [[ "$DM" = aria2 ]]
then
aria2c --continue -Z http://"$CMIRROR/$RPATH/$IFILE".md5 http://"$CMIRROR/$RPATH/$IFILE"
elif [[ "$DM" = axel ]]
then
axel -a --no-clobber http://"$CMIRROR/$RPATH/$IFILE".md5 ||:
axel -a --no-clobber http://"$CMIRROR/$RPATH/$IFILE" ||:
elif [[ "$DM" = lftp ]]
then
lftpget -c http://"$CMIRROR/$RPATH/$IFILE".md5 http://"$CMIRROR/$RPATH/$IFILE"
elif [[ "$DM" = wget ]]
then
wget "$DMVERBOSE" --continue --show-progress -N http://"$CMIRROR/$RPATH/$IFILE".md5 http://"$CMIRROR/$RPATH/$IFILE"
else
curl "$DMVERBOSE" -C - --fail --retry 4 -OL {"http://$CMIRROR/$RPATH/$IFILE.md5,http://$CMIRROR/$RPATH/$IFILE"}
fi
}
_FTCHSTND_() {
FSTND=1
_PRINTCONTACTING_
if [[ "$DM" = aria2 ]]
then
aria2c http://"$CMIRROR" 1>"$TMPDIR/global2localmirror"
NLCMIRROR="$(grep Redirecting "$TMPDIR/global2localmirror" | awk {'print $8'})"
_PRINTDONE_
_PRINTDOWNLOADINGFTCH_
aria2c --continue -m 4 -Z "$NLCMIRROR/$RPATH/$IFILE".md5 "$NLCMIRROR/$RPATH/$IFILE"
elif [[ "$DM" = axel ]]
then
axel -vv http://"$CMIRROR" 1 > "$TMPDIR/global2localmirror"
NLCMIRR="$(grep downloading "$TMPDIR/global2localmirror" | awk {'print $5'})"
NLCMIRROR="${NLCMIRR::-3}"
_PRINTDONE_
_PRINTDOWNLOADINGFTCH_
axel -a --no-clobber http://"$NLCMIRROR/$RPATH/$IFILE".md5 ||:
axel -a --no-clobber http://"$NLCMIRROR/$RPATH/$IFILE" ||:
elif [[ "$DM" = lftp ]]
then
lftp -e get http://"$CMIRROR" 2>&1 | tee>"$TMPDIR/global2localmirror"
NLCMI="$(grep direct "$TMPDIR/global2localmirror" | awk {'print $5'})"
NLCMIRR="${NLCMI//\`}"
NLCMIRROR="${NLCMIRR//\'}"
_PRINTDONE_
_PRINTDOWNLOADINGFTCH_
lftpget -c "$NLCMIRROR/$RPATH/$IFILE".md5 "$NLCMIRROR/$RPATH/$IFILE"
elif [[ "$DM" = wget ]]
then
wget -v -O/dev/null "$CMIRROR" 2>"$TMPDIR/global2localmirror"
NLCMIRROR="$(grep Location "$TMPDIR/global2localmirror" | awk {'print $2'})"
_PRINTDONE_
_PRINTDOWNLOADINGFTCH_
wget "$DMVERBOSE" --continue --show-progress "$NLCMIRROR/$RPATH/$IFILE".md5 "$NLCMIRROR/$RPATH/$IFILE"
else
curl -v "$CMIRROR" &> "$TMPDIR/global2localmirror"
NLCMIRROR="$(grep Location "$TMPDIR/global2localmirror" | awk {'print $3'})"
NLCMIRROR="${NLCMIRROR%$'\r'}" # remove trailing carrage return: strip bash variable of non printing characters
_PRINTDONE_
_PRINTDOWNLOADINGFTCH_
curl "$DMVERBOSE" -C - --fail --retry 4 -OL {"$NLCMIRROR/$RPATH/$IFILE.md5,$NLCMIRROR/$RPATH/$IFILE"}
fi
rm -f "$TMPDIR/global2localmirror"
}
_GETIMAGE_() {
_PRINTDOWNLOADINGX86_
if [[ "$DM" = aria2 ]]
then
aria2c http://"$CMIRROR/$RPATH/$IFILE".md5
_ISX86_
aria2c --continue http://"$CMIRROR/$RPATH/$IFILE"
elif [[ "$DM" = axel ]]
then
axel -a --no-clobber http://"$CMIRROR/$RPATH/$IFILE".md5 ||:
_ISX86_
axel -a --no-clobber http://"$CMIRROR/$RPATH/$IFILE" ||:
elif [[ "$DM" = lftp ]]
then
lftpget http://"$CMIRROR/$RPATH"/md5sums.txt || lftpget http://"$CMIRROR/$RPATH"/md5sums.txt
_ISX86_
lftpget -c http://"$CMIRROR/$RPATH/$IFILE" || lftpget -c http://"$CMIRROR/$RPATH/$IFILE"
elif [[ "$DM" = wget ]]
then
wget "$DMVERBOSE" -N --show-progress http://"$CMIRROR/$RPATH/"md5sums.txt
_ISX86_
wget "$DMVERBOSE" --continue --show-progress http://"$CMIRROR/$RPATH/$IFILE"
else
curl "$DMVERBOSE" --fail --retry 4 -OL http://"$CMIRROR/$RPATH"/md5sums.txt
_ISX86_
curl "$DMVERBOSE" -C - --fail --retry 4 -OL http://"$CMIRROR/$RPATH/$IFILE"
fi
}
_ISX86_() {
if [[ "$CPUABI" = "$CPUABIX86" ]]
then
IFILE="$(grep i686 md5sums.txt | awk {'print $2'} ||:)"
else
IFILE="$(grep boot md5sums.txt | awk {'print $2'} ||:)"
fi
sed '2q;d' md5sums.txt > "$IFILE".md5 2>/dev/null ||:
rm -f md5sums.txt
rm -f \.md5
_PRINTDOWNLOADINGX86TWO_
}
# getimagefunctions.bash FE