crowdsec/tests/instance-mysql
Manuel Sabban b792c45921
Mysql enabled tests (#1372)
* add msyql backend test

Co-authored-by: sabban <15465465+sabban@users.noreply.github.com>
2022-03-18 17:36:51 +01:00

57 lines
1.1 KiB
Bash
Executable file

#!/usr/bin/env bash
set -eu
script_name=$0
die() {
echo >&2 "$@"
exit 1
}
about() {
die "usage: $script_name [backup | restore | configure | cleanup | setup] <backup_file>"
}
#shellcheck disable=SC1007
THIS_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
cd "${THIS_DIR}"
#shellcheck disable=SC1090
. ./.environment.sh
# you have not removed set -u above, have you?
[ -z "${DATA_DIR-}" ] && die "\$DATA_DIR must be defined."
# ---------------------------
[ $# -lt 1 ] && about
./assert-crowdsec-not-running
case "$1" in
backup)
[ $# -lt 2 ] && about
backup_file="$2"
# dirty fast cp. nothing should be accessing it right now, anyway.
fixtures/mysql backup $backup_file
;;
restore)
[ $# -lt 2 ] && about
backup_file="$2"
[ -f "$backup_file" ] || die "missing file $backup_file"
fixtures/mysql restore $backup_file
;;
configure)
fixtures/mysql configure
;;
setup)
fixtures/mysql setup
;;
cleanup)
fixtures/mysql cleanup
;;
*)
about
;;
esac;