Skip to content

Commit d52de72

Browse files
committed
Handle case where MariaDB database has no root password
1 parent 56f5d3a commit d52de72

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

.templates/mariadb/iotstack_healthcheck.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@ HEALTHCHECK_PORT="${MYSQL_TCP_PORT:-3306}"
88
EXPECTED="mysqld is alive"
99

1010
# run the check
11-
RESPONSE=$(mysqladmin -p${MYSQL_ROOT_PASSWORD} ping -h localhost)
11+
if [ -z "$MYSQL_ROOT_PASSWORD" ] ; then
12+
RESPONSE=$(mysqladmin ping -h localhost)
13+
else
14+
# note - there is NO space between "-p" and the password. This is
15+
# intentional. It is part of the mysql and mysqladmin API.
16+
RESPONSE=$(mysqladmin -p${MYSQL_ROOT_PASSWORD} ping -h localhost)
17+
fi
1218

1319
# did the mysqladmin command succeed?
1420
if [ $? -eq 0 ] ; then

0 commit comments

Comments
 (0)