provisioning tool for building opinionated architecture
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
#!/bin/bash
function check() { PREFIX="recipe:mariadb:check" dpkg -l mariadb-client | grep -q ^ii || return 9 container_running "$CONTAINER" || return 10 cat <<EOF | lxc_exec "$CONTAINER" || return 20
set -Eeuo pipefail systemctl is-active mariadb.service &>/dev/null ss -tlnp | grep 0.0.0.0:3306 | grep -q maria
test -f /etc/default/automysqlbackup grep -q BACKUPDIR=\"/mnt/BACKUP/mariadb\" /etc/default/automysqlbackup EOF echo "container <$CONTAINER> approved successfully!" return 0 }
function build_device_backup() { PREFIX="recipe:mariadb:backup" if ! (lxc config device list "$CONTAINER" | grep -q BACKUP); then local backup_dir="$HOME/LXD/BACKUP/databases-$CONTAINER" mkdir -p "$backup_dir" lxc config device add "$CONTAINER" BACKUP disk source=$backup_dir path=mnt/BACKUP fi }
function install() { sudo_required PREFIX="recipe:mariadb:install" : $PREFIX
sudo /opt/miaou-bash/tools/idem_apt_install mariadb-client echowarn "initializing ..." launch_container "$CONTAINER" build_device_backup echowarn "executing various commands inside container <$CONTAINER>, please be patient ..." lxc exec "$CONTAINER" -- bash <<EOF set -Eeuo pipefail cloud-init status --wait >/dev/null . /opt/miaou-bash/lib/functions.sh apt update && apt dist-upgrade -y /opt/miaou-bash/tools/idem_apt_install mariadb-server automysqlbackup echo "change bind-adress" /opt/miaou-bash/tools/append_or_replace "^bind-address.*$" "bind-address = 0.0.0.0" /etc/mysql/mariadb.conf.d/50-server.cnf systemctl restart mariadb.service
function systemctl-exists() ([ \$(systemctl list-unit-files "\${1}*" | wc -l) -gt 3 ]) systemctl-exists exim4.service && systemctl stop exim4.service && systemctl disable exim4.service /opt/miaou-bash/tools/append_or_replace "^BACKUPDIR=.*$" "BACKUPDIR=\"/mnt/BACKUP/mariadb\"" /etc/default/automysqlbackup exit 0 EOF echo DONE }
# MAIN . "$MIAOU_BASEDIR/lib/init.sh"
arg1_required "$@" readonly CONTAINER="$1"
check || ( install check )
|