28 lines
795 B
Bash
28 lines
795 B
Bash
|
#!/bin/sh
|
||
|
|
||
|
SOURCE_DIR=$(realpath $(dirname "${0}"))/mariadb
|
||
|
|
||
|
# Build Docker container
|
||
|
docker build -t mariadb ${SOURCE_DIR}
|
||
|
|
||
|
# Create MariaDB instance
|
||
|
mkdir -p /srv/mariadb/data
|
||
|
chown 3306:3306 /srv/mariadb/data
|
||
|
docker run --rm --name mariadb -h mariadb -v /srv/mariadb/data:/var/lib/mysql mariadb mysql_install_db --user=mysql
|
||
|
|
||
|
# Configure MariaDB
|
||
|
cp ${SOURCE_DIR}/srv/mariadb/my.cnf /srv/mariadb/my.cnf
|
||
|
|
||
|
# Enable query logging. Only if the DEBUG environment variable is set
|
||
|
if [ ${DEBUG:-0} -eq 1 ]; then
|
||
|
sed -i 's/#general_log/general_log/g' /srv/mariadb/my.cnf
|
||
|
fi
|
||
|
|
||
|
# Configure MariaDB service
|
||
|
cp ${SOURCE_DIR}/etc/init.d/mariadb /etc/init.d/mariadb
|
||
|
rc-update add mariadb boot
|
||
|
service mariadb start
|
||
|
|
||
|
# Configure MariaDB admin
|
||
|
cat ${SOURCE_DIR}/adminpwd.sql | docker exec -i mariadb mysql
|