Files
percona-toolkit/sandbox/load-sakila-db

50 lines
1.1 KiB
Bash
Executable File

#!/bin/sh
err() {
echo
for msg; do
echo $msg
done
exit_status=1
}
# ###########################################################################
# Sanity check the cmd line options.
# ###########################################################################
if [ $# -lt 1 ]; then
err "Usage: load-sakila-db PORT"
exit 1
fi
PORT=$1
if [ ! -d "/tmp/$PORT" ]; then
err "MySQL test server does not exist: /tmp/$PORT"
exit 1
fi
# ###########################################################################
# Sanity check the environment.
# ###########################################################################
if [ -z "$PERCONA_TOOLKIT_BRANCH" ]; then
err "PERCONA_TOOLKIT_BRANCH environment variable is not set."
exit 1
fi
if [ ! -d "$PERCONA_TOOLKIT_BRANCH" ]; then
err "Invalid PERCONA_TOOLKIT_BRANCH directory: $PERCONA_TOOLKIT_BRANCH"
exit 1
fi
cd $PERCONA_TOOLKIT_BRANCH/sandbox
exit_status=0
/tmp/$PORT/use < sakila-db/sakila-schema.sql
exit_status=$((exit_status | $?))
/tmp/$PORT/use < sakila-db/sakila-data.sql
exit_status=$((exit_status | $?))
exit $exit_status