LXCize MariaDB setup

This commit is contained in:
Disassembler 2018-09-13 15:50:30 +02:00
parent 7ebdfc1866
commit 677ac1bc4c
Signed by: Disassembler
GPG Key ID: 524BD33A0EE29499
4 changed files with 30 additions and 19 deletions

View File

@ -15,7 +15,7 @@ RUN EOF
chown mysql:mysql /run/mysqld
EOF
MOUNT /srv/mariadb/conf etc/mysqld
MOUNT /srv/mariadb/conf etc/mysql
MOUNT /srv/mariadb/data var/lib/mysql
USER 3306 3306

View File

@ -1,17 +1,12 @@
#!/bin/sh
set -e
SOURCE_DIR=$(realpath $(dirname "${0}"))/mariadb
# Build Docker container
docker build -t mariadb ${SOURCE_DIR}
cp ${SOURCE_DIR}/etc/init.d/mariadb /etc/init.d/mariadb
rc-update -u
SOURCE_DIR=$(realpath $(dirname "${0}"))/setup
# Create MariaDB instance
mkdir -p /srv/mariadb/conf /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
lxc-execute mariadb -- /usr/bin/mysql_install_db --user=mysql
# Configure MariaDB
cp ${SOURCE_DIR}/srv/mariadb/conf/my.cnf /srv/mariadb/conf/my.cnf
@ -21,7 +16,11 @@ if [ ${DEBUG:-0} -eq 1 ]; then
sed -i 's/#general_log/general_log/g' /srv/mariadb/conf/my.cnf
fi
# Install service
cp ${SOURCE_DIR}/etc/init.d/mariadb /etc/init.d/mariadb
rc-update -u
# Configure MariaDB admin
service mariadb start
cat ${SOURCE_DIR}/adminpwd.sql | docker exec -i mariadb mysql
cat ${SOURCE_DIR}/adminpwd.sql | lxc-attach mariadb -- /usr/bin/mysql
service mariadb stop

View File

@ -1,24 +1,19 @@
#!/sbin/openrc-run
description="MariaDB docker container"
description="MariaDB container"
depend() {
need docker
need cgroups
}
start() {
/usr/bin/docker run -d --rm \
--name mariadb \
-h mariadb \
-v /srv/mariadb/conf:/etc/mysql \
-v /srv/mariadb/data:/var/lib/mysql \
mariadb
/usr/bin/lxc-start mariadb
}
start_post() {
timeout -t 60 docker exec mariadb sh -c 'until [ -e /run/mysqld/mysqld.sock ]; do usleep 50000; done'
ewaitfile 60 /var/lib/lxc/mariadb/delta0/run/mysqld/mysqld.sock
}
stop() {
/usr/bin/docker stop mariadb
/usr/bin/lxc-stop mariadb
}

View File

@ -6,9 +6,26 @@ SOURCE_DIR=$(realpath $(dirname "${0}"))
# Setup components
${SOURCE_DIR}/activemq/setup.sh
${SOURCE_DIR}/ckan-datapusher/setup.sh
${SOURCE_DIR}/mariadb/setup.sh
${SOURCE_DIR}/postgres/setup.sh
#${SOURCE_DIR}/rabbitmq/setup.sh
${SOURCE_DIR}/redis/setup.sh
${SOURCE_DIR}/solr/setup.sh
# Setup applications
${SOURCE_DIR}/ckan/setup.sh
#${SOURCE_DIR}/crisiscleanup/setup.sh
#${SOURCE_DIR}/cts/setup.sh
#${SOURCE_DIR}/frontlinesms/setup.sh
#${SOURCE_DIR}/gnuhealth/setup.sh
#${SOURCE_DIR}/kanboard/setup.sh
#${SOURCE_DIR}/opendatakit/setup.sh
#${SOURCE_DIR}/opendatakit-build/setup.sh
#${SOURCE_DIR}/openmapkit/setup.sh
#${SOURCE_DIR}/pandora/setup.sh
#${SOURCE_DIR}/sahana/setup.sh
#${SOURCE_DIR}/sahana-demo/setup.sh
#${SOURCE_DIR}/sambro/setup.sh
#${SOURCE_DIR}/seeddms/setup.sh
#${SOURCE_DIR}/sigmah/setup.sh
#${SOURCE_DIR}/ushahidi/setup.sh