#!/bin/sh

set -e

BASE="$HOME/.pwn/ubidump"

if [[ ! -d "$BASE/bin" ]]; then
	if [[ ! -d "$BASE/src" ]]; then
		git clone --depth 1 --recursive \
			https://github.com/ticarpi/ubidump.git \
			"$BASE/src"
	fi
	pip3 install --no-cache-dir --user \
		--requirement "$BASE/src/requirements.txt"
	ln -s "$BASE/src/ubidump.py" "$BASE/bin/ubidump.py"
	chmod +x "$BASE/bin/ubidump.py"
fi

python3 "$BASE/bin/ubidump.py" "$@"
