1#!/bin/bash 2TMP_DIR=${TMP_DIR:-/tmp} 3 4die() { 5 echo $1 >&2 6 exit 1 7} 8 9if [ $# -lt 1 ]; then 10 die "Usage: stop-sandbox PORTS" 11fi 12 13exit_status=0 14 15for port in "$@"; do 16 if ! [ -d "${TMP_DIR}/$port" ]; then 17 echo "MySQL test server on port $port does not exist." 18 continue 19 fi 20 21 if [ -x "${TMP_DIR}/$port/stop" ]; then 22 ${TMP_DIR}/$port/stop 23 exit_status=$((exit_status | $?)) 24 else 25 echo "${TMP_DIR}/$port is missing files:" >&2 26 ls -la ${TMP_DIR}/$port >&2 27 fi 28 29 rm -rf ${TMP_DIR}/$port 30 exit_status=$((exit_status | $?)) 31done 32 33exit $exit_status 34