aboutsummaryrefslogtreecommitdiffhomepage
path: root/bootstrap
blob: 860d49984c2474c754496aacf4ca7577dbecb9d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/sh

MITAMAE_VERSION=v1.14.0

usage() {
    echo "Usage: $0 <host>"
    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