/usr/bin/deploy_to_remote_sandboxes is in mysql-sandbox 3.1.04-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | #!/bin/bash
# The MySQL Sandbox
# Copyright (C) 2006-2015 Giuseppe Maxia
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
[ -z "$MYSQL_VERSION" ] && MYSQL_VERSION=5.5.30
[ -z "$MYSQL_PORT" ] && MYSQL_PORT=15530
[ -z "$SANDBOX_DIR" ] && SANDBOX_DIR=remote_sb
NODES_LIST=
TARBALL=
function show_help {
echo "Deploy to remote sandboxes. "
echo "Usage: $0 [options] "
echo '-h => help'
echo "-P port => MySQL port ($MYSQL_PORT)"
echo "-d sandbox dir => sandbox directory name ($SANDBOX_DIR)"
echo "-m version => MySQL version ($MYSQL_VERSION)"
echo "-l list of nodes => list of nodes where to deploy"
echo "-s server-ids => list of server IDs to use (default: (10 20 30 40 ...))"
echo '-t tarball => MySQL tarball to install remotely (none)'
echo '-y my.cnf => MySQL configuration file to use as template (none)'
echo ""
echo "This command takes the list of nodes and installs a MySQL sandbox in each one."
echo "You must have ssh access to the remote nodes, or this script won't work."
exit 1
}
SERVER_IDS=(`seq 10 10 200`)
args=$(getopt hs:P:m:d:l:t:y: $*)
if [ $? != 0 ]
then
show_help
fi
set -- $args
for i
do
case "$i"
in
-h)
show_help
;;
-d)
export SANDBOX_DIR=$2
shift
shift
;;
-l)
NODES_LIST=$(echo $2 | tr ',' ' ')
count=0
for NODE in $NODES_LIST
do
NODES[$count]=$NODE
count=$(($count+1))
done
export UPDATE_USER_VALUES=
shift
shift
;;
-m)
export MYSQL_VERSION=$2
shift
shift
;;
-P)
export MYSQL_PORT=$2
shift
shift
;;
-s)
I=0
for n in $(echo $2 | tr ',' ' ' )
do
SERVER_IDS[$I]=$n;
I=$(($I+1))
done
shift
shift
;;
-t)
export TARBALL=$2
shift
shift
;;
-y)
export MY_CNF=$2
shift
shift
;;
--)
shift
break
;;
esac
done
if [ -z "$NODES_LIST" ]
then
echo "You must provide a nodes list"
show_help
fi
# remove the sandbox if it already exists
for HOST in ${NODES[*]}
do
ssh $HOST "if [ -d $HOME/sandboxes/$SANDBOX_DIR ] ; then sbtool -o delete -s $HOME/sandboxes/$SANDBOX_DIR > /dev/null ; fi"
done
BUILD_SB=$HOME/build_sb.sh
echo "#!/bin/bash" > $BUILD_SB
echo 'SANDBOX_EXISTS=$(for P in `echo $PATH | tr ":" " "` ; do if [ -f $P/make_sandbox ] ; then echo $P/make_sandbox ; fi; done)' >> $BUILD_SB
echo 'if [ -z "$SANDBOX_EXISTS" ] ; then hostname; echo "make_sandbox not found in PATH" ; exit 1; fi' >> $BUILD_SB
MY_TEMPLATE=$my_template$$.cnf
if [ -n "$MY_CNF" ]
then
if [ ! -f $MY_CNF ]
then
echo "File '$MY_CNF' not found"
exit 1
fi
cp $MY_CNF $HOME/$MY_TEMPLATE
echo "MY_CNF=\$HOME/$MY_TEMPLATE" >> $BUILD_SB
fi
echo 'SANDBOX_OPTIONS="--no_confirm --no_show"' >> $BUILD_SB
echo 'if [ -n "$MY_CNF" ] ; then SANDBOX_OPTIONS="$SANDBOX_OPTIONS --my_file=$MY_CNF" ; fi ' >> $BUILD_SB
echo 'SANDBOX_OPTIONS="$SANDBOX_OPTIONS -c server-id=$1 -c default_storage_engine=innodb -c log-bin=mysql-bin -c log-slave-updates -c innodb_flush_log_at_trx_commit=1"' >> $BUILD_SB
echo 'export SANDBOX_OPTIONS="$SANDBOX_OPTIONS -c max_allowed_packet=48M --remote_access=%"' >> $BUILD_SB
if [ -n "$TARBALL" ]
then
BASE_TARBALL=$(basename $TARBALL)
echo "make_sandbox \$HOME/opt/mysql/$BASE_TARBALL -- --sandbox_port=$MYSQL_PORT \\" >> $BUILD_SB
else
echo "make_sandbox $MYSQL_VERSION -- --sandbox_port=$MYSQL_PORT \\" >> $BUILD_SB
fi
echo " --sandbox_directory=$SANDBOX_DIR \$SANDBOX_OPTIONS" >> $BUILD_SB
# echo "if [ -f \$HOME/$MY_TEMPLATE ] ; then rm -f \$HOME/$MY_TEMPLATE ; fi "
chmod +x $BUILD_SB
SERVER_ID_COUNTER=0
for HOST in ${NODES[*]}
do
if [ -n "$TARBALL" ]
then
ssh $HOST 'if [ ! -d $HOME/opt/mysql ] ; then mkdir -p $HOME/opt/mysql ; fi'
scp -p $TARBALL $HOST:~/opt/mysql
fi
scp -p $BUILD_SB $HOST:$BUILD_SB
scp -p $HOME/$MY_TEMPLATE $HOST:$MY_TEMPLATE
ssh $HOST $BUILD_SB ${SERVER_IDS[$SERVER_ID_COUNTER]}
SERVER_ID_COUNTER=$(($SERVER_ID_COUNTER+1))
done
echo "Connection parameters:"
echo "datadir=~/sandboxes/$SANDBOX_DIR/data"
echo "options file=~/sandboxes/$SANDBOX_DIR/my.sandbox.cnf"
echo "port=$MYSQL_PORT"
echo ""
|