#!/bin/sh MITAMAE_VERSION=v1.14.0 usage() { echo "Usage: $0 " echo "Available hosts:" find mitamae -name 'node.*.json' | sed -e 's#^mitamae/node[.]##' -e 's#.json##' | sort | sed -e 's/^/ * /' } # Check arguments. if [ $# != 1 ]; then usage >&2 exit 1 fi target_host="$1" if [ ! -f "mitamae/node.${target_host}.json" ]; then usage >&2 exit 1 fi target_arch="$(grep targetArch "mitamae/node.${target_host}.json" | sed -e 's/.*: "//' -e 's/",//')" # Prepare directory. if [ ! -d .bootstrap ]; then mkdir .bootstrap fi # Install mitamae. if [ ! -f .bootstrap/mitamae.tar.gz ]; then curl -L -o .bootstrap/mitamae.tar.gz \ "https://github.com/itamae-kitchen/mitamae/releases/download/${MITAMAE_VERSION}/mitamae-${target_arch}.tar.gz" fi if [ ! -f .bootstrap/mitamae ]; then tar xf .bootstrap/mitamae.tar.gz -C .bootstrap mv ".bootstrap/mitamae-${target_arch}" .bootstrap/mitamae fi # Run mitamae. .bootstrap/mitamae local \ --node-json "mitamae/node.${target_host}.json" \ mitamae/default.rb