Handle if mkdir fails in start-sandbox.

This commit is contained in:
Daniel Nichter
2011-08-23 09:43:50 -06:00
parent e93381d6b6
commit dbe6de7f71

View File

@@ -11,7 +11,10 @@ die() {
make_sandbox() { make_sandbox() {
# Make the sandbox dir and extract the base files. # Make the sandbox dir and extract the base files.
mkdir /tmp/$port >/dev/null 2>&1 mkdir /tmp/$port
if [ $? -ne 0 ]; then
die "mkdir /tmp/$port failed"
fi
cp $PERCONA_TOOLKIT_BRANCH/sandbox/servers/$version/my.sandbox.cnf /tmp/$port cp $PERCONA_TOOLKIT_BRANCH/sandbox/servers/$version/my.sandbox.cnf /tmp/$port
tar xzf $PERCONA_TOOLKIT_BRANCH/sandbox/servers/$version/data.tar.gz -C /tmp/$port tar xzf $PERCONA_TOOLKIT_BRANCH/sandbox/servers/$version/data.tar.gz -C /tmp/$port
@@ -44,13 +47,13 @@ make_sandbox() {
/tmp/$port/use -e 'SHOW /*!40100 ENGINE*/ INNODB STATUS' | grep 'INNODB MONITOR OUTPUT' >/dev/null 2>&1 /tmp/$port/use -e 'SHOW /*!40100 ENGINE*/ INNODB STATUS' | grep 'INNODB MONITOR OUTPUT' >/dev/null 2>&1
# grep exits 0 if lines are found # grep exits 0 if lines are found
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "****** WARNING sandbox doesn't have a working InnoDB! ******" echo "****** WARNING sandbox doesn't have a working InnoDB! ******" >&2
cat /tmp/$port/data/mysqld.log cat /tmp/$port/data/mysqld.log >&2
exit 1 exit 1
fi fi
else else
echo "Sandbox $type $port failed to start." echo "Sandbox $type $port failed to start." >&2
cat /tmp/$port/data/mysqld.log cat /tmp/$port/data/mysqld.log >&2
exit 1 exit 1
fi fi
@@ -69,40 +72,32 @@ port=$2 # sandbox port number, e.g. 12345
master_port=$3 # master port if slave or master-master master_port=$3 # master port if slave or master-master
if [ "$type" != "master" ] && [ "$type" != "slave" ] && [ "$type" != "master-master" ]; then if [ "$type" != "master" ] && [ "$type" != "slave" ] && [ "$type" != "master-master" ]; then
err "Invalid sandbox type: $type" \ die "Invalid sandbox type: $type. Valid types are master, slave, and master-master."
"Type must be either master, slave or master-master."
exit 1
fi fi
if [ $port -le 1024 ]; then if [ $port -le 1024 ]; then
err "Invalid port number: $port" \ die "Invalid port: $port. Ports must be > 1024."
"Port number must be > 1024"
exit 1
fi fi
if [ "$type" = "slave" -o "$type" = "master-master" ] && [ -z "$master_port" ]; then if [ "$type" = "slave" -o "$type" = "master-master" ] && [ -z "$master_port" ]; then
err "No master port given for the $type." die "No master port given for the $type."
exit 1
fi fi
# If creating a slave, the master must exist first. Not true for creating # If creating a slave, the master must exist first. Not true for creating
# a master-master though. # a master-master though.
if [ "$type" = "slave" ] && [ ! -d "/tmp/$master_port" ]; then if [ "$type" = "slave" ] && [ ! -d "/tmp/$master_port" ]; then
err "Master sandbox does not exist: /tmp/$master_port" die "Master sandbox does not exist: /tmp/$master_port"
exit 1
fi fi
# ########################################################################### # ###########################################################################
# Sanity check the environment. # Sanity check the environment.
# ########################################################################### # ###########################################################################
if [ -z "$PERCONA_TOOLKIT_BRANCH" ]; then if [ -z "$PERCONA_TOOLKIT_BRANCH" ]; then
err "PERCONA_TOOLKIT_BRANCH environment variable is not set." die "PERCONA_TOOLKIT_BRANCH environment variable is not set."
exit 1
fi fi
if [ ! -d "$PERCONA_TOOLKIT_BRANCH" ]; then if [ ! -d "$PERCONA_TOOLKIT_BRANCH" ]; then
err "Invalid PERCONA_TOOLKIT_BRANCH directory: $PERCONA_TOOLKIT_BRANCH" die "Invalid PERCONA_TOOLKIT_BRANCH directory: $PERCONA_TOOLKIT_BRANCH"
exit 1
fi fi
cd $PERCONA_TOOLKIT_BRANCH/sandbox cd $PERCONA_TOOLKIT_BRANCH/sandbox
@@ -116,12 +111,10 @@ cd $PERCONA_TOOLKIT_BRANCH/sandbox
if [ -z "$PERCONA_TOOLKIT_SANDBOX" ]; then if [ -z "$PERCONA_TOOLKIT_SANDBOX" ]; then
PERCONA_TOOLKIT_SANDBOX=`./mk-test-env checkconfig | grep PERCONA_TOOLKIT_SANDBOX | cut -d= -f2 | awk '{print $1}'` PERCONA_TOOLKIT_SANDBOX=`./mk-test-env checkconfig | grep PERCONA_TOOLKIT_SANDBOX | cut -d= -f2 | awk '{print $1}'`
if [ -z "$PERCONA_TOOLKIT_SANDBOX" ]; then if [ -z "$PERCONA_TOOLKIT_SANDBOX" ]; then
err "PERCONA_TOOLKIT_SANDBOX environment variable is not set." die "PERCONA_TOOLKIT_SANDBOX environment variable is not set."
exit 1
fi fi
fi fi
# ########################################################################### # ###########################################################################
# Get server version. # Get server version.
# ########################################################################### # ###########################################################################
@@ -132,12 +125,11 @@ elif [ -x "$PERCONA_TOOLKIT_SANDBOX/sbin/mysqld" ]; then
elif [ -x "$PERCONA_TOOLKIT_SANDBOX/libexec/mysqld" ]; then elif [ -x "$PERCONA_TOOLKIT_SANDBOX/libexec/mysqld" ]; then
mysqld="$PERCONA_TOOLKIT_SANDBOX/libexec/mysqld" mysqld="$PERCONA_TOOLKIT_SANDBOX/libexec/mysqld"
else else
err "Cannot find executable mysqld in $PERCONA_TOOLKIT_SANDBOX/bin, $PERCONA_TOOLKIT_SANDBOX/sbin or $PERCONA_TOOLKIT_SANDBOX/libexec." die "Cannot find executable mysqld in $PERCONA_TOOLKIT_SANDBOX/bin, $PERCONA_TOOLKIT_SANDBOX/sbin or $PERCONA_TOOLKIT_SANDBOX/libexec."
fi fi
version=`$mysqld -V | awk '{print $3}' | cut -d. -f 1,2`; version=`$mysqld -V | awk '{print $3}' | cut -d. -f 1,2`;
if [ ! -d "$PERCONA_TOOLKIT_BRANCH/sandbox/servers/$version" ]; then if [ ! -d "$PERCONA_TOOLKIT_BRANCH/sandbox/servers/$version" ]; then
err "$PERCONA_TOOLKIT_BRANCH/sandbox/servers/$version does not exist." die "$PERCONA_TOOLKIT_BRANCH/sandbox/servers/$version does not exist."
exit 1
fi fi
# ########################################################################### # ###########################################################################