logic changes

This commit is contained in:
2025-08-29 10:59:06 +02:00
parent 42b15e8a27
commit e3a419885c

15
helper
View File

@@ -243,10 +243,23 @@ setup_mariadb() {
exit 1
fi
mysql -u root -p"$mariapwd" <<EOF
# Create a temporary MySQL defaults file
local tmpfile
tmpfile=$(mktemp)
cat >"$tmpfile" <<EOF
[client]
user=root
password=$mariapwd
EOF
# Execute the SQL safely using the temporary file
mysql --defaults-extra-file="$tmpfile" <<EOF
CREATE DATABASE IF NOT EXISTS \`$dbname\`;
CREATE USER IF NOT EXISTS '$dbuser'@'localhost' IDENTIFIED BY '$dbpass';
GRANT ALL PRIVILEGES ON \`$dbname\`.* TO '$dbuser'@'localhost';
FLUSH PRIVILEGES;
EOF
# Remove the temporary file
rm -f "$tmpfile"
}