#! /bin/bash
# Copyright (c) 2007 Apple Inc. All rights reserved.

# jpeach_smb -  This is a test driver (like SambaServerTest) for running
# the Samba test suite from BigBrother. The difference is that this script
# will pull a development version of Samba from a well-known build host
# and test that version.
#
# The canonical version of this file is:
# $HeadURL$
# $Id$

# Set up the test machine.
RequireScript InventoryTracker
RequireScript PrepTestSys
RequireScript TestSuiteNetFS

# SAMBA_BUILDHOST is the machine to pull the source from
SAMBA_BUILDHOST=${SAMBA_BUILDHOST:-jpeach.apple.com}

# SAMBA_BUILDPATH is the directory where SAMBA_BUILD lives
SAMBA_BUILDPATH=${SAMBA_BUILDPATH:-/Volumes/work}

# SAMBA_BUILD is the name of the directory containing the Samba svn tree
SAMBA_BUILD=${SAMBA_BUILD:-"samba-trunk"}

echo synching $SAMBA_BUILD from $SAMBA_BUILDHOST

# Set up a "well-known" ssh key that will let me log back into
# jpeach.apple.com as user "local"

mkdir -p ~/.ssh

cat > ~/.ssh/id_rsa <<EOF
-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEAxQyWG07T9JMYuyWsBLmVJJwJ0PoQbHVNmFQIklUZWpvH+PcD
EMUSg1TDamlpqAfbgycoQqjr5aWZAcQxwy2YzwVYarhyL3tO7bLfUPc4v46L63t6
4Aqg6PszS9L5pBWHEQ8oM5XwdSJg3m7B36122iuGgGO/evSkjoEV1gy88MLWH4Wx
rvjHvd05k8knXT7eFGf7x/hidLWfwSH58tBrZBmpq3DS6dKD4i9wpCqYYfsuxBFQ
sr9G5OhJQ0N8McUN6L2N+KF3XJzKq00i8h4EA35Jx9uEWFB/KI/VZnEW6xH6GOue
peSLHKJihK2TL5mJu7VyIlV43hi/WKxmKeAaTwIBIwKCAQAFoUYeCZEG/ONzD7R1
Kd+wlr5zr1+OEfrnGFgELlEueXq9+G3NR3WOuUdpcLngOr0hAR5oTfgcgRMADOt6
mucb25TP2WJZIMe9pgZhZiYxW9gcq8GuoTfMJG8uDVeW+U0AfMaiY16kQs+RU58j
pd7TCI7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
-----END RSA PRIVATE KEY-----
EOF

# Copy this to local@jpeach.apple.com:~/.ssh/authorized_keys to
# get rid of the ssh password prompt that will halt the test script.
cat > ~/.ssh/id_rsa.pub <<EOF
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAxQyWG07T9JMYuyWsBLmVJJwJ0PoQbHVNmFQIklUZWpvH+PcDEMUSg1TDamlpqAfbgycoQqjr5aWZAcQxwy2YzwVYarhyL3tO7bLfUPc4v46L63t64Aqg6PszS9L5pBWHEQ8oM5XwdSJg3m7B36122iuGgGO/evSkjoEV1gy88MLWH4WxrvjHvd05k8knXT7eFGf7x/hidLWfwSH58tBrZBmpq3DS6dKD4i9wpCqYYfsuxBFQsr9G5OhJQ0N8McUN6L2N+KF3XJzKq00i8h4EA35Jx9uEWFB/KI/VZnEW6xH6GOuepeSLHKJihK2TL5mJu7VyIlV43hi/WKxmKeAaTw== local@jpeach-mini
EOF

cat > ~/.ssh/config <<EOF
Host *
    CheckHostIP no
    VerifyHostKeyDNS no
    StrictHostKeyChecking no
    UserKnownHostsFile /dev/null
EOF

chmod 600 ~/.ssh/id_rsa
chmod 644 ~/.ssh/id_rsa.pub

rsync --archive local@$SAMBA_BUILDHOST:$SAMBA_BUILDPATH/$SAMBA_BUILD .

# Pull the actual test implementation in from the SVN source tree.
exec $SAMBA_BUILD/scripts/bb-scripts/CurrentSambaServerTest

