-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild_and_start_apps.sh
executable file
·114 lines (93 loc) · 3.82 KB
/
build_and_start_apps.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/usr/bin/env bash
set -e
ROOT_DIR="$(dirname "$0")"
cd "$ROOT_DIR"
ROOT_DIR=$(pwd)
source lib.sh
clone_and_cd() {
local PROJECT="$1"
cd "$ROOT_DIR"
clone "$ROOT_DIR" "$PROJECT"
cd "$PROJECT"
git checkout verify-build
}
build() {
local PROJECT="$1"
clone_and_cd "$PROJECT"
set_build_number
fixup_repos "$PROJECT"
if [ "$PROJECT" = "verify-service-provider" ] || [ "$PROJECT" = "verify-local-matching-service-example" ] ; then
./gradlew -Dorg.gradle.daemon=false clean test distZip
else
./gradlew -Dorg.gradle.daemon=false clean test zip
if [ "$PROJECT" = "verify-hub" ]; then
./gradlew -Dorg.gradle.daemon=false publishToMavenLocal # for hub-saml
fi
fi
mkdir -p ../output/bin
find . -type f -name '*.zip' -exec cp {} ../output/bin/ \; || echo "failed to copy a zip file, continuing..."
}
# clone all the apps and compile them - output exported to `cache/output`
build "verify-hub"
build "verify-matching-service-adapter"
build "verify-service-provider"
build "verify-test-rp"
build "verify-stub-idp"
# get the frontend ready to start
PROJECT="verify-frontend"
clone_and_cd "$PROJECT"
eval "$(rbenv init -)"
rbenv local 2.4.0
gem install bundler -v '<2.0'
rbenv rehash
sed -i "s/ruby '2.4.2'/ruby '2.4.0'/g" Gemfile
bundle check || bundle install
# start postgres
sudo service postgresql start
# note that the database is not accessible from outside this container
# which is good because this command sets the password to 'password' which is generally a
# very bad idea and not recommended
sudo -u postgres psql -U postgres -d postgres -c "alter user postgres with password 'password';"
# you can change this to the external IP of your machine to be able to access the apps
# on a separate machine
export EXTERNAL_HOST=127.0.0.1
# clone the startup scripts and make sure app logs are readable outside the container
PROJECT="verify-local-startup"
clone_and_cd "$PROJECT"
mkdir -p ../output/logs
ln -s ../output/logs logs
git checkout verify-build
rbenv local 2.4.0
gem install bundler
rbenv rehash
# start the apps
GOPATH="$HOME/go" PATH="$HOME/go/bin":$PATH ./startup-jars.sh
set +e
MSA_METADATA_URL="http://localhost:3300/matching-service/SAML2/metadata" MSA_ENTITY_ID="http://localhost:3300/matching-service/SAML2/metadata" GOPATH="$HOME/go" PATH="$HOME/go/bin":$PATH ./vsp-startup.sh
set -e
cd "$ROOT_DIR"
./generate_eidas_metadata.sh
# create the database for passport-verify-stub-relying-party
cd "$ROOT_DIR"
sudo -u postgres createdb stub_rp_test
export DATABASE_CONNECTION_STRING="jdbc:postgresql://localhost:5432/stub_rp_test?user=postgres&password=password"
# use the correct local matching service for passport-verify-stub-relying-party
# this needs to run first because it sets up the database
build "verify-local-matching-service-example"
./gradlew installDist --no-daemon
DB_URI=$DATABASE_CONNECTION_STRING PORT=50500 ./build/install/verify-local-matching-service-example/bin/verify-local-matching-service-example server verify-local-matching-service-example.yml > ../verify-local-startup/logs/verify-local-matching-service-example_console.log 2>&1 &
# start the stub relying party frontend
PROJECT="passport-verify-stub-relying-party"
clone_and_cd "$PROJECT"
# the verify-local-matching-service-example should have set up the database
# sudo -u postgres psql -U postgres -d stub_rp_test -f passport-verify-stub-relying-party/database-schema.sql
npm install
export ENTITY_ID="http://localhost:50400/metadata"
export DATABASE_CONNECTION_STRING="postgresql://postgres:password@localhost:5432/stub_rp_test"
DEBUG='passport-verify:*' ./startup.sh >../verify-local-startup/logs/passport-verify-stub-relying-party_console.log 2>&1 &
# check if all the apps are running
cd "$ROOT_DIR"
./check_apps.sh
echo "everything started!"
# start a shell, apps will be stopped when you exit
bash