This repository has been archived by the owner on Jun 17, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 41
/
gac-new.sh
executable file
·65 lines (53 loc) · 2.29 KB
/
gac-new.sh
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
set -eo pipefail
# Make sure that we are using `find`/`xargs` from GNU and not the (gasp) BSD version 😒
PATH=$(nix-build -E "(import ${gacroot:?} {}).pkgs.findutils" --no-out-link)/bin:$PATH
# disable shellcheck complaining about undeclared variables:
# `overlayroot` is declared in `gac.sh` which sources this file (it is not meant to be called directly)
# shellcheck disable=SC2154
case "$1" in
-h | --help | help )
cat <<EOF
$(basename "$0") new CLUSTER-NAME [OPS-BRANCH-NAME] [CLUSTER-TYPE] [CLUSTER-KIND]
Sets up a new, named deployment checkout for a cluster of type CLUSTER_TYPE
for subsequent deployment.
The CLUSTER-NAME will be used both for the ops checkout directory, and
the Nixops deployment.
Available cluster types: $(cd "${overlayroot}/clusters" ; find . -mindepth 1 -maxdepth 1 -type d -printf '%f\0' | xargs -0)
Generals documentation: https://github.com/input-output-hk/iohk-ops/blob/goguen-ala-cardano/docs/Goguen-clusters-HOWTO.org
EOF
exit 1;;
esac;
CLUSTER_NAME="$1"; test -n "$1" && shift
BRANCH_NAME="${1:-${DEFAULT_OPS_BRANCH}}"; test -n "$1" && shift
CLUSTER_TYPE="${1:-${CLUSTER_TYPE}}"; test -n "$1" && shift
CLUSTER_KIND="${1:-${CLUSTER_KIND}}"; test -n "$1" && shift
set -u
while test -d "${CLUSTER_NAME}" -o -z "${CLUSTER_NAME}" || nixops info -d "${CLUSTER_NAME}" >/dev/null 2>/dev/null
do if test -z "${CLUSTER_NAME}"
then message="Please enter cluster name: "
else message="Cluster '${CLUSTER_NAME}' already exists, please choose another name: "
fi
read -rei "${CLUSTER_NAME}" -p "${message}" CLUSTER_NAME
done
git clone "${OPS_REPO}" "${CLUSTER_NAME}"
cd "${CLUSTER_NAME}"
git checkout "${BRANCH_NAME}"
git submodule update --init
cat > .config.sh <<EOF
CLUSTER_KIND=${CLUSTER_KIND}
CLUSTER_TYPE=${CLUSTER_TYPE}
CLUSTER_NAME=${CLUSTER_NAME}
CONFIG=default
EOF
$GAC_CENTRAL list-cluster-components
log "Generating node keys"
verbose=${verbose:-}
$GAC_CENTRAL "${verbose}" generate-node-keys
log "creating the Nixops deployment.."
nixops create -d "${CLUSTER_NAME}" "clusters/${CLUSTER_TYPE}"/*.nix
$GAC_CENTRAL configure-nixops-deployment-arguments
log "cluster has been set up, but not deployed; Next steps:"
log " 1. cd ${CLUSTER_NAME}"
log " 2. ./enter.sh"
log " 3. gac deploy"