Skip to content

Commit 4aecb6d

Browse files
committed
Rework (remove) TEST_LEN
1 parent e584a8d commit 4aecb6d

File tree

2 files changed

+8
-13
lines changed
  • root/etc/s6-overlay/s6-rc.d
    • init-mariadb-initdb
    • init-mariadb-upgrade

2 files changed

+8
-13
lines changed

root/etc/s6-overlay/s6-rc.d/init-mariadb-initdb/run

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,7 @@ if [[ ! -d "${DATADIR}/mysql" ]]; then
2929
DELETE FROM mysql.user WHERE user <> 'mariadb.sys';
3030
EOSQL
3131

32-
# test for empty password variable, if it's set to 0 or less than 4 characters
33-
if [[ -z "${MYSQL_ROOT_PASSWORD}" ]]; then
34-
TEST_LEN="0"
35-
else
36-
TEST_LEN=${#MYSQL_ROOT_PASSWORD}
37-
fi
38-
39-
if [[ "${TEST_LEN}" -lt "4" ]]; then
32+
if [[ "${#MYSQL_ROOT_PASSWORD}" -lt "4" ]]; then
4033
MYSQL_PASS="CREATE USER 'root'@'%' IDENTIFIED BY '' ;"
4134
else
4235
MYSQL_PASS="CREATE USER 'root'@'%' IDENTIFIED BY '${MYSQL_ROOT_PASSWORD}' ;"
@@ -97,7 +90,7 @@ EONEWSQL
9790
echo "Database Setup Completed"
9891

9992
# display a message about password if not set or too short
100-
if [[ "${TEST_LEN}" -lt "4" ]]; then
93+
if [[ "${#MYSQL_ROOT_PASSWORD}" -lt "4" ]]; then
10194
cat <<-EOFPASS
10295

10396

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
#!/usr/bin/with-contenv bash
22
# shellcheck shell=bash
33

4-
# display a message about upgrading database if needed
5-
if mariadb-upgrade -u root -p"${MYSQL_ROOT_PASSWORD}" --check-if-upgrade-is-needed >/dev/null 2>&1; then
6-
cat <<-EOF
4+
if [[ "${#MYSQL_ROOT_PASSWORD}" -gt "3" ]]; then
5+
# display a message about upgrading database if needed
6+
if mariadb-upgrade -u root -p"${MYSQL_ROOT_PASSWORD}" --check-if-upgrade-is-needed >/dev/null 2>&1; then
7+
cat <<-EOF
78

89

910

@@ -15,5 +16,6 @@ if mariadb-upgrade -u root -p"${MYSQL_ROOT_PASSWORD}" --check-if-upgrade-is-need
1516

1617

1718
EOF
18-
sleep 5s
19+
sleep 5s
20+
fi
1921
fi

0 commit comments

Comments
 (0)