Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
isv:metal3:BCI:ironic
mariadb
runmariadb
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File runmariadb of Package mariadb
#!/usr/bin/bash set -eux PATH=$PATH:/usr/sbin/ DATADIR="/var/lib/mysql/data" MARIADB_PASSWORD=${MARIADB_PASSWORD:-"change_me"} MARIADB_CONF_FILE="/etc/my.cnf.d/mariadb-server.cnf" MARIADB_CERT_FILE=/certs/mariadb/tls.crt MARIADB_KEY_FILE=/certs/mariadb/tls.key RESTART_CONTAINER_CERTIFICATE_UPDATED=${RESTART_CONTAINER_CERTIFICATE_UPDATED:-"false"} USER="$(whoami)" mkdir -p "$(dirname "${MARIADB_CERT_FILE}")" if [ -f "$MARIADB_CERT_FILE" ] && [ ! -f "$MARIADB_KEY_FILE" ] ; then echo "Missing TLS private key file ${MARIADB_KEY_FILE}" exit 1 fi if [ ! -f "$MARIADB_CERT_FILE" ] && [ -f "$MARIADB_KEY_FILE" ] ; then echo "Missing TLS Certificate file ${MARIADB_CERT_FILE}" exit 1 fi ln -sf /proc/self/fd/1 /var/log/mysql/mysqld.log # Restart mysqld when the certificate is updated if [[ -f "$MARIADB_CERT_FILE" && "${RESTART_CONTAINER_CERTIFICATE_UPDATED}" == "true" ]]; then # shellcheck disable=SC2034,SC2162 inotifywait -m -e delete_self "${MARIADB_CERT_FILE}" | while read file event; do kill $(pgrep -f mysqld) done & fi crudini --set "$MARIADB_CONF_FILE" mysqld max_connections 64 crudini --set "$MARIADB_CONF_FILE" mysqld max_heap_table_size 1M crudini --set "$MARIADB_CONF_FILE" mysqld innodb_buffer_pool_size 5M crudini --set "$MARIADB_CONF_FILE" mysqld innodb_log_buffer_size 512K crudini --set "$MARIADB_CONF_FILE" mysqld user "${USER}" # Allow binding to all interfaces so we can access via ClusterIP crudini --set "$MARIADB_CONF_FILE" mysqld bind-address 0.0.0.0 # Change data directory crudini --set "$MARIADB_CONF_FILE" mysqld datadir "${DATADIR}" # Config MariaDB to enable TLS if [ -f "$MARIADB_CERT_FILE" ]; then crudini --set "$MARIADB_CONF_FILE" mariadb-10.3 ssl on crudini --set "$MARIADB_CONF_FILE" mariadb-10.3 ssl_cert "${MARIADB_CERT_FILE}" crudini --set "$MARIADB_CONF_FILE" mariadb-10.3 ssl_key "${MARIADB_KEY_FILE}" fi if [ ! -d "${DATADIR}/mysql" ]; then mysql_install_db --datadir="$DATADIR" --skip-test-db --user="${USER}" --group="10060" cat > /tmp/configure-mysql.sql <<-EOSQL DELETE FROM mysql.user ; CREATE USER 'ironic'@'%' identified by '${MARIADB_PASSWORD}' ; GRANT ALL on *.* TO 'ironic'@'%' WITH GRANT OPTION ; DROP DATABASE IF EXISTS test ; CREATE DATABASE IF NOT EXISTS ironic ; CREATE DATABASE IF NOT EXISTS ironic_inspector ; FLUSH PRIVILEGES ; EOSQL # mysqld_safe closes stdout/stderr if no bash options are set ($- == '') # turn on tracing to prevent this exec bash -x /usr/bin/mysqld_safe --init-file /tmp/configure-mysql.sql else exec bash -x /usr/bin/mysqld_safe fi
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor