1#!/bin/sh
2
3# Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License, version 2.0,
7# as published by the Free Software Foundation.
8#
9# This program is also distributed with certain software (including
10# but not limited to OpenSSL) that is licensed under separate terms,
11# as designated in a particular file or component or in included license
12# documentation.  The authors of MySQL hereby grant you an additional
13# permission to link the program and your derivative works with the
14# separately licensed software that they have included with MySQL.
15#
16# This program is distributed in the hope that it will be useful,
17# but WITHOUT ANY WARRANTY; without even the implied warranty of
18# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19# GNU General Public License, version 2.0, for more details.
20#
21# You should have received a copy of the GNU General Public License
22# along with this program; if not, write to the Free Software
23# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
24
25MACHINE=$1
26LOCAL_DIR=$2
27REMOTE_DIR=$3
28verbose=
29
30if [ `uname | grep -ic cygwin || true` -ne 0 ]
31then
32    verbose=1
33fi
34
35name="`uname -n | sed 's!\..*!!g'`"
36
37# Local copy
38if [ "$MACHINE" = "$name" -o "$MACHINE" = "localhost" ]
39then
40    if [ "$REMOTE_DIR" = "$LOCAL_DIR" -o "$REMOTE_DIR/" = "$LOCAL_DIR" ]
41    then
42	if [ "$verbose" ]
43	then
44	    echo "$0: Same directory on localhost. Skipping setup..."
45	fi
46    else
47	if [ "$verbose" ]
48	then
49	    echo "$0: Local machine setup from '$REMOTE_DIR' to '$LOCAL_DIR'..."
50	fi
51	cp -r "$REMOTE_DIR" "$LOCAL_DIR"
52    fi
53    exit 0;
54fi
55
56if [ `uname | grep -ic cygwin || true` -ne 0 ]
57then
58    LOCAL_DIR=`cygpath -u $LOCAL_DIR`
59    REMOTE_DIR=`cygpath -u $REMOTE_DIR`
60fi
61
62set -e
63ssh $MACHINE rm -rf $REMOTE_DIR
64ssh $MACHINE mkdir -p $REMOTE_DIR
65rsync -a --delete --force --ignore-errors $LOCAL_DIR $MACHINE:$REMOTE_DIR
66