Import alt-mysql plugin
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
PLUGIN_DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
SCRIPT="$PLUGIN_DIR/scripts/setup/roundcube_repair_config.sh"
|
||||
TMP_DIR="$(mktemp -d)"
|
||||
trap 'rm -rf "$TMP_DIR"' EXIT
|
||||
|
||||
fail() {
|
||||
echo "FAIL: $*" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
mkdir -p "$TMP_DIR/mariadb/bin" "$TMP_DIR/roundcube"
|
||||
cat > "$TMP_DIR/roundcube/config.inc.php" <<'PHP'
|
||||
<?php
|
||||
$config = [];
|
||||
PHP
|
||||
|
||||
cat > "$TMP_DIR/alt-mariadb.env" <<EOF
|
||||
SERVICE_NAME='alt-mariadb-test'
|
||||
MARIADB_DIR='$TMP_DIR/mariadb'
|
||||
DATADIR='$TMP_DIR/data'
|
||||
PORT='4407'
|
||||
SOCKET='$TMP_DIR/data/mariadb.sock'
|
||||
ALT_MYSQL_CONF='$TMP_DIR/alt-mysql.conf'
|
||||
ALT_MY_CNF='$TMP_DIR/alt-my.cnf'
|
||||
INSTANCE_CNF='$TMP_DIR/alt-mariadb.cnf'
|
||||
EOF
|
||||
|
||||
cat > "$TMP_DIR/alt-mysql.conf" <<EOF
|
||||
host=
|
||||
passwd=secret
|
||||
port=4407
|
||||
socket=$TMP_DIR/data/mariadb.sock
|
||||
user=da_admin
|
||||
EOF
|
||||
|
||||
cat > "$TMP_DIR/plugin-settings.conf" <<EOF
|
||||
MYSQL_PLUGIN_METADATA_FILE=$TMP_DIR/alt-mariadb.env
|
||||
MYSQL_PLUGIN_CREDENTIALS_FILE=$TMP_DIR/alt-mysql.conf
|
||||
MYSQL_PLUGIN_ALT_MY_CNF=$TMP_DIR/alt-my.cnf
|
||||
ROUNDCUBE_ENABLED=true
|
||||
ROUNDCUBE_DB_NAME=roundcube
|
||||
ROUNDCUBE_DB_USER=roundcube
|
||||
ROUNDCUBE_DB_PASSWORD_FILE=$TMP_DIR/alt-roundcube.conf
|
||||
ROUNDCUBE_CONFIG_FILE=$TMP_DIR/roundcube/config.inc.php
|
||||
ROUNDCUBE_CUSTOM_CONFIG_FILE=$TMP_DIR/custombuild/custom/roundcube/config.inc.php
|
||||
ROUNDCUBE_WRITE_CUSTOMBUILD_CONFIG=true
|
||||
ROUNDCUBE_ALT_DSN_MODE=tcp
|
||||
EOF
|
||||
|
||||
ROUNDCUBE_SETTINGS_FILE="$TMP_DIR/plugin-settings.conf" bash "$SCRIPT" >/dev/null
|
||||
|
||||
grep -Fq "BEGIN DIRECTADMIN MYSQL PLUGIN ROUNDCUBE" "$TMP_DIR/roundcube/config.inc.php" \
|
||||
|| fail "managed block missing"
|
||||
grep -Fq "127.0.0.1:4407/roundcube" "$TMP_DIR/roundcube/config.inc.php" \
|
||||
|| fail "alt endpoint not written"
|
||||
grep -Fq "BEGIN DIRECTADMIN MYSQL PLUGIN ROUNDCUBE" "$TMP_DIR/custombuild/custom/roundcube/config.inc.php" \
|
||||
|| fail "managed block missing from CustomBuild Roundcube config"
|
||||
grep -Fq "127.0.0.1:4407/roundcube" "$TMP_DIR/custombuild/custom/roundcube/config.inc.php" \
|
||||
|| fail "alt endpoint not written to CustomBuild Roundcube config"
|
||||
grep -Fq "password=" "$TMP_DIR/alt-roundcube.conf" || fail "password file not created"
|
||||
|
||||
ROUNDCUBE_SETTINGS_FILE="$TMP_DIR/plugin-settings.conf" bash "$SCRIPT" >/dev/null
|
||||
COUNT="$(grep -c "BEGIN DIRECTADMIN MYSQL PLUGIN ROUNDCUBE" "$TMP_DIR/roundcube/config.inc.php")"
|
||||
[ "$COUNT" = "1" ] || fail "managed block is not idempotent"
|
||||
CUSTOM_COUNT="$(grep -c "BEGIN DIRECTADMIN MYSQL PLUGIN ROUNDCUBE" "$TMP_DIR/custombuild/custom/roundcube/config.inc.php")"
|
||||
[ "$CUSTOM_COUNT" = "1" ] || fail "CustomBuild managed block is not idempotent"
|
||||
|
||||
echo "roundcube_repair_config_test: OK"
|
||||
Reference in New Issue
Block a user