Skip to content

Instantly share code, notes, and snippets.

@starstuck
Last active April 1, 2019 10:42
Show Gist options
  • Save starstuck/6d747c7ee7b2bc9b81c0630f56020433 to your computer and use it in GitHub Desktop.
Save starstuck/6d747c7ee7b2bc9b81c0630f56020433 to your computer and use it in GitHub Desktop.
Restic multi-arch wrapper
#!/usr/bin/env bash
# -*- sh -*-
#
# This script runs right restic executable for system where it is called.
# Download restic releases to ../libexec folder and update VERSION valriable.
# It will also set RESTIC_REPOSITORY, based on assumption that the script lies
# in bin folder in the repository.
VERSION="0.9.3"
SYS=$(uname -s | tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m)
case "${ARCH}" in
"x86_64")
ARCH="amd64"
;;
"armv7l")
ARCH="arm"
;;
"armv8")
ARCH="arm64"
;;
"i386")
ARCH="386"
;;
"386" | "amd64" | "arm" | "arm64")
;;
*)
echo "Unsupported architecture ${ARCH}" 1>&2
exit -1
esac
BASEDIR="$(dirname ${0})/.."
CMD="${BASEDIR}/libexec/restic_${VERSION}_${SYS}_${ARCH}"
export "RESTIC_REPOSITORY=${BASEDIR}"
exec "${CMD}" "${@}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment