Merge pull request #8 from lemniskett/curl-fallback

Req #7: Add more support for other downloaders.
This commit is contained in:
Lemniskett 2021-01-23 15:49:50 +07:00 committed by GitHub
commit 6166f472c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 2 deletions

View File

@ -6,7 +6,9 @@ Ever since I'm running some niche distros like Void, Solus, I had a problem find
### Dependencies
- Bash
- Sed
- Wget
- Curl
- Wget (Optional: use ```wget``` when it's installed)
- Aria2 (Optional: use ```aria2c``` when it's installed)
- Tar
- Desktop-file-utils
- Xorg-xhost (Optional: allowing users in Archbox to access X server)

View File

@ -39,6 +39,18 @@ OPTIONS:
EOF
}
fetch_tarball(){
if hash aria2c 2>/dev/null; then
aria2c -o archlinux.tar.gz $1
elif hash wget 2>/dev/null; then
wget -O archlinux.tar.gz $1
elif hash curl 2>/dev/null; then
curl -o archlinux.tar.gz $1
else
err "No supported downloader found."
fi
}
err(){
echo "$(tput bold)$(tput setaf 1)==> $@ $(tput sgr0)" 1>&2
exit 1
@ -57,7 +69,7 @@ case $1 in
cd $INSTALL_PATH
msg "Downloading Arch Linux tarball..."
checkdep wget
while true; do wget -O archlinux.tar.gz $2 && break; done
while true; do fetch_tarball $2 && break; done
msg "Extracting the tarball..."
checkdep tar
tar xzf archlinux.tar.gz