#!/bin/sh
# Install oras binary to dst directory

set -e

dst="${1:-/usr/local/bin}"

tmp=$(mktemp -d)
if [ -z "$tmp" ] || ! [ -d "$tmp" ]; then
    echo "Error by creating temp directory" >&2
    exit 1
fi
if which curl >/dev/null; then
    curl -L https://github.com/oras-project/oras/releases/download/v1.3.2/oras_1.3.2_linux_arm64.tar.gz -o - | \
    tar xz -C "$tmp"
else
    wget https://github.com/oras-project/oras/releases/download/v1.3.2/oras_1.3.2_linux_arm64.tar.gz -O - | \
    tar xz -C "$tmp"
fi
mv "$tmp"/oras "$dst"
rm -rf "$tmp"
chmod +x "$dst"/oras
