Files
mtgodot-poc/tools/server/setup_mysql.sh
T
shenleiandClaude Opus 5.5 a46093104c layout: restructure into src/ tests/ android/ scripts/ tools/
- extension/src/{port,platform,codepage} -> src/; native_render -> src/host
  (+ dxt, shaders/); libgr2 -> src/gr2; extension/third_party -> third_party
- extension/tests -> tests/port, libgr2/tests -> tests/gr2
- android-native -> android (build.sh, push-client.sh moved in)
- script -> scripts; tools/40250 -> tools/server; oracle -> tools/granny-oracle;
  perf tools -> tools/perf
- all build trees under build/ (native, release, android, port-gate)
- xrender:: CMake aliases -> mt::; port-map ledger impl paths rewritten

No code changes. ctest 15/15, port_gate macos+android PASS, port_map check 0 errors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 19:08:19 +09:00

46 lines
1.7 KiB
Bash
Executable File

#!/bin/sh
set -eu
dump_root=${MT40250_DUMP_ROOT:-/usr/metin2_mysql_dump}
mysql_bin=${MT40250_MYSQL_BIN:-}
if [ -z "$mysql_bin" ]; then
mysql_bin=$(command -v mysql || true)
fi
if [ -z "$mysql_bin" ] || [ ! -x "$mysql_bin" ]; then
echo "setup_mysql.sh: mysql client not found" >&2
exit 2
fi
for db in account common log player; do
if [ ! -f "$dump_root/$db.sql" ]; then
echo "setup_mysql.sh: missing $dump_root/$db.sql" >&2
exit 2
fi
done
db_password=${MT40250_DB_PASSWORD:-password}
case "$db_password" in
*"'"*) echo "setup_mysql.sh: DB password may not contain a single quote" >&2; exit 2 ;;
esac
mysql_root() {
if [ -n "${MT40250_MYSQL_ROOT_PASSWORD:-}" ]; then
MYSQL_PWD="$MT40250_MYSQL_ROOT_PASSWORD" "$mysql_bin" -u root "$@"
else
"$mysql_bin" -u root -p "$@"
fi
}
mysql_root -e "CREATE DATABASE IF NOT EXISTS account; CREATE DATABASE IF NOT EXISTS common; CREATE DATABASE IF NOT EXISTS log; CREATE DATABASE IF NOT EXISTS player; CREATE USER IF NOT EXISTS 'metin2'@'localhost' IDENTIFIED BY '$db_password'; CREATE USER IF NOT EXISTS 'metin2'@'127.0.0.1' IDENTIFIED BY '$db_password'; ALTER USER 'metin2'@'localhost' IDENTIFIED BY '$db_password'; ALTER USER 'metin2'@'127.0.0.1' IDENTIFIED BY '$db_password'; GRANT ALL PRIVILEGES ON *.* TO 'metin2'@'localhost' WITH GRANT OPTION; GRANT ALL PRIVILEGES ON *.* TO 'metin2'@'127.0.0.1' WITH GRANT OPTION; FLUSH PRIVILEGES;"
for db in account common log player; do
echo "importing $db.sql"
if [ -n "${MT40250_MYSQL_ROOT_PASSWORD:-}" ]; then
MYSQL_PWD="$MT40250_MYSQL_ROOT_PASSWORD" "$mysql_bin" -u root "$db" < "$dump_root/$db.sql"
else
"$mysql_bin" -u root -p "$db" < "$dump_root/$db.sql"
fi
done
mysql_root -e "SELECT 1 AS metin2_database_ready;"
echo "40250 databases ready"