Skip to content

2025-05-31 mariadb - old-menu branch - PR 2 of 2 #805

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: old-menu
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .templates/mariadb/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ RUN for CNF in ${CANDIDATES} ; do [ -f ${CNF} ] && break ; done ; \
-e "s/^read_buffer_size/# read_buffer_size/" \
${CNF}

# copy the root password check+fix into place
# https://github.com/linuxserver/docker-mariadb/issues/163
COPY iotstack_check-root-password.sh /etc/periodic/15min/iotstack_check-root-password.sh

# copy the health-check script into place
ENV HEALTHCHECK_SCRIPT="iotstack_healthcheck.sh"
COPY ${HEALTHCHECK_SCRIPT} /usr/local/bin/${HEALTHCHECK_SCRIPT}
Expand Down
28 changes: 28 additions & 0 deletions .templates/mariadb/iotstack_check-root-password.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/sh

# https://github.com/linuxserver/docker-mariadb/issues/163
# assumed installation path is /etc/periodic/15min/iotstack_check-root-password.sh

# marker file
MARKER="/tmp/root-password-checked"

# sense marker already exists
[ -f "${MARKER}" ] && exit 0

# create the marker
touch "${MARKER}"

# sense root password not defined yet.
# (defining the var necessarily causes a recreate)
[ -z "${MYSQL_ROOT_PASSWORD}" ] && exit 0

# can we execute a trivial command as root but WITHOUT a password?
if $(mariadb -u root -e 'quit' &> /dev/null) ; then
# yes! Set the password now
mariadb-admin -u root password "${MYSQL_ROOT_PASSWORD}"
echo "root password was not set - is now set" >"${MARKER}"
else
echo "root password checked - already set" >"${MARKER}"
fi

exit 0