aboutsummaryrefslogtreecommitdiffstats
path: root/fetchpk3.sh
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xfetchpk3.sh60
1 files changed, 49 insertions, 11 deletions
diff --git a/fetchpk3.sh b/fetchpk3.sh
index 7c2394e..fae9520 100755
--- a/fetchpk3.sh
+++ b/fetchpk3.sh
@@ -5,15 +5,53 @@
5 exit 1 5 exit 1
6} 6}
7 7
8mkdir -p "$DIR" 8SCRIPT_DIR=$(cd "$(dirname "$0")" 2>/dev/null && pwd)
9 9DIR="$SCRIPT_DIR/$DIR"
10wget -nc -nd -r -l1 --no-parent -A '*.pk3' -P "$DIR" "$URL" \ 10
11|| { 11setup() {
12 echo "wget not present, fallback to curl..." 12 mkdir -p "$DIR"
13 curl -s "$URL" \ 13 command -v wget >/dev/null 2>&1 \
14 | grep -o 'href="[^"]*\.pk3"' \ 14 || command -v curl >/dev/null 2>&1 \
15 | cut -d'"' -f2 \ 15 || {
16 | while read -r f; do 16 echo "Error: neither wget nor curl is installed."
17 [ -f "$DIR/$f" ] || curl -# -o "$DIR/$f" "$URL/$f" 17 echo "Please install wget or curl."
18 done 18 exit 1
19 }
20}
21
22fetch_pk3() {
23 SRC_URL="$1"
24 echo "Source: $SRC_URL"
25 command -v wget >/dev/null 2>&1 \
26 && wget -nc -nd -r -l1 --no-parent -A '*.pk3' -P "$DIR" "$SRC_URL" \
27 && return
28 echo "wget not available, using curl..."
29 curl -s "$SRC_URL" \
30 | grep '\.pk3"' \
31 | cut -d'"' -f2 \
32 | while read -r f; do
33 TARGET="$DIR/$f"
34 [ -s "$TARGET" ] && echo "✓ exists: $f" && continue
35 echo "↓ downloading: $f"
36 curl -s -o "$TARGET" "$SRC_URL/$f"
37 done
38}
39
40game() {
41 echo "Fetching base game pk3 files..."
42 fetch_pk3 "$URL"
19} 43}
44
45maps() {
46 echo "Fetching baseq3 pk3 files (maps + base)..."
47 fetch_pk3 "$MAP_URL"
48}
49
50main() {
51 setup
52 game
53 maps
54 echo "All pk3 files fetched into $DIR"
55}
56
57main