Skip to content

Commit 4070d46

Browse files
Fix external DB connectivity by using USE_EXTERNAL_DB variable (#498)
* Add isFalse function to check for external DB * Fix external DB connectivity by using USE_EXTERNAL_DB variable
1 parent bc511c6 commit 4070d46

File tree

2 files changed

+31
-21
lines changed

2 files changed

+31
-21
lines changed

_sources/scripts/functions.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,17 @@ isTrue() {
4242
esac
4343
}
4444

45+
isFalse() {
46+
case $1 in
47+
"True" | "TRUE" | "true" | 1)
48+
return 1
49+
;;
50+
*)
51+
return 0
52+
;;
53+
esac
54+
}
55+
4556
get_hostname_with_port() {
4657
port=$(echo "$1" | grep ":" | cut -d":" -f2)
4758
echo "$1:${port:-$2}"

_sources/scripts/run-maintenance-scripts.sh

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ set -x
99

1010
WG_DB_TYPE=$(get_mediawiki_db_var wgDBtype)
1111
WG_DB_SERVER=$(get_mediawiki_db_var wgDBserver)
12-
if ! [[ $WG_DB_SERVER =~ ":" ]]; then
13-
WG_DB_SERVER+=":3306"
14-
fi
1512
WG_DB_NAME=$(get_mediawiki_db_var wgDBname)
1613
WG_DB_USER=$(get_mediawiki_db_var wgDBuser)
1714
WG_DB_PASSWORD=$(get_mediawiki_db_var wgDBpassword)
@@ -37,25 +34,27 @@ waitdatabase() {
3734
exit 123
3835
fi
3936

40-
echo >&2 "Waiting for database to start"
41-
/wait-for-it.sh -t 86400 "$WG_DB_SERVER"
42-
43-
mysql=( mysql -h "$WG_DB_SERVER" -u"$WG_DB_USER" -p"$WG_DB_PASSWORD" )
44-
45-
for i in {60..0}; do
46-
if echo 'SELECT 1' | "${mysql[@]}" &> /dev/null; then
47-
db_started="1"
48-
break
49-
fi
50-
echo >&2 'Waiting for database to start...'
51-
sleep 1
52-
done
53-
if [ "$i" = 0 ]; then
54-
echo >&2 'Could not connect to the database.'
55-
return 1
37+
if isFalse "$USE_EXTERNAL_DB"; then
38+
echo >&2 "Waiting for database to start"
39+
/wait-for-it.sh -t 86400 "$WG_DB_SERVER"
40+
41+
mysql=( mysql -h "$WG_DB_SERVER" -u"$WG_DB_USER" -p"$WG_DB_PASSWORD" )
42+
43+
for i in {60..0}; do
44+
if echo 'SELECT 1' | "${mysql[@]}" &> /dev/null; then
45+
db_started="1"
46+
break
47+
fi
48+
echo >&2 'Waiting for database to start...'
49+
sleep 1
50+
done
51+
if [ "$i" = 0 ]; then
52+
echo >&2 'Could not connect to the database.'
53+
return 1
54+
fi
55+
echo >&2 'Successfully connected to the database.'
56+
return 0
5657
fi
57-
echo >&2 'Successfully connected to the database.'
58-
return 0
5958
}
6059

6160
# Pause setup until ElasticSearch starts running

0 commit comments

Comments
 (0)