forked from gary-archer/oauth.websample.final
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
executable file
·115 lines (87 loc) · 2.66 KB
/
run.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
115
#!/bin/bash
#################################################
# A script to run the SPA when developing locally
#################################################
cd "$(dirname "${BASH_SOURCE[0]}")"
WEB_ORIGIN='https://web.authsamples-dev.com'
#
# Get the platform
#
case "$(uname -s)" in
Darwin)
PLATFORM="MACOS"
;;
MINGW64*)
PLATFORM="WINDOWS"
;;
Linux)
PLATFORM="LINUX"
;;
esac
if [ "$1" == 'LOCALAPI' ]; then
#
# When connecting the SPA to a local API, deploy a token handler to run in Docker on the local development computer
#
./localtokenhandler/deployment/docker-local/deploy.sh
if [ $? -ne 0 ]; then
echo 'Problem encountered deploying the local token handler'
exit
fi
#
# Get OAuth agent logs to the local computer, which enables token handler log shipping when required
#
if [ ! -d '../oauth.logs' ]; then
mkdir '../oauth.logs'
fi
if [ ! -d '../oauth.logs/oauthagent' ]; then
mkdir '../oauth.logs/oauthagent'
fi
docker compose --project-name tokenhandler logs -f --no-log-prefix oauthagent >> ../oauth.logs/oauthagent/oauthagent.log &
fi
#
# Ensure that web components point to the correct API components
#
if [ "$1" == 'LOCALAPI' ]; then
cp deployment/environments/dev-localapi/spa.config.json spa/dist/spa.config.json
cp deployment/environments/dev-localapi/webhost.config.json webhost/webhost.config.json
else
cp deployment/environments/dev/spa.config.json spa/dist/spa.config.json
cp deployment/environments/dev/webhost.config.json webhost/webhost.config.json
fi
#
# Run the web host to serve static content
# On Linux first ensure that you have first granted Node.js permissions to listen on port 443:
# - sudo setcap 'cap_net_bind_service=+ep' $(which node)
#
#
if [ "$PLATFORM" == 'MACOS' ]; then
open -a Terminal ./webhost/run.sh
elif [ "$PLATFORM" == 'WINDOWS' ]; then
GIT_BASH="C:\Program Files\Git\git-bash.exe"
"$GIT_BASH" -c ./webhost/run.sh &
elif [ "$PLATFORM" == 'LINUX' ]; then
gnome-terminal -- ./webhost/run.sh
fi
#
# Wait for it to become available
#
echo 'Waiting for Web Host to become available ...'
while [ "$(curl -k -s -o /dev/null -w ''%{http_code}'' "$WEB_ORIGIN/spa/index.html")" != '200' ]; do
sleep 2
done
#
# Restore the default web host configuration once it is running
#
cp deployment/environments/dev/webhost.config.json webhost/webhost.config.json
#
# Run the SPA in the default browser, then sign in with these credentials:
# - guestuser@mycompany.com
# - Password1
#
if [ "$PLATFORM" == 'MACOS' ]; then
open "$WEB_ORIGIN/"
elif [ "$PLATFORM" == 'WINDOWS' ]; then
start "$WEB_ORIGIN/"
elif [ "$PLATFORM" == 'LINUX' ]; then
xdg-open "$WEB_ORIGIN/"
fi