extract.sh 681 Bytes
Newer Older
noplanman's avatar
noplanman committed
1
#!/usr/bin/env sh
noplanman's avatar
noplanman committed
2

noplanman's avatar
noplanman committed
3
# Usage: ./extract.sh <arch> [<version>] [<binary_save_location>]
noplanman's avatar
noplanman committed
4

noplanman's avatar
noplanman committed
5 6 7
BORG_ARCH=${1}
BORG_VERSION=${2:-1.1.7}
BORG_BINARY=${3:-borg-${BORG_VERSION}-${BORG_ARCH}}
noplanman's avatar
noplanman committed
8

noplanman's avatar
noplanman committed
9 10 11 12 13 14
DOCKER_IMAGE=borg:${BORG_VERSION}-${BORG_ARCH}

if [ -z "${BORG_ARCH}" ]; then
    echo "Usage: ./build.sh <arch> [<version>]";
    echo "No arch provided";
    exit 1;
noplanman's avatar
noplanman committed
15 16
fi

noplanman's avatar
noplanman committed
17 18 19 20 21
if ! docker inspect "${DOCKER_IMAGE}" >/dev/null 2>&1; then
    echo "Couldn't find the '${DOCKER_IMAGE}' docker image!"
    echo "Create the image first, using './build.sh ${BORG_ARCH} ${BORG_VERSION}'"
    exit 1
fi
noplanman's avatar
noplanman committed
22

noplanman's avatar
noplanman committed
23
docker run --rm --entrypoint cat "${DOCKER_IMAGE}" /usr/bin/borg > "${BORG_BINARY}"
noplanman's avatar
noplanman committed
24
chmod +x "${BORG_BINARY}"