commit a2e5c666d55afb1319cee9e986272fde22b2d826 Author: Fanir Date: Mon Mar 21 01:20:31 2022 +0100 created gamedl with build, hbd and itch-download commands diff --git a/gamedl b/gamedl new file mode 100755 index 0000000..8183fb2 --- /dev/null +++ b/gamedl @@ -0,0 +1,75 @@ +#!/usr/bin/env bash + +set -o errexit +set -o nounset + +IMAGE=gamedl +CONTAINER=$IMAGE + +function build_image () { + echo "building $IMAGE..." + # docker build --tag "$IMAGE" . + + docker build --tag "$IMAGE" - << EOF +FROM python:3-alpine +RUN apk add --no-cache git +RUN pip install itchiodl +WORKDIR /usr/src/humble-dl +RUN \ + git clone 'https://github.com/xtream1101/humblebundle-downloader.git' . &&\ + wget -O trovefix.patch 'https://patch-diff.githubusercontent.com/raw/xtream1101/humblebundle-downloader/pull/59.patch' &&\ + git apply trovefix.patch &&\ + pip install -e . +CMD echo "Usage: gamedl []" +EOF +} + +function check_image () { + if ! (docker image inspect "$IMAGE" >/dev/null); then + echo "cannot access docker image $IMAGE, it probably does not exist." + + while true; do + read -p "build image? [yn] " yn + case $yn in + [Yy]* ) build_image; exit ;; + [Nn]* ) echo "bye"; exit ;; + * ) echo "Please answer yes or no." ;; + esac + done + fi +} + +function run_image () { + echo "mounting your local working dir as /dl" + docker run -u $(id -u):$(id -g) -v $PWD:/dl -it --rm --name "$CONTAINER" "$IMAGE" "$@" +} + +function show_help () { + echo "Usage $0 [] +Commands: + hbd + Run the Humble downloader. + itch-download + Run the Itch.io downloader. + + build + (Re)build the gamedl-image. + help + That is what you are reading now. +" +} + +cmd="help" +if [ $# -ge 1 ]; then + cmd="$1" +fi + +case "$cmd" in + help | h | -h ) + show_help; exit ;; + build ) + build_image; exit ;; + * ) + run_image $@; exit ;; +esac +