|
| 1 | +#!/bin/sh - |
| 2 | +# |
| 3 | +# Copyright (c) 2023 Jason R. Thorpe. |
| 4 | +# All rights reserved. |
| 5 | +# |
| 6 | +# Redistribution and use in source and binary forms, with or without |
| 7 | +# modification, are permitted provided that the following conditions |
| 8 | +# are met: |
| 9 | +# 1. Redistributions of source code must retain the above copyright |
| 10 | +# notice, this list of conditions and the following disclaimer. |
| 11 | +# 2. Redistributions in binary form must reproduce the above copyright |
| 12 | +# notice, this list of conditions and the following disclaimer in the |
| 13 | +# documentation and/or other materials provided with the distribution. |
| 14 | +# |
| 15 | +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 16 | +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 17 | +# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 18 | +# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 19 | +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
| 20 | +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 21 | +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
| 22 | +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 23 | +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 24 | +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 25 | +# SUCH DAMAGE. |
| 26 | +# |
| 27 | + |
| 28 | +# |
| 29 | +# pakslurp -- |
| 30 | +# |
| 31 | +# A simple script that will slurp down the PAK cycles of the NabuRetroNet |
| 32 | +# cycles to your local machine. This is useful if you want to serve the |
| 33 | +# files locally. |
| 34 | +# |
| 35 | + |
| 36 | +base_url="https://cloud.nabu.ca" |
| 37 | +max_image_number=767 # this seems to be the upper bound (0x300-1) |
| 38 | + |
| 39 | +# |
| 40 | +# If you're lucky[*] enough to have Luke Mewburn's enhanced ftp client (that |
| 41 | +# can also download stuff from HTTP servers), tnen you don't have to bother |
| 42 | +# with curl. |
| 43 | +# |
| 44 | +# [*] If you run NetBSD, then you are so lucky. |
| 45 | +# |
| 46 | +# XXX curl doesn't always seem to work. Use at your own risk. Better yet, |
| 47 | +# install Luke's enhanced ftp client. |
| 48 | +# |
| 49 | +# https://ftp.netbsd.org/pub/NetBSD/misc/tnftp/ |
| 50 | +# |
| 51 | +URL_DOWNLOAD=ftp |
| 52 | +#URL_DOWNLOAD="curl -f" |
| 53 | + |
| 54 | +slurp_one_pak() |
| 55 | +{ |
| 56 | + # |
| 57 | + # Args: |
| 58 | + # |
| 59 | + # $1 base URL |
| 60 | + # $2 directory in which to save slurped file |
| 61 | + # $3 image number |
| 62 | + # |
| 63 | + local hexnum |
| 64 | + local filename |
| 65 | + |
| 66 | + hexnum=`printf "%06X" $3` |
| 67 | + filename="${hexnum}.pak" |
| 68 | + |
| 69 | + $URL_DOWNLOAD -o "$2/$filename" "$1/$filename" |
| 70 | +} |
| 71 | + |
| 72 | +slurp_cycle() |
| 73 | +{ |
| 74 | + # |
| 75 | + # Args: |
| 76 | + # |
| 77 | + # $1 base URL |
| 78 | + # $2 directory in which to save slurped files |
| 79 | + # |
| 80 | + local image_number |
| 81 | + |
| 82 | + image_number=0 |
| 83 | + while [ "$image_number" -le "$max_image_number" ]; do |
| 84 | + slurp_one_pak $1 $2 $image_number |
| 85 | + image_number=$(expr $image_number + 1) |
| 86 | + done |
| 87 | +} |
| 88 | + |
| 89 | +mkdir -p cycle1 |
| 90 | +slurp_cycle "$base_url/cycle%201%20raw" cycle1 |
| 91 | + |
| 92 | +mkdir -p cycle2 |
| 93 | +slurp_cycle "$base_url/cycle%202%20raw" cycle2 |
| 94 | + |
| 95 | +mkdir -p cycleDJ |
| 96 | +slurp_cycle "$base_url/cycle%20DJ%20raw" cycleDJ |
0 commit comments