Skip to content
Snippets Groups Projects
Commit d48f77f8 authored by Yordan Kinkov's avatar Yordan Kinkov
Browse files

#4 add setup script

parent ffe88ddc
No related branches found
No related tags found
1 merge request!2Resolve "Setup script"
setup.sh 0 → 100755
#! /bin/bash
# ------------
# IMPORTANT!
#
# This script uses an environment variable named 'email' to properly
# configure git repos upon checkout. If you don't have it set in your
# environment, the email of the git repos will be set to an empty value.
# For best experience, set the variable in your .bashrc, .zshrc, etc.
#
# export email="lyuben.penkovski@vereign.com"
# ------------
# pull the master branch of a given git repository.
# User will be prompted for manual action if another branch is checked out or a problem occurs.
# $1 - name of the repo to pull.
function pull() {
local repo=$1
pushd "${repo}"
local branch=`git rev-parse --abbrev-ref HEAD`
if [ $branch == "master" ]; then
echo "Pulling ${repo}/master..."
git pull origin master || read -p "Could not pull ${repo}/master. Fix the issue and press ENTER to continue:"
else
echo "${repo}/${branch} is checked out"
read -p "Pull ${repo} manually now or press ENTER to skip:"
fi
popd
}
# getServices clones or pulls the services with separate repos
# in ${GOPATH}/src/code.vereign.com/gaiax/tsa
function getServices() {
local GAIAX_TSA_DIR="${GOPATH}/src/code.vereign.com/gaiax/tsa"
mkdir -p "${GAIAX_TSA_DIR}" && cd "$_"
local services=(
"infohub"
)
for repo in ${services[@]}; do
echo
if [ -d "${repo}" ]; then
pull $repo
continue
fi
mkdir -p "$GAIAX_TSA_DIR/$repo" && pushd "$GAIAX_TSA_DIR/$repo"
echo "Cloning $repo repository to $GAIAX_TSA_DIR/$repo"
git clone "ssh://git@code.vereign.com/gaiax/tsa/${repo}.git" .
if [ ! -d "./vendor" ]; then
go mod tidy && go mod vendor # download dependencies to vendor
fi
git config user.email $EMAIL && popd
done
}
getServices
echo
echo "All repos are updated successfully."
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment