Import alt-mysql plugin

This commit is contained in:
Marek Miklewicz
2026-07-04 15:48:19 +02:00
commit d71fcf9ace
101 changed files with 18635 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
#!/bin/bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
# shellcheck source=./roundcube_common.sh
source "$SCRIPT_DIR/roundcube_common.sh"
fail() {
echo "roundcube alt-mysql health: $*" >&2
exit 1
}
roundcube_enabled || {
echo "roundcube alt-mysql health: disabled"
exit 0
}
CONFIG_FILE="$(roundcube_config_file)"
DB_NAME="$(roundcube_db_name)"
DB_USER="$(roundcube_db_user)"
PASS="$(roundcube_load_password)" || fail "Roundcube password file is missing or invalid: $(roundcube_password_file)"
mysql_load_alt_credentials
mysql_load_alt_runtime
[ -r "$CONFIG_FILE" ] || fail "config file is not readable: $CONFIG_FILE"
grep -Fq "BEGIN DIRECTADMIN MYSQL PLUGIN ROUNDCUBE" "$CONFIG_FILE" || fail "managed Roundcube DB block is missing"
grep -Fq "$DB_NAME" "$CONFIG_FILE" || fail "Roundcube config does not reference expected database"
if grep -Fq "/var/lib/mysql/mysql.sock" "$CONFIG_FILE"; then
fail "Roundcube config references native DirectAdmin socket"
fi
if grep -Fq "/usr/local/directadmin/conf/mysql.conf" "$CONFIG_FILE"; then
fail "Roundcube config references native DirectAdmin mysql.conf"
fi
MYSQL_PWD="$PASS" "$(mysql_alt_binary mysql)" --protocol=TCP --host=127.0.0.1 --port="$MYSQL_ALT_PORT" --user="$DB_USER" --database="$DB_NAME" -e "SELECT 1" >/dev/null \
|| fail "cannot connect to Roundcube database on alt-mariadb as $DB_USER"
echo "roundcube alt-mysql health: OK"