3
3
# set -e: exit asap if a command exits with a non-zero status
4
4
set -e
5
5
6
+ echo " Starting Selenium Grid Hub..."
7
+
8
+ function append_se_opts() {
9
+ local option=" ${1} "
10
+ local value=" ${2:- " " } "
11
+ local log_message=" ${3:- true} "
12
+ if [[ " ${SE_OPTS} " != * " ${option} " * ]]; then
13
+ if [ " ${log_message} " = " true" ]; then
14
+ echo " Appending Selenium option: ${option} ${value} "
15
+ else
16
+ echo " Appending Selenium option: ${option} $( mask ${value} ) "
17
+ fi
18
+ SE_OPTS=" ${SE_OPTS} ${option} "
19
+ if [ ! -z " ${value} " ]; then
20
+ SE_OPTS=" ${SE_OPTS} ${value} "
21
+ fi
22
+ else
23
+ echo " Selenium option: ${option} already set in env variable SE_OPTS. Ignore new option: ${option} ${value} "
24
+ fi
25
+ }
26
+
6
27
if [ ! -z " $SE_OPTS " ]; then
7
28
echo " Appending Selenium options: ${SE_OPTS} "
8
29
fi
@@ -23,23 +44,19 @@ if [ ! -z "$SE_SUB_PATH" ]; then
23
44
fi
24
45
25
46
if [ ! -z " $SE_LOG_LEVEL " ]; then
26
- echo " Appending Selenium options: --log-level ${SE_LOG_LEVEL} "
27
- SE_OPTS=" $SE_OPTS --log-level ${SE_LOG_LEVEL} "
47
+ append_se_opts " --log-level" " ${SE_LOG_LEVEL} "
28
48
fi
29
49
30
50
if [ ! -z " $SE_HTTP_LOGS " ]; then
31
- echo " Appending Selenium options: --http-logs ${SE_HTTP_LOGS} "
32
- SE_OPTS=" $SE_OPTS --http-logs ${SE_HTTP_LOGS} "
51
+ append_se_opts " --http-logs" " ${SE_HTTP_LOGS} "
33
52
fi
34
53
35
54
if [ ! -z " $SE_STRUCTURED_LOGS " ]; then
36
- echo " Appending Selenium options: --structured-logs ${SE_STRUCTURED_LOGS} "
37
- SE_OPTS=" $SE_OPTS --structured-logs ${SE_STRUCTURED_LOGS} "
55
+ append_se_opts " --structured-logs" " ${SE_STRUCTURED_LOGS} "
38
56
fi
39
57
40
58
if [ ! -z " $SE_EXTERNAL_URL " ]; then
41
- echo " Appending Selenium options: --external-url ${SE_EXTERNAL_URL} "
42
- SE_OPTS=" $SE_OPTS --external-url ${SE_EXTERNAL_URL} "
59
+ append_se_opts " --external-url" " ${SE_EXTERNAL_URL} "
43
60
fi
44
61
45
62
if [ " ${SE_ENABLE_TLS} " = " true" ]; then
@@ -60,43 +77,35 @@ if [ "${SE_ENABLE_TLS}" = "true" ]; then
60
77
SE_JAVA_OPTS=" $SE_JAVA_OPTS -Djdk.internal.httpclient.disableHostnameVerification=${SE_JAVA_DISABLE_HOSTNAME_VERIFICATION} "
61
78
# Configure certificate and private key for component communication
62
79
if [ ! -z " $SE_HTTPS_CERTIFICATE " ]; then
63
- echo " Appending Selenium options: --https-certificate ${SE_HTTPS_CERTIFICATE} "
64
- SE_OPTS=" $SE_OPTS --https-certificate ${SE_HTTPS_CERTIFICATE} "
80
+ append_se_opts " --https-certificate" " ${SE_HTTPS_CERTIFICATE} "
65
81
fi
66
82
if [ ! -z " $SE_HTTPS_PRIVATE_KEY " ]; then
67
- echo " Appending Selenium options: --https-private-key ${SE_HTTPS_PRIVATE_KEY} "
68
- SE_OPTS=" $SE_OPTS --https-private-key ${SE_HTTPS_PRIVATE_KEY} "
83
+ append_se_opts " --https-private-key" " ${SE_HTTPS_PRIVATE_KEY} "
69
84
fi
70
85
fi
71
86
72
87
if [ ! -z " $SE_REGISTRATION_SECRET " ]; then
73
- echo " Appending Selenium options: --registration-secret $( mask ${SE_REGISTRATION_SECRET} ) "
74
- SE_OPTS=" $SE_OPTS --registration-secret ${SE_REGISTRATION_SECRET} "
88
+ append_se_opts " --registration-secret" " ${SE_REGISTRATION_SECRET} " " false"
75
89
fi
76
90
77
91
if [ ! -z " $SE_DISABLE_UI " ]; then
78
- echo " Appending Selenium options: --disable-ui ${SE_DISABLE_UI} "
79
- SE_OPTS=" $SE_OPTS --disable-ui ${SE_DISABLE_UI} "
92
+ append_se_opts " --disable-ui" " ${SE_DISABLE_UI} "
80
93
fi
81
94
82
95
if [ ! -z " $SE_ROUTER_USERNAME " ]; then
83
- echo " Appending Selenium options: --username ${SE_ROUTER_USERNAME} "
84
- SE_OPTS=" $SE_OPTS --username ${SE_ROUTER_USERNAME} "
96
+ append_se_opts " --username" " ${SE_ROUTER_USERNAME} " " false"
85
97
fi
86
98
87
99
if [ ! -z " $SE_ROUTER_PASSWORD " ]; then
88
- echo " Appending Selenium options: --password $( mask ${SE_ROUTER_PASSWORD} ) "
89
- SE_OPTS=" $SE_OPTS --password ${SE_ROUTER_PASSWORD} "
100
+ append_se_opts " --password" " ${SE_ROUTER_PASSWORD} " " false"
90
101
fi
91
102
92
103
if [ ! -z " $SE_REJECT_UNSUPPORTED_CAPS " ]; then
93
- echo " Appending Selenium options: --reject-unsupported-caps ${SE_REJECT_UNSUPPORTED_CAPS} "
94
- SE_OPTS=" $SE_OPTS --reject-unsupported-caps ${SE_REJECT_UNSUPPORTED_CAPS} "
104
+ append_se_opts " --reject-unsupported-caps" " ${SE_REJECT_UNSUPPORTED_CAPS} "
95
105
fi
96
106
97
107
if [ ! -z " $SE_NEW_SESSION_THREAD_POOL_SIZE " ]; then
98
- echo " Appending Selenium options: --newsession-threadpool-size ${SE_NEW_SESSION_THREAD_POOL_SIZE} "
99
- SE_OPTS=" $SE_OPTS --newsession-threadpool-size ${SE_NEW_SESSION_THREAD_POOL_SIZE} "
108
+ append_se_opts " --newsession-threadpool-size" " ${SE_NEW_SESSION_THREAD_POOL_SIZE} "
100
109
fi
101
110
102
111
EXTRA_LIBS=" "
@@ -124,7 +133,7 @@ if [ "$SE_ENABLE_TRACING" = "true" ]; then
124
133
SE_JAVA_OPTS=" $SE_JAVA_OPTS ${SE_OTEL_JVM_ARGS} "
125
134
fi
126
135
else
127
- SE_OPTS= " $SE_OPTS --tracing false"
136
+ append_se_opts " --tracing" " false"
128
137
SE_JAVA_OPTS=" $SE_JAVA_OPTS -Dwebdriver.remote.enableTracing=false"
129
138
echo " Tracing is disabled"
130
139
fi
0 commit comments