From 0dd76ce21f5b0d9c293374ac707ec3bec0213c73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Szil=C3=A1gyi?= Date: Sun, 15 Sep 2024 03:16:48 +0200 Subject: [PATCH 01/13] Add support for mariadb server config parameters --- mariadb/.devcontainer/devcontainer.json | 28 +++++++++++++++++++ mariadb/.devcontainer/tasks.json | 20 +++++++++++++ mariadb/DOCS.md | 5 ++++ mariadb/config.yaml | 4 +++ .../etc/s6-overlay/s6-rc.d/mariadb-core/run | 21 +++++++++++++- 5 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 mariadb/.devcontainer/devcontainer.json create mode 100644 mariadb/.devcontainer/tasks.json diff --git a/mariadb/.devcontainer/devcontainer.json b/mariadb/.devcontainer/devcontainer.json new file mode 100644 index 00000000000..e7cf06f4e8f --- /dev/null +++ b/mariadb/.devcontainer/devcontainer.json @@ -0,0 +1,28 @@ +{ + "name": "Example devcontainer for add-on repositories", + "image": "ghcr.io/home-assistant/devcontainer:addons", + "appPort": ["7123:8123", "7357:4357"], + "postStartCommand": "bash devcontainer_bootstrap", + "runArgs": ["-e", "GIT_EDITOR=code --wait", "--privileged"], + "containerEnv": { + "WORKSPACE_DIRECTORY": "${containerWorkspaceFolder}" + }, + "customizations": { + "vscode": { + "extensions": ["timonwong.shellcheck", "esbenp.prettier-vscode"], + "settings": { + "terminal.integrated.profiles.linux": { + "zsh": { + "path": "/usr/bin/zsh" + } + }, + "terminal.integrated.defaultProfile.linux": "zsh", + "editor.formatOnPaste": false, + "editor.formatOnSave": true, + "editor.formatOnType": true, + "files.trimTrailingWhitespace": true + } + } + }, + "mounts": [ "type=volume,target=/var/lib/docker" ] + } \ No newline at end of file diff --git a/mariadb/.devcontainer/tasks.json b/mariadb/.devcontainer/tasks.json new file mode 100644 index 00000000000..36e373a283a --- /dev/null +++ b/mariadb/.devcontainer/tasks.json @@ -0,0 +1,20 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "Start Home Assistant", + "type": "shell", + "command": "supervisor_run", + "group": { + "kind": "test", + "isDefault": true + }, + "presentation": { + "reveal": "always", + "panel": "new" + }, + "problemMatcher": [] + } + ] + } + \ No newline at end of file diff --git a/mariadb/DOCS.md b/mariadb/DOCS.md index 39c9912700a..1f8b6e34177 100644 --- a/mariadb/DOCS.md +++ b/mariadb/DOCS.md @@ -74,6 +74,10 @@ If omitted, grants `ALL PRIVILEGES` to the user. Restricting privileges of the u that Home Assistant uses is not recommended but if you want to allow other applications to view recorder data should create a user limited to read-only access on the database. +### Option: `parameters.innodb_buffer_pool_size` (optional) + +During Home Assistant schema updates some people experienced [errors][migration-issues] on large databases. Increasing this value can help if there is RAM available. + ## Home Assistant Configuration MariaDB will be used by the `recorder` and `history` components within Home Assistant. For more information about setting this up, see the [recorder integration][mariadb-ha-recorder] documentation for Home Assistant. @@ -101,6 +105,7 @@ In case you've found a bug, please [open an issue on our GitHub][issue]. [username]: https://mariadb.com/kb/en/create-user/#user-name-component [hostname]: https://mariadb.com/kb/en/create-user/#host-name-component [grant]: https://mariadb.com/kb/en/grant/ +[migration-issues]: https://github.com/home-assistant/core/issues/125339 [mariadb-ha-recorder]: https://www.home-assistant.io/integrations/recorder/ [discord]: https://discord.gg/c5DvZ4e [forum]: https://community.home-assistant.io diff --git a/mariadb/config.yaml b/mariadb/config.yaml index 14688a86655..d4d5b8cf47b 100644 --- a/mariadb/config.yaml +++ b/mariadb/config.yaml @@ -23,6 +23,8 @@ options: rights: - database: homeassistant username: homeassistant + parameters: + - innodb_buffer_pool_size: 128M ports: 3306/tcp: null schema: @@ -38,6 +40,8 @@ schema: CREATE VIEW|DELETE|DELETE HISTORY|DROP|EVENT|GRANT OPTION|INDEX|\ INSERT|LOCK TABLES|SELECT|SHOW VIEW|TRIGGER|UPDATE)?" username: str + parameters: + - innodb_buffer_pool_size: str services: - mysql:provide startup: system diff --git a/mariadb/rootfs/etc/s6-overlay/s6-rc.d/mariadb-core/run b/mariadb/rootfs/etc/s6-overlay/s6-rc.d/mariadb-core/run index e486c2bf296..6ec73d70be4 100755 --- a/mariadb/rootfs/etc/s6-overlay/s6-rc.d/mariadb-core/run +++ b/mariadb/rootfs/etc/s6-overlay/s6-rc.d/mariadb-core/run @@ -4,7 +4,26 @@ # Start MariaDB service # ============================================================================== +# Initialize an empty string to hold the concatenated parameters +param_string="" + +# Print the concatenated string of parameters +echo "Concatenated parameters: $param_string" + +# You can now use this $param_string in your mysqld command or configuration file. + +# Init params +for param in $(bashio::config "parameters"); do + PARAM=$(bashio::config "parameters[${right}].key") + VALUE=$(bashio::config "parameters[${right}].value") + bashio::log.info "Configured ${PARAM}: ${VALUE}" + param_string+="--${PARAM}=${VALUE} " +done + +# Trim the trailing space (optional) +param_string=$(echo "$param_string" | sed 's/ *$//') + # Start mariadb bashio::log.info "Starting MariaDB" mkdir -p /run/mysqld -exec mysqld --datadir="${MARIADB_DATA}" --user=root < /dev/null +exec mysqld --datadir="${MARIADB_DATA}" --user=root "${param_string}" < /dev/null From d6adfaf2108af354c5f625a118fe9c44515011a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Szil=C3=A1gyi?= Date: Sun, 15 Sep 2024 15:00:31 +0200 Subject: [PATCH 02/13] debug --- mariadb/.vscode/tasks.json | 20 +++++++++++++++++++ .../etc/s6-overlay/s6-rc.d/mariadb-core/run | 10 +++++----- 2 files changed, 25 insertions(+), 5 deletions(-) create mode 100644 mariadb/.vscode/tasks.json diff --git a/mariadb/.vscode/tasks.json b/mariadb/.vscode/tasks.json new file mode 100644 index 00000000000..36e373a283a --- /dev/null +++ b/mariadb/.vscode/tasks.json @@ -0,0 +1,20 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "Start Home Assistant", + "type": "shell", + "command": "supervisor_run", + "group": { + "kind": "test", + "isDefault": true + }, + "presentation": { + "reveal": "always", + "panel": "new" + }, + "problemMatcher": [] + } + ] + } + \ No newline at end of file diff --git a/mariadb/rootfs/etc/s6-overlay/s6-rc.d/mariadb-core/run b/mariadb/rootfs/etc/s6-overlay/s6-rc.d/mariadb-core/run index 6ec73d70be4..a9b9bb42f34 100755 --- a/mariadb/rootfs/etc/s6-overlay/s6-rc.d/mariadb-core/run +++ b/mariadb/rootfs/etc/s6-overlay/s6-rc.d/mariadb-core/run @@ -7,13 +7,9 @@ # Initialize an empty string to hold the concatenated parameters param_string="" -# Print the concatenated string of parameters -echo "Concatenated parameters: $param_string" - -# You can now use this $param_string in your mysqld command or configuration file. - # Init params for param in $(bashio::config "parameters"); do + bashio::log.info "$param" PARAM=$(bashio::config "parameters[${right}].key") VALUE=$(bashio::config "parameters[${right}].value") bashio::log.info "Configured ${PARAM}: ${VALUE}" @@ -23,6 +19,10 @@ done # Trim the trailing space (optional) param_string=$(echo "$param_string" | sed 's/ *$//') +# Print the concatenated string of parameters +bashio::log.info "Concatenated parameters: $param_string" + + # Start mariadb bashio::log.info "Starting MariaDB" mkdir -p /run/mysqld From b8775edb161ce70b5803571fd2f1ce855a783610 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Szil=C3=A1gyi?= Date: Sun, 15 Sep 2024 15:08:19 +0200 Subject: [PATCH 03/13] fix url, bump version --- mariadb/config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mariadb/config.yaml b/mariadb/config.yaml index d4d5b8cf47b..3d35a14762d 100644 --- a/mariadb/config.yaml +++ b/mariadb/config.yaml @@ -1,9 +1,9 @@ --- -version: 2.7.1 +version: 2.7.2 slug: mariadb name: MariaDB description: A SQL database server -url: https://github.com/home-assistant/addons/tree/master/mariadb +url: https://github.com/danielszilagyi/homeassistant-addons/tree/master/mariadb arch: - armhf - armv7 From 37071ab35236519d470a54ad7dda600c1994bdef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Szil=C3=A1gyi?= Date: Sun, 15 Sep 2024 15:15:19 +0200 Subject: [PATCH 04/13] Mention changes --- mariadb/CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mariadb/CHANGELOG.md b/mariadb/CHANGELOG.md index 8ab5abb00dc..c319e0f5bbe 100644 --- a/mariadb/CHANGELOG.md +++ b/mariadb/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 2.7.2 + +Add option to increase MariaDB server parameters (see also https://github.com/home-assistant/addons/issues/3754) + ## 2.7.1 **Note:** Restart the add-on before upgrade if the current version is lower From 7b2f28fe613096f7dfe4faee66a27946e3f622eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Szil=C3=A1gyi?= Date: Sun, 15 Sep 2024 18:01:42 +0200 Subject: [PATCH 05/13] Fix startup, add another example option --- mariadb/.devcontainer/devcontainer.json | 28 ------------------- mariadb/.devcontainer/tasks.json | 20 ------------- mariadb/.vscode/tasks.json | 20 ------------- mariadb/CHANGELOG.md | 2 +- mariadb/config.yaml | 4 ++- .../etc/s6-overlay/s6-rc.d/mariadb-core/run | 18 ++++-------- 6 files changed, 10 insertions(+), 82 deletions(-) delete mode 100644 mariadb/.devcontainer/devcontainer.json delete mode 100644 mariadb/.devcontainer/tasks.json delete mode 100644 mariadb/.vscode/tasks.json diff --git a/mariadb/.devcontainer/devcontainer.json b/mariadb/.devcontainer/devcontainer.json deleted file mode 100644 index e7cf06f4e8f..00000000000 --- a/mariadb/.devcontainer/devcontainer.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "name": "Example devcontainer for add-on repositories", - "image": "ghcr.io/home-assistant/devcontainer:addons", - "appPort": ["7123:8123", "7357:4357"], - "postStartCommand": "bash devcontainer_bootstrap", - "runArgs": ["-e", "GIT_EDITOR=code --wait", "--privileged"], - "containerEnv": { - "WORKSPACE_DIRECTORY": "${containerWorkspaceFolder}" - }, - "customizations": { - "vscode": { - "extensions": ["timonwong.shellcheck", "esbenp.prettier-vscode"], - "settings": { - "terminal.integrated.profiles.linux": { - "zsh": { - "path": "/usr/bin/zsh" - } - }, - "terminal.integrated.defaultProfile.linux": "zsh", - "editor.formatOnPaste": false, - "editor.formatOnSave": true, - "editor.formatOnType": true, - "files.trimTrailingWhitespace": true - } - } - }, - "mounts": [ "type=volume,target=/var/lib/docker" ] - } \ No newline at end of file diff --git a/mariadb/.devcontainer/tasks.json b/mariadb/.devcontainer/tasks.json deleted file mode 100644 index 36e373a283a..00000000000 --- a/mariadb/.devcontainer/tasks.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "version": "2.0.0", - "tasks": [ - { - "label": "Start Home Assistant", - "type": "shell", - "command": "supervisor_run", - "group": { - "kind": "test", - "isDefault": true - }, - "presentation": { - "reveal": "always", - "panel": "new" - }, - "problemMatcher": [] - } - ] - } - \ No newline at end of file diff --git a/mariadb/.vscode/tasks.json b/mariadb/.vscode/tasks.json deleted file mode 100644 index 36e373a283a..00000000000 --- a/mariadb/.vscode/tasks.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "version": "2.0.0", - "tasks": [ - { - "label": "Start Home Assistant", - "type": "shell", - "command": "supervisor_run", - "group": { - "kind": "test", - "isDefault": true - }, - "presentation": { - "reveal": "always", - "panel": "new" - }, - "problemMatcher": [] - } - ] - } - \ No newline at end of file diff --git a/mariadb/CHANGELOG.md b/mariadb/CHANGELOG.md index c319e0f5bbe..a625ab0d377 100644 --- a/mariadb/CHANGELOG.md +++ b/mariadb/CHANGELOG.md @@ -2,7 +2,7 @@ ## 2.7.2 -Add option to increase MariaDB server parameters (see also https://github.com/home-assistant/addons/issues/3754) +- Add option to configure MariaDB server parameters (see also https://github.com/home-assistant/addons/issues/3754) ## 2.7.1 diff --git a/mariadb/config.yaml b/mariadb/config.yaml index 3d35a14762d..30fce4cd9c4 100644 --- a/mariadb/config.yaml +++ b/mariadb/config.yaml @@ -3,7 +3,7 @@ version: 2.7.2 slug: mariadb name: MariaDB description: A SQL database server -url: https://github.com/danielszilagyi/homeassistant-addons/tree/master/mariadb +url: https://github.com/home-assistant/addons/tree/master/mariadb arch: - armhf - armv7 @@ -25,6 +25,7 @@ options: username: homeassistant parameters: - innodb_buffer_pool_size: 128M + key_buffer_size: 16M ports: 3306/tcp: null schema: @@ -42,6 +43,7 @@ schema: username: str parameters: - innodb_buffer_pool_size: str + key_buffer_size: str services: - mysql:provide startup: system diff --git a/mariadb/rootfs/etc/s6-overlay/s6-rc.d/mariadb-core/run b/mariadb/rootfs/etc/s6-overlay/s6-rc.d/mariadb-core/run index a9b9bb42f34..346ef505525 100755 --- a/mariadb/rootfs/etc/s6-overlay/s6-rc.d/mariadb-core/run +++ b/mariadb/rootfs/etc/s6-overlay/s6-rc.d/mariadb-core/run @@ -7,20 +7,14 @@ # Initialize an empty string to hold the concatenated parameters param_string="" -# Init params -for param in $(bashio::config "parameters"); do - bashio::log.info "$param" - PARAM=$(bashio::config "parameters[${right}].key") - VALUE=$(bashio::config "parameters[${right}].value") - bashio::log.info "Configured ${PARAM}: ${VALUE}" - param_string+="--${PARAM}=${VALUE} " -done +# Fetch the full array of parameters +item=$(bashio::config "parameters") -# Trim the trailing space (optional) -param_string=$(echo "$param_string" | sed 's/ *$//') +while read -r param; do + param_string+="--${param} " +done < <(jq --raw-output 'to_entries[] | "\(.key)=\(.value)"' <<< "$item") -# Print the concatenated string of parameters -bashio::log.info "Concatenated parameters: $param_string" +bashio::log.info "Using command line parameters for MariaDB: $param_string" # Start mariadb From 500dc45b441919a9fbe8ec3403e673ae81ccd0ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Szil=C3=A1gyi?= Date: Sun, 15 Sep 2024 18:03:41 +0200 Subject: [PATCH 06/13] Fix doc --- mariadb/DOCS.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mariadb/DOCS.md b/mariadb/DOCS.md index 1f8b6e34177..4c888255c3c 100644 --- a/mariadb/DOCS.md +++ b/mariadb/DOCS.md @@ -78,6 +78,10 @@ to view recorder data should create a user limited to read-only access on the da During Home Assistant schema updates some people experienced [errors][migration-issues] on large databases. Increasing this value can help if there is RAM available. +### Option: `parameters.key_buffer_size` (optional) + +During Home Assistant schema updates some people experienced [errors][migration-issues] on large databases. Increasing this value can help if there is RAM available. + ## Home Assistant Configuration MariaDB will be used by the `recorder` and `history` components within Home Assistant. For more information about setting this up, see the [recorder integration][mariadb-ha-recorder] documentation for Home Assistant. From d85827977051a40097077c0c77c08611f3119a11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Szil=C3=A1gyi?= Date: Sun, 15 Sep 2024 19:25:49 +0200 Subject: [PATCH 07/13] fixes --- mariadb/DOCS.md | 4 ---- mariadb/config.yaml | 2 -- mariadb/rootfs/etc/s6-overlay/s6-rc.d/mariadb-core/run | 9 ++++----- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/mariadb/DOCS.md b/mariadb/DOCS.md index 4c888255c3c..1f8b6e34177 100644 --- a/mariadb/DOCS.md +++ b/mariadb/DOCS.md @@ -78,10 +78,6 @@ to view recorder data should create a user limited to read-only access on the da During Home Assistant schema updates some people experienced [errors][migration-issues] on large databases. Increasing this value can help if there is RAM available. -### Option: `parameters.key_buffer_size` (optional) - -During Home Assistant schema updates some people experienced [errors][migration-issues] on large databases. Increasing this value can help if there is RAM available. - ## Home Assistant Configuration MariaDB will be used by the `recorder` and `history` components within Home Assistant. For more information about setting this up, see the [recorder integration][mariadb-ha-recorder] documentation for Home Assistant. diff --git a/mariadb/config.yaml b/mariadb/config.yaml index 30fce4cd9c4..133934b8319 100644 --- a/mariadb/config.yaml +++ b/mariadb/config.yaml @@ -25,7 +25,6 @@ options: username: homeassistant parameters: - innodb_buffer_pool_size: 128M - key_buffer_size: 16M ports: 3306/tcp: null schema: @@ -43,7 +42,6 @@ schema: username: str parameters: - innodb_buffer_pool_size: str - key_buffer_size: str services: - mysql:provide startup: system diff --git a/mariadb/rootfs/etc/s6-overlay/s6-rc.d/mariadb-core/run b/mariadb/rootfs/etc/s6-overlay/s6-rc.d/mariadb-core/run index 346ef505525..6c9695edd70 100755 --- a/mariadb/rootfs/etc/s6-overlay/s6-rc.d/mariadb-core/run +++ b/mariadb/rootfs/etc/s6-overlay/s6-rc.d/mariadb-core/run @@ -11,13 +11,12 @@ param_string="" item=$(bashio::config "parameters") while read -r param; do - param_string+="--${param} " + param_string+="--$param " done < <(jq --raw-output 'to_entries[] | "\(.key)=\(.value)"' <<< "$item") -bashio::log.info "Using command line parameters for MariaDB: $param_string" - +param_string=$(echo -n "$param_string" | sed 's/[[:space:]]*$//'|tr -d '\n') # Start mariadb -bashio::log.info "Starting MariaDB" +bashio::log.info "Starting MariaDB with command line parameters: ${param_string}" mkdir -p /run/mysqld -exec mysqld --datadir="${MARIADB_DATA}" --user=root "${param_string}" < /dev/null +exec mysqld --datadir="${MARIADB_DATA}" --user=root "$param_string" < /dev/null From 0639fdeb1181c154278a2f5c7ffe9a5648fa7093 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Szil=C3=A1gyi?= Date: Sun, 15 Sep 2024 19:52:56 +0200 Subject: [PATCH 08/13] Doc adjustment --- mariadb/DOCS.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mariadb/DOCS.md b/mariadb/DOCS.md index 1f8b6e34177..4a82968f907 100644 --- a/mariadb/DOCS.md +++ b/mariadb/DOCS.md @@ -76,7 +76,8 @@ to view recorder data should create a user limited to read-only access on the da ### Option: `parameters.innodb_buffer_pool_size` (optional) -During Home Assistant schema updates some people experienced [errors][migration-issues] on large databases. Increasing this value can help if there is RAM available. +Some users have experienced [errors][migration-issues] during Home Assistant schema updates on large databases. +Increasing this value from the default 128M can help if there is RAM available. ## Home Assistant Configuration From 98e04aa036ad2c66c684f37e9ca4902b640e1d44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Szil=C3=A1gyi?= Date: Sun, 15 Sep 2024 19:54:36 +0200 Subject: [PATCH 09/13] Fix changelog --- mariadb/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mariadb/CHANGELOG.md b/mariadb/CHANGELOG.md index a625ab0d377..803fa242323 100644 --- a/mariadb/CHANGELOG.md +++ b/mariadb/CHANGELOG.md @@ -2,7 +2,7 @@ ## 2.7.2 -- Add option to configure MariaDB server parameters (see also https://github.com/home-assistant/addons/issues/3754) +- Add option to configure MariaDB server parameters (see also [home-assistant/addons#3754](https://github.com/home-assistant/addons/issues/3754)) ## 2.7.1 From 8caa4dea038722b82a2d80ed7dcbc8f58b7897f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Szil=C3=A1gyi?= Date: Mon, 16 Sep 2024 18:16:15 +0200 Subject: [PATCH 10/13] Empty commit for coderabbit From c72ccd7eabd0974a436c21fa8949f7ca83a856f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Szil=C3=A1gyi?= Date: Mon, 14 Oct 2024 19:54:56 +0200 Subject: [PATCH 11/13] Use parameters as in matter server addon --- mariadb/DOCS.md | 6 ++++-- mariadb/config.yaml | 6 ++---- .../etc/s6-overlay/s6-rc.d/mariadb-core/run | 19 ++++++------------- 3 files changed, 12 insertions(+), 19 deletions(-) diff --git a/mariadb/DOCS.md b/mariadb/DOCS.md index 4a82968f907..f2b49c7176c 100644 --- a/mariadb/DOCS.md +++ b/mariadb/DOCS.md @@ -74,10 +74,12 @@ If omitted, grants `ALL PRIVILEGES` to the user. Restricting privileges of the u that Home Assistant uses is not recommended but if you want to allow other applications to view recorder data should create a user limited to read-only access on the database. -### Option: `parameters.innodb_buffer_pool_size` (optional) +### Option: `mariadb_server_args` (optional) Some users have experienced [errors][migration-issues] during Home Assistant schema updates on large databases. -Increasing this value from the default 128M can help if there is RAM available. +Defining the recommended parameters can help if there is RAM available. + +Example: `--innodb_buffer_pool_size=512M` ## Home Assistant Configuration diff --git a/mariadb/config.yaml b/mariadb/config.yaml index 133934b8319..828018ecd71 100644 --- a/mariadb/config.yaml +++ b/mariadb/config.yaml @@ -23,8 +23,6 @@ options: rights: - database: homeassistant username: homeassistant - parameters: - - innodb_buffer_pool_size: 128M ports: 3306/tcp: null schema: @@ -40,8 +38,8 @@ schema: CREATE VIEW|DELETE|DELETE HISTORY|DROP|EVENT|GRANT OPTION|INDEX|\ INSERT|LOCK TABLES|SELECT|SHOW VIEW|TRIGGER|UPDATE)?" username: str - parameters: - - innodb_buffer_pool_size: str + mariadb_server_args: + - str? services: - mysql:provide startup: system diff --git a/mariadb/rootfs/etc/s6-overlay/s6-rc.d/mariadb-core/run b/mariadb/rootfs/etc/s6-overlay/s6-rc.d/mariadb-core/run index 6c9695edd70..4035820b7d5 100755 --- a/mariadb/rootfs/etc/s6-overlay/s6-rc.d/mariadb-core/run +++ b/mariadb/rootfs/etc/s6-overlay/s6-rc.d/mariadb-core/run @@ -4,19 +4,12 @@ # Start MariaDB service # ============================================================================== -# Initialize an empty string to hold the concatenated parameters -param_string="" - -# Fetch the full array of parameters -item=$(bashio::config "parameters") - -while read -r param; do - param_string+="--$param " -done < <(jq --raw-output 'to_entries[] | "\(.key)=\(.value)"' <<< "$item") - -param_string=$(echo -n "$param_string" | sed 's/[[:space:]]*$//'|tr -d '\n') +if bashio::config.has_value "mariadb_server_args"; then + extra_args+=($(bashio::config 'mariadb_server_args')) + bashio::log.info "Starting MariaDB with command line parameters: ${extra_args[@]}" +fi # Start mariadb -bashio::log.info "Starting MariaDB with command line parameters: ${param_string}" +bashio::log.info "Starting MariaDB with command line parameters: ${extra_args[@]}" mkdir -p /run/mysqld -exec mysqld --datadir="${MARIADB_DATA}" --user=root "$param_string" < /dev/null +exec mysqld --datadir="${MARIADB_DATA}" --user=root "${extra_args[@]}" < /dev/null From 5a13683cd8bd575e1f6cc9f624a00ac282f396fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Szil=C3=A1gyi?= Date: Mon, 14 Oct 2024 20:32:05 +0200 Subject: [PATCH 12/13] Fix startup message --- mariadb/rootfs/etc/s6-overlay/s6-rc.d/mariadb-core/run | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mariadb/rootfs/etc/s6-overlay/s6-rc.d/mariadb-core/run b/mariadb/rootfs/etc/s6-overlay/s6-rc.d/mariadb-core/run index 4035820b7d5..9a1d16bc2ed 100755 --- a/mariadb/rootfs/etc/s6-overlay/s6-rc.d/mariadb-core/run +++ b/mariadb/rootfs/etc/s6-overlay/s6-rc.d/mariadb-core/run @@ -7,9 +7,10 @@ if bashio::config.has_value "mariadb_server_args"; then extra_args+=($(bashio::config 'mariadb_server_args')) bashio::log.info "Starting MariaDB with command line parameters: ${extra_args[@]}" +else + bashio::log.info "Starting MariaDB" fi # Start mariadb -bashio::log.info "Starting MariaDB with command line parameters: ${extra_args[@]}" mkdir -p /run/mysqld exec mysqld --datadir="${MARIADB_DATA}" --user=root "${extra_args[@]}" < /dev/null From 243ef59a201921a862f9251424479a4aa64eba4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Szil=C3=A1gyi?= Date: Mon, 14 Oct 2024 21:31:56 +0200 Subject: [PATCH 13/13] Fix startup logic --- .../rootfs/etc/s6-overlay/s6-rc.d/mariadb-core/run | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/mariadb/rootfs/etc/s6-overlay/s6-rc.d/mariadb-core/run b/mariadb/rootfs/etc/s6-overlay/s6-rc.d/mariadb-core/run index 9a1d16bc2ed..ddab749c6f8 100755 --- a/mariadb/rootfs/etc/s6-overlay/s6-rc.d/mariadb-core/run +++ b/mariadb/rootfs/etc/s6-overlay/s6-rc.d/mariadb-core/run @@ -5,12 +5,17 @@ # ============================================================================== if bashio::config.has_value "mariadb_server_args"; then - extra_args+=($(bashio::config 'mariadb_server_args')) - bashio::log.info "Starting MariaDB with command line parameters: ${extra_args[@]}" + readarray -t extra_args <<< "$(bashio::config 'mariadb_server_args')" + bashio::log.info "Starting MariaDB with command line parameters: ${extra_args[*]}" else bashio::log.info "Starting MariaDB" fi # Start mariadb mkdir -p /run/mysqld -exec mysqld --datadir="${MARIADB_DATA}" --user=root "${extra_args[@]}" < /dev/null + +if [ -z "${extra_args+x}" ] || [ ${#extra_args[@]} -eq 0 ]; then + exec mysqld --datadir="${MARIADB_DATA}" --user=root < /dev/null +else + exec mysqld --datadir="${MARIADB_DATA}" --user=root "${extra_args[@]}" < /dev/null +fi