File: start_mysqld_and_run.sh

package info (click to toggle)
ruby-mysql2 0.5.5-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,096 kB
  • sloc: ansic: 3,459; ruby: 3,334; sh: 226; makefile: 3
file content (43 lines) | stat: -rwxr-xr-x 1,207 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/sh
#
# start_mysqld_and_auto_install.sh - starts an instance of mysqld before
# auto_installing and running do_mysql's test suite. It is inspired by
# debian/test_mysql.sh from libdbi-drivers source package.

set -ex

MYTEMP_DIR=`mktemp -d`

export MYSQL_UNIX_PORT=${MYTEMP_DIR}/mysql.sock
DO_MYSQL_USER=${USER}
DO_MYSQL_PASS=
DO_MYSQL_DBNAME=test
DO_MYSQL_DATABASE=/${DO_MYSQL_DBNAME}

mysqladmin="/usr/bin/mysqladmin --user=${DO_MYSQL_USER} --socket=${MYSQL_UNIX_PORT}"

mysql_install_db --no-defaults --datadir=${MYTEMP_DIR} --force --skip-name-resolve --user=${DO_MYSQL_USER}
cat >${MYTEMP_DIR}/init.sql <<EOT
UPDATE mysql.user SET plugin = "";
FLUSH PRIVILEGES;
EOT
/usr/sbin/mysqld --no-defaults --user=${DO_MYSQL_USER} --socket=${MYSQL_UNIX_PORT} --datadir=${MYTEMP_DIR} --skip-networking --init-file=${MYTEMP_DIR}/init.sql &
MYSQL_PID=$!
echo -n pinging mysqld.
attempts=0
while ! $mysqladmin ping ; do
  sleep 3
  attempts=$((attempts+1))
  if [ ${attempts} -gt 10 ] ; then
    echo "skipping test, mysql server could not be contacted after 30 seconds"
    exit 0
  fi
done

cleanup() {
  $mysqladmin shutdown || kill "${MYSQL_PID}"
  rm -rf ${MYTEMP_DIR}
}
trap cleanup INT EXIT TERM

"$@"