#  Copyright (C) Cfengine AS

#  This file is part of Cfengine 3 - written and maintained by Cfengine AS.

#  This program is free software; you can redistribute it and/or modify it
#  under the terms of the GNU General Public License as published by the
#  Free Software Foundation; version 3.

#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA

# To the extent this program is licensed as part of the Enterprise
# versions of Cfengine, the applicable Commerical Open Source License
# (COSL) may apply to this file if you as a licensee so wish it. See
# included file COSL.txt.


########################################################
#
# Simple test copy from server connection to cfServer
#
########################################################

 #
 # run this as follows:
 #
 # cf-serverd -f runtest_1.cf [-v] (on remote-host.example.org)
 # cf-agent   -f runtest_2.cf (on host 1.2.3.4)
 #
 # Notice that the same file configures all parts of cfengine
 # even though different parts are read by different hosts and agents

########################################################

body common control

{
bundlesequence  => { "example"  };
}

########################################################

bundle agent example

{
files:

  "/tmp/testcopy" 

    perms => system,
    copy_from => mycopy("/src/document","remote-host.example.org"),
    depth_search => recurse("inf");

}

########################################################

body perms system

{
mode  => "0444";
}

#########################################################

body depth_search recurse(d)

{
depth => "$(d)";
}

#########################################################

body copy_from mycopy(from,server)

{
source      => "$(from)";
#portnumber => "6789";
servers     => { "$(server)" , "failover1" };
copy_backup => "true";                   #/false/timestamp
stealth     => "true";                   #/on/false/off
preserve    => "true";
linkcopy_patterns => { ".*fish.*" };
copylink_patterns => { "non-local.*"};
xdev        => "true";                   # /on/false/off
compare     => "mtime";                  # ctime/mtime/checksum/sum/byte/binary/any
link_type    => "absolute";              # /symbolic/relative/hard etc
type_check   => "true";
force_update => "false";
force_ipv4   => "false";
copy_size        => irange("0","50000");
trustkey    => "true";
encrypt     => "true";
verify      => "true";
purge       => "false";
findertype  => "MacOSX";
}

#########################################################
# Server config
#########################################################

body server control 

{
allowconnects         => { "1.2.3.4" , "::1" };
allowallconnects      => { "1.2.3.4" , "::1" };
trustkeysfrom         => { "1.2.3.4" , "::1" };
# allowusers
}

#########################################################

bundle server access_rules()

{

access:

  # Grant access to the remote client to access the source docs

  "/src"   admit   => { "1.2.3.4" };
}



