grenade/setup-grenade
Andreas Jaeger 7f7e515de6 Switch to opendev URLs
Change URLs to use opendev instead of openstack.

Change-Id: I9bbd64615a689efba3a20d5f9d10bdb178c68ef4
2020-02-27 09:59:40 +01:00

50 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
# setup-grenade [hostname [username]]
#
# Assumes ssh keys set up to an account with root privs
# Configuration:
# * Reads ``grenaderc`` (and ``localrc``) if present;
# * Reads ``localrc`` if present and ``grenaderc`` is not present
# * Runs with sane defaults if no ``*rc`` file is present
# Keep track of the source directory
SRC_DIR=$(cd $(dirname "$0") && pwd)
# Set up some defaults if grenaderc is not present
GRENADE_REPO=https://opendev.org/openstack/grenade
GRENADE_DIR=${STACK_ROOT}/grenade
GRENADE_BRANCH=master
STACK_ROOT=/opt/stack
GRENADE_DIR=${STACK_ROOT}/grenade
# Source params
if [[ -r $SRC_DIR/grenaderc ]]; then
source $SRC_DIR/grenaderc
elif [[ -r $SRCDIR/localrc ]]; then
source $SRC_DIR/localrc
fi
HOST=${1:-localhost}
DEST_USER=${2:-${USER:-stack}}
set -o xtrace
ssh -t $DEST_USER@$HOST " \
sudo mkdir -p ${STACK_ROOT}; \
[[ -w ${STACK_ROOT} ]] || sudo chown $DEST_USER ${STACK_ROOT}; \
[[ -d $GRENADE_DIR ]] || (cd ${STACK_ROOT}; git clone $GRENADE_REPO $GRENADE_DIR); \
[[ -d $GRENADE_DIR ]] && (cd $GRENADE_DIR; git checkout $GRENADE_BRANCH); \
"
# Copy devstack.localrc if it exists
if [[ -r $SRC_DIR/devstack.localrc ]]; then
scp -p $SRC_DIR/devstack.localrc $DEST_USER@$HOST:$GRENADE_DIR
fi
# Copy localrc if it exists
if [[ -r $SRC_DIR/localrc ]]; then
scp -p $SRC_DIR/localrc $DEST_USER@$HOST:$GRENADE_DIR
fi