forked from GEO-BON/bon-in-a-box-pipelines
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathserver-up.sh
executable file
·49 lines (41 loc) · 1.51 KB
/
server-up.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
#!/bin/bash
# Start the BON in a Box microservices locally.
# The UI can then be accessed throught the localhost of this machine.
# Optional arg 1: branch name of server repo, default "main"
branch=${1:-"main"}
shift
# Additionnal optional args will be appended to the docker compose up command.
# Typical use is to give a specific service name to (re)start only that one.
options=$@
RED="\033[31m"
ENDCOLOR="\033[0m"
function assertSuccess {
if [[ $? -ne 0 ]] ; then
echo -e "${RED}FAILED${ENDCOLOR}" ; exit 1
fi
}
echo "Updating server init script..."
if cd .server; then
# Check for a branch change
remoteFetch="+refs/heads/$branch:refs/remotes/origin/$branch"
if [[ "$(git config remote.origin.fetch)" != $remoteFetch ]]; then
echo "Switching to branch $branch..."
# Change branch restriction of shallow repo.
# We are not really changing branch but just allowing to checkout individual files from that other branch.
git config remote.origin.fetch "$remoteFetch"
# Delete all except .git, . and ..
ls -a | grep -Ev "^(\.git|\.|\.\.)$" | xargs rm -r
fi
git fetch --no-tag --depth 1 origin $branch
assertSuccess
else
git clone -n git@github.com:GEO-BON/bon-in-a-box-pipeline-engine.git --branch $branch --single-branch .server --depth 1
assertSuccess
cd .server
assertSuccess
fi
echo "Using branch $branch."
git checkout origin/$branch -- prod-server.sh
assertSuccess
./prod-server.sh checkout $branch
./prod-server.sh up $options