#!/bin/bash set -euo pipefail PLUGIN_DIR="$(cd "$(dirname "$0")/.." && pwd)" INSTALLER="$PLUGIN_DIR/scripts/setup/custombuild_hooks_install.sh" TMP_DIR="$(mktemp -d)" trap 'rm -rf "$TMP_DIR"' EXIT fail() { echo "FAIL: $*" >&2 exit 1 } CUSTOMBUILD_ROOT="$TMP_DIR/custombuild" bash "$INSTALLER" install >/dev/null ROUND_HOOK="$TMP_DIR/custombuild/custom/hooks/roundcube/post/90-alt-mysql-repair.sh" PMA_HOOK="$TMP_DIR/custombuild/custom/hooks/phpmyadmin/post/90-alt-mysql-repair.sh" [ -x "$ROUND_HOOK" ] || fail "Roundcube CustomBuild post hook not installed" [ -x "$PMA_HOOK" ] || fail "phpMyAdmin CustomBuild post hook not installed" grep -Fq "roundcube_repair_config.sh" "$ROUND_HOOK" || fail "Roundcube hook does not call repair" grep -Fq "roundcube_health_check.sh" "$ROUND_HOOK" || fail "Roundcube hook does not call health check" grep -Fq "phpmyadmin_repair.sh" "$PMA_HOOK" || fail "phpMyAdmin hook does not call repair" grep -Fq "phpmyadmin_health_check.sh" "$PMA_HOOK" || fail "phpMyAdmin hook does not call health check" CUSTOMBUILD_ROOT="$TMP_DIR/custombuild" bash "$INSTALLER" uninstall >/dev/null [ ! -e "$ROUND_HOOK" ] || fail "Roundcube CustomBuild post hook not removed" [ ! -e "$PMA_HOOK" ] || fail "phpMyAdmin CustomBuild post hook not removed" echo "custombuild_hooks_install_test: OK"