#!/bin/sh set -e echo dirisempty() { [ -z "$( ls -A "$1" )" ] } # install database if doesn't exist if dirisempty /db then echo "database doesn't exist. creating it..." echo chmod -R 777 /db mariadb-install-db --user=www --datadir=/db # TODO(secret) echo ' FLUSH PRIVILEGES; CREATE DATABASE wp; GRANT ALL PRIVILEGES ON wp.* TO wwsw IDENTIFIED BY "ultraPassword"; FLUSH PRIVILEGES; ' | mariadbd -u root --bootstrap echo echo "database created!" echo fi echo "to recreate a new database, remove the db volume of this compose." echo # run mariadb mariadbd -u root