Skip to content

Commit

Permalink
Much streamline, such good code, very downloading
Browse files Browse the repository at this point in the history
run without wget, bash, and sed
  • Loading branch information
whatwareweb authored Aug 14, 2022
2 parents 1b6e2e9 + 2338563 commit 2eed77d
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 167 deletions.
14 changes: 3 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
# BashRDL
# shRDL
Cydia repo downloader/archiver written in Bash


### Syntax:
./bashrdl.sh [http(s)://apt.cydiarepo.url] [y/n] [y/n] [y/n]

1st y/n argument: whether or not to delete Packages file

2nd y/n argument: whether or not to delete deburllist.txt file

3rd y/n argument: whether or not to auto download all debs
./shrdl.sh [repo url]

### Dependencies:
- GNU core utils
- bzip2
- gzip
- curl
- wget
156 changes: 0 additions & 156 deletions bashrdl.sh

This file was deleted.

15 changes: 15 additions & 0 deletions bulkrdl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh
if ! [ -f shrdl.sh ]; then
printf "shrdl.sh not found.\n"
printf "make sure shrdl.sh in in the same directory as this script.\n"
exit 1
elif ! [ -f repolist.txt ]; then
printf "repolist.txt file not found.\n"
printf "Create a file in the same directory as this script containing the URLs for repos you want to download"
exit 1
fi

while read -r line; do
printf "Downloading repo: %s\n" "$line"
./shrdl.sh "$line"
done < ./repolist.txt
83 changes: 83 additions & 0 deletions shrdl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/bin/sh
case $1 in
-v|--version)
printf "shRDL 2.0\n"
exit 0
;;

http://*|https://*)
set "${1%/}"
repodomain=${1#*//}
;;

*)
cat <<EOF
shRDL - Downloads deb packages from Cydia repositories
Usage:
shrdl.sh [URL]
-h, --help Print this message
-v, --version Print version info
EOF
exit 0
;;
esac

for cmd in curl gunzip bunzip2 sed; do
if ! command -v $cmd > /dev/null; then
printf "%s not found, please install %s\n" "$cmd" "$cmd"
exit 1
fi
done

gzcode=$(curl -H "X-Machine: iPod4,1" -H "X-Unique-ID: 0000000000000000000000000000000000000000" -H "X-Firmware: 6.1" -H "User-Agent: Telesphoreo APT-HTTP/1.0.999" --write-out '%{http_code}' -L --silent --output /dev/null "$1/Packages.gz")
bz2code=$(curl -H "X-Machine: iPod4,1" -H "X-Unique-ID: 0000000000000000000000000000000000000000" -H "X-Firmware: 6.1" -H "User-Agent: Telesphoreo APT-HTTP/1.0.999" --write-out '%{http_code}' -L --silent --output /dev/null "$1/Packages.bz2")

if [ "$gzcode" -eq 200 ]; then
printf "Downloading Packages.gz\n"
archive=gz
elif [ "$bz2code" -eq 200 ]; then
printf "Downloading Packages.bz2\n"
archive=bz2
else
printf "Couldn't find a Packages file. Exiting\n"
exit 1
fi

[ ! -d "$repodomain" ] && mkdir -p "$repodomain"
cd "$repodomain" || exit 1
rm -f urllist.txt

curl -H "X-Machine: iPod4,1" -H "X-Unique-ID: 0000000000000000000000000000000000000000" -H "X-Firmware: 6.1" -H "User-Agent: Telesphoreo APT-HTTP/1.0.999" -L -# -O "$1/Packages.$archive"

if [ "$archive" = "gz" ]; then
gunzip ./Packages.gz
elif [ "$archive" = "bz2" ]; then
bunzip2 ./Packages.bz2
fi

while read -r line; do
case $line in
Filename:*)
deburl=${line#Filename: }
case $deburl in
./*)
deburl=${deburl#./}
;;
esac
printf "%s/%s\n" "$1" "$deburl" >> urllist.txt
;;
esac
done < ./Packages

[ ! -d debs ] && mkdir debs
cd debs || exit 1

while read -r i; do
printf "Downloading %s\n" "${i##*/}"
curl -H "X-Machine: iPod4,1" -H "X-Unique-ID: 0000000000000000000000000000000000000000" -H "X-Firmware: 6.1" -H "User-Agent: Telesphoreo APT-HTTP/1.0.999" -g -L -# -O "$i"
done < ../urllist.txt
cd ../..

printf "Done!\n"

0 comments on commit 2eed77d

Please sign in to comment.