Commit 1bb0aa8f authored by Julien Muchembled's avatar Julien Muchembled

ERP5: fix mariadb initialization when datadir is not a simple directory

The previous way to initialize ~/srv/mariadb relied on /bin/mv, so that
it's atomic, making [template-mysqld-wrapper] idempotent (think of a
crash in the middle mysql_install_db). However, mv only works if
~/srv/mariadb is a simple directory: it fails if it's a symlink,
a mount point, or a subvolume (btrfs).

When using extra storage devices for some data, one may prefer to only
put the data (e.g. ~/srv/mariadb) and not the whole slapos partition.
Then if we want a resilient ERP5 with catalog's datadir on a separate
storage device, the importer script must be able to reinitialize
~/srv/mariadb whatever its type.
parent 05f78f2c
......@@ -105,15 +105,17 @@ template =
inline:{% raw %}#!/bin/sh -e
basedir='${mariadb:location}'
datadir='{{datadir}}'
[ -e "$datadir" ] || {
rm -vrf "$datadir.new"
marker=$datadir/.slapos_initializing
[ -d "$datadir/mysql" ] && [ ! -f "$marker" ] || {
find "$datadir/" -mindepth 1 ! -path $marker -delete || mkdir "$datadir"
touch "$marker"
"$basedir/scripts/mysql_install_db" \
--defaults-file='{{defaults_file}}' \
--skip-name-resolve \
--auth-root-authentication-method=normal \
--basedir="$basedir" --plugin_dir="$basedir/lib/plugin" \
--datadir="$datadir.new"
mv -v "$datadir.new" "$datadir"
--datadir="$datadir"
rm "$marker"
}
{%- if environ is defined %}
{%- for variable in environ.splitlines() %}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment