summaryrefslogtreecommitdiffstats
path: root/node-admin/scripts/populate-noderepo-with-local-nodes.sh
blob: 6d9a789426d249fe79b93978fd02ec0788bc4fbc (plain) (blame)
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
42
43
44
#!/bin/bash
# Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

set -e

source "${0%/*}/common.sh"

# Used to return response from RunCurl
declare CURL_RESPONSE

function Usage {
    UsageHelper "$@" <<EOF
Usage: $SCRIPT_NAME <command> [--num-nodes <num-nodes>]
Add Docker containers as nodes in the node repo, and activate them

Commands:
  start     Add and activate nodes
  stop      Remove nodes (not implemented)
  restart   Stop, then start

Options:
  --num-nodes <num-nodes>
            Activate <num-nodes> instead of the default $DEFAULT_NUM_APP_CONTAINERS.
EOF
}

function Stop {
    # TODO: Implement removal of the Docker containers from the node repo
    :
}

function Start {
    local -a hostnames=()

    local -i i=1
    for ((; i <= $NUM_APP_CONTAINERS; ++i)); do
        hostnames+=("$APP_HOSTNAME_PREFIX$i")
    done
    
    ./node-repo.sh add -c "$CONFIG_SERVER_HOSTNAME" -p "$HOSTNAME" \
                   "${hostnames[@]}"
}

Main "$@"