#!/bin/bash # Fetch the current installer first, instead of needing two runs to update it. set -eo pipefail ref="${1:-${MONKEYDEV_REF:-master}}" [[ "$#" -le 1 && "$ref" =~ ^[A-Za-z0-9_./-]+$ && "$ref" != -* && "$ref" != *..* ]] || { echo "Usage: md-update [Git ref]" >&2; exit 1; } installerSnapshot="$(mktemp -t monkeydev-update)" trap 'rm -f "$installerSnapshot"' EXIT if [[ -n "${MONKEYDEV_SOURCE_DIR:-}" ]]; then cp "$MONKEYDEV_SOURCE_DIR/bin/md-install" "$installerSnapshot" else /usr/bin/curl --fail --location --silent --show-error --retry 3 --connect-timeout 20 --max-time 180 \ --output "$installerSnapshot" "https://raw.githubusercontent.com/AloneMonkey/MonkeyDev/$ref/bin/md-install" fi /bin/bash -n "$installerSnapshot" /bin/bash "$installerSnapshot" "$ref"