Initial commit of refactored backuppc module.
diff --git a/Modulefile b/Modulefile
index c325e13..c9e75b6 100644
--- a/Modulefile
+++ b/Modulefile
@@ -1,11 +1,11 @@
-name    'codec-backuppc'
+name    'wyrie-backuppc'
 version '0.0.1'
-source 'https://github.com/codec/puppet-backuppc'
-author 'codec'
-license 'WTFPL'
-summary 'Controls backupPC and clients'
-description 'Setup backupPC and handle client configuration in puppet'
-project_page 'https://github.com/codec/puppet-backuppc'
+source 'https://github.com/wyrie/puppet-backuppc'
+author 'Scott Barr'
+license 'Apache2'
+summary 'BackupPC module'
+description 'Backuppc module that uses exported resources to setup clients and server. Extended the work by codec-backuppc'
+project_page 'https://github.com/wyrie/puppet-backuppc'
 
 ## Add dependencies, if any:
-# dependency 'username/name', '>= 1.2.0'
+dependency 'puppetlabs/stdlib', '>= 4.0.2'
diff --git a/README b/README
deleted file mode 100644
index eefd413..0000000
--- a/README
+++ /dev/null
@@ -1,3 +0,0 @@
-backuppc
-
-This is the backuppc module.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..32046e6
--- /dev/null
+++ b/README.md
@@ -0,0 +1,101 @@
+# BackupPC Module
+
+This module will install and configure a BackupPC server and allow you to add other puppet managed nodes as clients/hosts. It
+uses exported resources to create the client's configuration file, add it to the hosts file and setup ssh access if needed.
+
+This module started as a fork of https://github.com/codec/puppet-backuppc.
+
+## Description
+
+BackupPC has many configuration options and this module should provide you access to most of them. BackupPC's global configuration
+file is managed by backuppc::server and is intended to setup useful defaults that can be overridden by the client if needed. 
+
+Where BackupPC's configuration file uses camel case for the config variables the module's class parameters would use the same names but
+replacing the uppercase characters with lowercase and an underscore prefix.
+
+For xfer methods that require ssh the module can:
+* Create a non-privledged account on the client and allow it access to rsync or tar via sudo.
+* Install the server's ssh key.
+* Add the client's ssh key to the list of known hosts.
+
+By default the account name is 'backup'. You can choose to do the ssh configuration yourself if it doesn't suit your environment (see the client.pp
+file for notes on system_account).
+
+The module is designed to work alongside the BackupPC web administration interface, meaning hosts that are configured but not managed by this
+module will still work.
+
+## Usage
+
+### Minimal server configuration
+
+```puppet
+class { 'backuppc::server':
+  backuppc_password => 'somesecret'
+}
+```
+This will do the typical install, configure and service management. The module does not manage apache. It will, if the apache_configuation parameter is true,
+install an apache configuration file that creates an alias from the /backuppc url to the backuppc files on the system. Additionally it will create a htpasswd
+file with the default backuppc user and the password that you provide for access to the web based administration. You will however need to inform the apache
+service that something has changed. Alternatively you can install backuppc as a virtual host or whatever else suits your needs.
+
+### Additional login accounts
+
+```puppet
+backuppc::server::user { 'john':
+  password => 'mypassword'
+}
+```
+The default path to the htpasswd file is in the [config_directory]/htpasswd. You can add additional login accounts and assign these to hosts (see client examples
+for this).
+
+### More server configuration
+
+```puppet
+class { 'backuppc::server':
+  backuppc_password => 'somesecret'
+  wakeup_schedule   => [1, 2, 3, 4, 5, 21, 22, 23],
+  max_backups       => 3,
+  max_user_backups  => 1,
+}
+```
+Please consult the BackupPC documentation for explanations on configuration options: http://backuppc.sourceforge.net/faq/BackupPC.html
+
+Some configuration options, like xfer_method, is more useful to set when adding a client. Where a configuration parameter is ommited backuppc's default is applied
+in the main/global configuration file.
+
+### Client configuration
+
+```puppet
+class { 'backuppc::client':
+  backuppc_hostname     => 'fqdn.backuppcserver.com',
+  rsync_share_name      => ['/home', '/etc'],
+  hosts_file_more_users => 'john',
+}
+```
+You'll need to specify the hostname of the node on which you installed backuppc server. This value should be the same as the facter value for fqdn. By default the
+xfer_method is rsync and you can specify the paths to backup with the parameter rsync_share_name. With rsync and tar methods the module will create on the client
+an system account and allow the server access to it (see the description section in this readme).
+
+### Backuping up the backuppc server itself
+
+```puppet
+class { 'backuppc::client':
+  backuppc_hostname => $::fqdn,
+  xfer_method       => 'tar',
+  tar_share_name    => ['/home', '/etc', '/var/log'],
+  tar_client_cmd    => '/usr/bin/sudo $tarPath -c -v -f - -C $shareName --totals',
+  tar_full_args     => '$fileList',
+  tar_incr_arge     => '--newer=$incrDate $fileList',
+}
+```
+Debian by default installs a 'localhost' host, but if you want to managed it with puppet or if you're on Centos/RHEL this example will use the tar method to backup
+the paths you sepcify. The example uses sudo which is not configured in the module itself.
+
+
+## Limitations
+
+* This module has been tested on Debian Wheezy, Squeeze and Centos 6.4.
+* Storeconfigs need to be enabled for this module to work.
+* There is a TODO for generating and installing the server's ssh key. Currently it relies on a facter value that is only present on the second run of puppet.
+
+
diff --git a/files/debian/backuppc.preseed b/files/backuppc.preseed
similarity index 100%
rename from files/debian/backuppc.preseed
rename to files/backuppc.preseed
diff --git a/lib/facter/backuppc_pubkey_rsa.rb b/lib/facter/backuppc_pubkey_rsa.rb
index e64f13d..f58a7fa 100644
--- a/lib/facter/backuppc_pubkey_rsa.rb
+++ b/lib/facter/backuppc_pubkey_rsa.rb
@@ -1,7 +1,15 @@
 Facter.add('backuppc_pubkey_rsa') do
   setcode do
-    if File.exists?('/var/lib/backuppc/.ssh/id_rsa.pub')
-      File.open('/var/lib/backuppc/.ssh/id_rsa.pub').read.split(' ')[1]
+    os_family   = Facter.value(:osfamily)
+    sshkey_path ||= case Facter.value(:osfamily)
+    when 'RedHat'
+      '/var/lib/BackupPC/.ssh/id_rsa.pub'
+    when 'Debian'
+      '/var/lib/backuppc/.ssh/id_rsa.pub'
+    end
+    
+    if File.exists?(sshkey_path)
+      File.open(sshkey_path).read.split(' ')[1]
     end
   end
-end
\ No newline at end of file
+end
diff --git a/manifests/apache.pp b/manifests/apache.pp
deleted file mode 100644
index ec4c5b9..0000000
--- a/manifests/apache.pp
+++ /dev/null
@@ -1,7 +0,0 @@
-class backuppc::apache inherits backuppc::params {
-  file { $config_apache:
-    ensure  => symlink,
-    target  => '/etc/backuppc/apache.conf',
-    require => Package[$package]
-  }
-}
\ No newline at end of file
diff --git a/manifests/client.pp b/manifests/client.pp
index a3de795..3b33c8c 100644
--- a/manifests/client.pp
+++ b/manifests/client.pp
@@ -1,87 +1,360 @@
+# == Class: backuppc::client
+#
+# Configures a host for backup with the backuppc server.
+# Uses storedconfigs to provide the backuppc server with
+# required information.
+#
+# === Parameters
+#
+# For parameters that are not documented here see the server
+# manifest.
+#
+# [*ensure*]
+# Present or absent.
+#
+# [*system_account*]
+# Name of the user that will be created to allow backuppc
+# access to the system via ssh. This only applies to xfer
+# methods that require it. To override this set the system_account
+# to an empty string and configure access to the client yourself as
+# the default in the global config file (root) or change the
+# rsync_client_cmd or tar_client_cmd to suit your setup.
+#
+# [*system_home_directory*]
+# Absolute path to the home directory of the system account.
+#
+# [*manage_sudo*]
+# Boolean. Set to true to configure and install sudo and the
+# sudoers.d directory. Defaults to false and is only applied
+# if 1) xfer_method requires ssh access and 2) you're using
+# the system_account parameter.
+#
+# [*manage_rsync*]
+# Boolean. By default will install the rsync package. If you
+# manage this elsewhere set it to false. Defaults to true and
+# is only applied if 1) the xfer_method is rsync and 2) you're
+# using the system_account parameter.
+#
+# [*blackout_bad_ping_limit*]
+# To allow for periodic rebooting of a PC or other brief periods when a
+# PC is not on the network, a number of consecutive bad pings is allowed
+# before the good ping count is reset.
+#
+# [*backups_disable*]
+# Disable all full and incremental backups. These settings are useful for a client that
+# is no longer being backed up (eg: a retired machine), but you wish to keep the last backups
+# available for browsing or restoring to other machines.
+#
+# [*xfer_method*]
+# What transport method to use to backup each host. Valid values are rsync,
+# rsyncd, tar and smb.
+#
+# [*xfer_loglevel*]
+# Level of verbosity in Xfer log files. 0 means be quiet, 1 will give will
+# give one line per file, 2 will also show skipped files on incrementals,
+# higher values give more output.
+#
+# [*smb_share_name*]
+# Name of the host share that is backed up when using SMB. This can be a string or an
+# array of strings if there are multiple shares per host.
+#
+# [*smb_share_username*]
+# Smbclient share user name. This is passed to smbclient's -U argument.
+#
+# [*smb_share_passwd*]
+# Smbclient share password. This is passed to smbclient via its PASSWD environment variable.
+#
+# [*smb_client_full_cmd*]
+# Command to run smbclient for a full dump.
+#
+# [*smb_client_incr_cmd*]
+# Command to run smbclient for an incremental dump.
+#
+# [*smb_client_restore_cmd*]
+# Command to run smbclient for a restore.
+#
+# [*tar_share_name*]
+# Which host directories to backup when using tar transport. This can be a string or an array
+# of strings if there are multiple directories to backup per host.
+#
+# [*tar_client_cmd*]
+# Command to run tar on the client. GNU tar is required. The default will run
+# the tar command as the user you specify in system_account.
+#
+# [*tar_full_args*]
+# Extra tar arguments for full backups.
+#
+# [*tar_incr_args*]
+# Extra tar arguments for incr backups.
+#
+# [*tar_client_restore_cmd*]
+# Full command to run tar for restore on the client. GNU tar is required.
+#
+# [*rsync_client_cmd*]
+# Full command to run rsync on the client machine. The default will run
+# the rsync command as the user you specify in system_account.
+#
+# [*rsync_client_restore_cmd*]
+# Full command to run rsync for restore on the client.
+#
+# [*rsync_share_name*]
+# Share name to backup. For $Conf{XferMethod} = "rsync" this should be a
+# file system path, eg '/' or '/home'.
+#
+# [*rsyncd_client_port*]
+# Rsync daemon port on host.
+#
+# [*rsyncd_user_name*]
+# Rsync daemon user name on host.
+#
+# [*rsyncd_passwd*]
+# Rsync daemon password on host.
+#
+# [*rsyncd_auth_required*]
+# Whether authentication is mandatory when connecting to the client's rsyncd. By default
+# this is on, ensuring that BackupPC will refuse to connect to an rsyncd on the client that
+# is not password protected.
+#
+# [*rsync_csum_cache_verify_prob*]
+# When rsync checksum caching is enabled (by adding the --checksum-seed=32761 option to
+# rsync_args), the cached checksums can be occasionally verified to make sure the file
+# contents matches the cached checksums.
+#
+# [*rsync_args*]
+# Arguments to rsync for backup.
+#
+# [*rsync_restore_args*]
+# Arguments to rsync for restore.
+#
+# [*backup_files_only*]
+# List of directories or files to backup. If this is defined, only these
+# directories or files will be backed up.
+#
+# [*backup_files_exclude*]
+# List of directories or files to exclude from the backup. For xfer_method smb,
+# only one of backup_files_exclude and backup_files_only can be specified per share.
+# If both are set for a particular share, then backup_files_only takes precedence and
+# backup_files_exclude is ignored.
+#
+# [*dump_pre_user_cmd*]
+# Optional command to run before a dump.
+#
+# [*dump_post_user_cmd*]
+# Optional command to run after a dump.
+#
+# [*dump_pre_share_cmd*]
+# Optional command to run before a dump of a share.
+#
+# [*dump_post_share_cmd*]
+# Optional command to run after a dump of a share.
+#
+# [*restore_pre_user_cmd*]
+# Optional command to run before a restore.
+#
+# [*restore_post_user_cmd*]
+# Optional command to run after a restore.
+#
+# [*user_cmd_check_status*]
+# Whether the exit status of each PreUserCmd and PostUserCmd is checked.
+#
+# [*hosts_file_dhcp*]
+# The way hosts are discovered has changed and now in most cases you should
+# use the default of 0 for the DHCP flag, even if the host has a dynamically
+# assigned IP address.
+#
+# [*hosts_file_most_users*]
+# Additional user names, separate by commas and with no white space, can be
+# specified. These users will also have full permission in the CGI interface
+# to stop/start/browse/restore backups for this host. These users will not be
+# sent email about this host.
+#
+# === Examples
+#
+#  See tests folder.
+#
+# === Authors
+#
+# Scott Barr <gsbarr@gmail.com>
+#
 class backuppc::client (
-    $full_period      = 6.97,
-    $incr_period      = 0.97,
-    $keep_full        = 1,
-    $keep_incr        = 6,
-    $maxage_full      = 90,
-    $maxage_incr      = 30,
-    $maxage_partial   = 3,
-    $only             = undef,
-    $exclude          = undef,
-    $pinglimit        = 3,
-    $blackoutcount    = 7,
-    $xfer_method       = 'rsync',
-    $xfer_loglevel     = 1
-) inherits backuppc::client::params {
-  user { 'backup':
-    ensure  => present,
-    shell   => '/bin/bash',
-    comment => 'BackupPC',
-    system  => true
+  $ensure                = 'present',
+  $backuppc_hostname     = '',
+  $system_account        = 'backup',
+  $system_home_directory = '/var/backups',
+  $manage_sudo           = false,
+  $manage_rsync          = true,
+  $full_period           = false,
+  $full_keep_cnt         = false,
+  $full_age_max          = false,
+  $incr_period           = false,
+  $incr_keep_cnt         = false,
+  $incr_age_max          = false,
+  $incr_levels           = [],
+  $incr_fill             = false,
+  $partial_age_max       = false,
+  $blackout_bad_ping_limit = false,
+  $blackout_good_cnt     = false,
+  $backups_disable       = false,
+  $xfer_method           = 'rsync',
+  $xfer_loglevel         = 1,
+  $smb_share_name        = false,
+  $smb_share_username    = false,
+  $smb_share_passwd      = false,
+  $smb_client_full_cmd   = false,
+  $smb_client_incr_cmd   = false,
+  $smb_client_restore_cmd = false,
+  $tar_share_name        = false,
+  $tar_client_cmd        = false,
+  $tar_full_args         = false,
+  $tar_incr_args         = false,
+  $tar_client_restore_cmd = false,
+  $rsync_client_cmd      = false,
+  $rsync_client_restore_cmd = false,
+  $rsync_share_name      = false,
+  $rsyncd_client_port    = false,
+  $rsyncd_user_name      = false,
+  $rsyncd_passwd         = false,
+  $rsyncd_auth_required  = false,
+  $rsync_csum_cache_verify_prob = false,
+  $rsync_args            = [],
+  $rsync_restore_args    = [],
+  $backup_files_only     = [],
+  $backup_files_exclude  = [],
+  $dump_pre_user_cmd     = false,
+  $dump_post_user_cmd    = false,
+  $dump_pre_share_cmd    = false,
+  $dump_post_share_cmd   = false,
+  $restore_pre_user_cmd  = false,
+  $restore_post_user_cmd = false,
+  $user_cmd_check_status = true,
+  $email_notify_min_days = false,
+  $email_from_user_name  = false,
+  $email_admin_user_name = false,
+  $email_notify_old_backup_days = false,
+  $hosts_file_dhcp       = 0,
+  $hosts_file_more_users = '',
+    ) {
+  include backuppc::params
+
+  validate_re($ensure, '^(present|absent)$',
+  'ensure parameter must have a value of: present or absent')
+
+  if empty($backuppc_hostname) {
+    fail('Please provide the hostname of the node that hosts backuppc.')
   }
 
-  package { 'rsync':
-    ensure  => installed
+  validate_re($xfer_method, '^(smb|rsync|rsyncd|tar)$',
+  'Xfer_method parameter must have value of: smb, rsync, rsyncd or tar')
+
+  validate_re($xfer_loglevel, '^[0-2]$',
+  'Xfer_loglevel parameter must be a 0, 1 or 2')
+
+  $real_incr_fill = bool2num($incr_fill)
+  $real_backups_disable = bool2num($backups_disable)
+  $real_rsyncd_auth_required = bool2num($rsyncd_auth_required)
+  $real_user_cmd_check_status = bool2num($user_cmd_check_status)
+
+  # With these xfer_methods we require sudo to grant access
+  # from the backuppc server to this client. It may be managed
+  # elsewhere so we allow it to be overridden with the manage_sudo
+  # parameter.
+  if $xfer_method in ['rsync', 'tar'] and ! empty($system_account)
+  {
+    validate_absolute_path($system_home_directory)
+
+    if $xfer_method == 'rsync' {
+      if $manage_rsync {
+        package { 'rsync':
+          ensure => installed,
+        }
+      }
+      $sudo_command = '/usr/bin/rsync'
+    }
+    else {
+      $sudo_command = $backuppc::params::tar_path
+    }
+
+    if $manage_sudo {
+      package { 'sudo':
+        ensure => installed,
+        before => File['/etc/sudoers.d/backuppc'],
+      }
+      file { '/etc/sudoers.d/':
+        ensure  => directory,
+        purge   => false,
+        require => Package['sudo'],
+      }
+      file_line { 'sudo_includedir':
+        ensure  => present,
+        path    => '/etc/sudoers',
+        line    => '#includedir /etc/sudoers.d',
+        require => Package['sudo'],
+      }
+    }
+
+    file { '/etc/sudoers.d/backuppc':
+      ensure  => $ensure,
+      owner   => 'root',
+      group   => 'root',
+      mode    => '0440',
+      content => "${system_account} ALL=(ALL:ALL) NOPASSWD: ${sudo_command}\n",
+    }
+
+    user { $system_account:
+      ensure     => $ensure,
+      home       => $system_home_directory,
+      managehome => true,
+      shell      => '/bin/bash',
+      comment    => 'BackupPC',
+      system     => true
+    }
+
+    file { "${system_home_directory}/.ssh":
+      ensure  => directory,
+      mode    => '0700',
+      owner   => $system_account,
+      group   => $system_account,
+      require => User[$system_account],
+    }
+
+    file { "${system_home_directory}/backuppc.sh":
+      ensure  => $ensure,
+      owner   => 'root',
+      group   => 'root',
+      mode    => '0755',
+      content => template('backuppc/client/backuppc.sh.erb'),
+      require => User[$system_account],
+    }
+
+    Ssh_authorized_key <<| tag == "backuppc_${backuppc_hostname}" |>> {
+      user    => $system_account,
+      require => File["${system_home_directory}/.ssh"]
+    }
   }
 
-  file { "${home_directory}/backuppc.sh":
-    ensure  => present,
-    owner   => 'root',
-    group   => 'root',
-    mode    => '0755',
-    source  => "puppet:///modules/${module_name}/client/backuppc.sh"
+  if $::fqdn != $backuppc_hostname {
+    @@sshkey { $::fqdn:
+      ensure => $ensure,
+      type   => 'ssh-rsa',
+      key    => $::sshrsakey,
+      tag    => "backuppc_sshkeys_${backuppc_hostname}",
+    }
   }
 
-  file { "${home_directory}/.ssh":
-    ensure  => directory,
-    mode    => 0700,
-    owner   => 'backup',
-    group   => 'backup',
-  }
-  
-
-  @@concat { "${topdir}/pc/${::fqdn}/exclude.list":
-    owner => 'backuppc',
-    group => 'backuppc',
-    mode  => 0750,
-    tag   => "backuppc_exclude_${::domain}"
+  @@file_line { "backuppc_host_${::fqdn}":
+    ensure  => $ensure,
+    path    => $backuppc::params::hosts,
+    match   => "^${::fqdn}.*$",
+    line    => "${::fqdn} ${hosts_file_dhcp} backuppc ${hosts_file_more_users}\n",
+    tag     => "backuppc_hosts_${backuppc_hostname}",
   }
 
-  @@concat::fragment { "backuppc_host_${::fqdn}":
-    target  => '/etc/backuppc/hosts',
-    content => "${::fqdn} 0 backuppc\n",
-    notify  => Service[$service],
-    tag     => "backuppc_hosts_${::domain}"
-  }
-  
-  @@file { "${topdir}/pc/${::fqdn}":
-    ensure  => directory,
-    owner   => 'backuppc',
-    group   => 'backuppc',
-    mode    => 0750,
-    tag     => "backuppc_pc_${::domain}",
-  }
-  
-  @@file { "${topdir}/pc/${::fqdn}/config.pl":
-    ensure  => present,
+  @@file { "${backuppc::params::config_directory}/pc/${::fqdn}.pl":
+    ensure  => $ensure,
     content => template("${module_name}/host.pl.erb"),
     owner   => 'backuppc',
-    group   => 'www-data',
-    mode    => '0740',
-    notify  => Service[$service],
-    tag     => "backuppc_config_${::domain}"
+    group   => $backuppc::params::group_apache,
+    mode    => '0640',
+    tag     => "backuppc_config_${backuppc_hostname}"
   }
-  
-  Ssh_authorized_key <<| tag == "backuppc_${::domain}" |>> {
-    require => File["${home_directory}/.ssh"]
-  }
-
-  file { '/etc/sudoers.d/backup':
-    ensure  => present,
-    owner   => 'root',
-    group   => 'root',
-    mode    => 440,
-    content => "backup ALL=(ALL:ALL) NOPASSWD: /usr/bin/rsync\n",
-    require => Package['sudo']
-  }
-}
\ No newline at end of file
+}
diff --git a/manifests/client/exclude.pp b/manifests/client/exclude.pp
deleted file mode 100644
index 3c487fe..0000000
--- a/manifests/client/exclude.pp
+++ /dev/null
@@ -1,15 +0,0 @@
-define backuppc::client::exclude ($exclude) {
-  include backuppc::params
-  include backuppc::client::params
-
-  if ! is_array($exclude) {
-   fail("exclude must be a list")
-  }
-
-  @@concat::fragment { "backuppc_exclude_${::fqdn}_${name}":
-    target  => "${topdir}/pc/${::fqdn}/exclude.list",
-    content => inline_template("<%= exclude.join('\n') %>"),
-    require => Concat["${topdir}/pc/${::fqdn}/exclude.list"],
-    tag     => "backuppc_exclude_${::domain}"
-  }
-}
\ No newline at end of file
diff --git a/manifests/client/params.pp b/manifests/client/params.pp
deleted file mode 100644
index 26e13f6..0000000
--- a/manifests/client/params.pp
+++ /dev/null
@@ -1,10 +0,0 @@
-class backuppc::client::params inherits backuppc::params {
-  case $operatingsystem {
-    'ubuntu', 'debian': {
-      $home_directory = '/var/backups'
-    }
-    default: {
-      fail("Operating system ${operatingsystem} is not supported by this module")
-    }
-  }
-}
\ No newline at end of file
diff --git a/manifests/debian.pp b/manifests/debian.pp
deleted file mode 100644
index dbcb13a..0000000
--- a/manifests/debian.pp
+++ /dev/null
@@ -1,6 +0,0 @@
-class backuppc::debian inherits backuppc::params {
-  file { '/var/cache/debconf/backuppc.seeds':
-    ensure  => present,
-    source  => "puppet:///modules/${module_name}/debian/backuppc.preseed"
-  }
-}
\ No newline at end of file
diff --git a/manifests/init.pp b/manifests/init.pp
deleted file mode 100644
index e13fec7..0000000
--- a/manifests/init.pp
+++ /dev/null
@@ -1,99 +0,0 @@
-# Class: backuppc
-#
-# This module manages backuppc
-#
-# Parameters:
-#
-# Actions:
-#
-# Requires:
-#
-# Sample Usage:
-#
-# [Remember: No empty lines between comments and class definition]
-class backuppc inherits backuppc::params {
-  include concat::setup
-  
-  # Set up dependencies
-  Package[$package] -> File[$config] -> Service[$service]
-
-  # Include preseeding for debian packages
-  case $operatingsystem {
-    'ubuntu', 'debian': {
-      include backuppc::debian
-    }
-  }
-
-  # BackupPC package and service configuration
-  package { $package:
-    ensure  => installed,
-  }
-
-  service { $service:
-    ensure    => running,
-    hasstatus => false,
-    pattern   => 'BackupPC'
-  }
-
-  file { $config:
-    ensure  => present,
-    owner   => 'backuppc',
-    group   => 'www-data',
-    mode    => '0644',
-    # content => template("${module_name}/config.pl"),
-  }
-  
-  file { $config_directory:
-    ensure  => present,
-    owner   => 'backuppc',
-    group   => 'www-data',
-    require => Package[$package]
-  }
-  
-  exec { 'backuppc-ssh-keygen':
-    command => "/usr/bin/ssh-keygen -f ${topdir}/.ssh/id_rsa -C 'BackupPC on ${::fqdn}' -N ''",
-    user    => 'backuppc',
-    unless  => "test -f ${topdir}/.ssh/id_rsa"
-  }
-
-  # Export backuppc's authorized key to all clients
-  @@ssh_authorized_key { "backuppc_${::fqdn}":
-    ensure  => present,
-    key     => $::backuppc_pubkey_rsa,
-    name    => "backuppc_${::fqdn}",
-    user    => 'backup',
-    options => [
-      "from=\"${::ipaddress}\"",
-      'command="/var/backups/backuppc.sh"'
-    ],
-    type    => 'ssh-rsa',
-    tag     => "backuppc_${::domain}",
-  }
-  
-  # Hosts
-  concat { '/etc/backuppc/hosts':
-    owner => 'backuppc',
-    group => 'backuppc',
-    mode  => 0750
-  }
-  
-  # FIXME: we use a custom fact to setup concat ...
-  create_resources('concat', $backuppc_hosts, {
-    owner => 'backuppc',
-    group => 'backuppc',
-    mode  => 0750
-  })
-
-  concat::fragment { 'hosts_header':
-    target  => '/etc/backuppc/hosts',
-    content => "host        dhcp    user    moreUsers     # <--- do not edit this line\n",
-    order   => 01,
-  }
-  
-  File <<| tag == "backuppc_pc_${::domain}" |>>
-  File <<| tag == "backuppc_config_${::domain}" |>>
-  Concat::Fragment <<| tag == "backuppc_hosts_${::domain}" |>>
-
-  Concat <<| tag == "backuppc_exclude_${::domain}" |>>
-  Concat::Fragment <<| tag == "backuppc_exclude_${::domain}" |>>
-}
diff --git a/manifests/params.pp b/manifests/params.pp
index 7e83726..3ea4ae0 100644
--- a/manifests/params.pp
+++ b/manifests/params.pp
@@ -1,16 +1,55 @@
+# == Class: backuppc::params
+#
+# Params class for backuppc.
+#
+# === Authors
+#
+# Scott Barr <gsbarr@gmail.com>
+#
 class backuppc::params {
-  case $operatingsystem {
-    'ubuntu', 'debian': {
-      $package        = 'backuppc'
-      $service        = 'backuppc'
-      $topdir         = '/var/lib/backuppc'
-      $config         = '/etc/backuppc/config.pl'
-      $hosts          = '/etc/backuppc/hosts'
-      $config_directory = '/etc/backuppc'
-      $config_apache  = '/etc/apache2/conf.d/backuppc.conf'
+  case $::osfamily {
+    'Debian': {
+      $package            = 'backuppc'
+      $service            = 'backuppc'
+      $topdir             = '/var/lib/backuppc'
+      $config_directory   = '/etc/backuppc'
+      $config             = "${config_directory}/config.pl"
+      $hosts              = "${config_directory}/hosts"
+      $install_directory  = '/usr/share/backuppc'
+      $cgi_directory      = "${install_directory}/cgi-bin"
+      $cgi_image_dir      = "${install_directory}/image"
+      $cgi_image_dir_url  = '/backuppc/image'
+      $log_directory      = '/var/lib/backuppc/log'
+      $config_apache      = '/etc/apache2/conf.d/backuppc.conf'
+      $group_apache       = 'www-data'
+      $par_path           = '/usr/bin/par2\' if -x \'/usr/bin/par2'
+      $gzip_path          = '/bin/gzip'
+      $bzip2_path         = '/bin/bzip2'
+      $tar_path           = '/bin/tar'
+    }
+    'RedHat': {
+      $package            = 'BackupPC'
+      $service            = 'backuppc'
+      $topdir             = '/var/lib/BackupPC'
+      $config_directory   = '/etc/BackupPC'
+      $config             = "${config_directory}/config.pl"
+      $hosts              = "${config_directory}/hosts"
+      $install_directory  = '/usr/share/BackupPC'
+      $cgi_directory      = "${install_directory}/sbin"
+      $cgi_image_dir      = "${install_directory}/html"
+      $cgi_image_dir_url  = '/BackupPC/images'
+      $log_directory      = '/var/log/BackupPC'
+      $config_apache      = '/etc/httpd/conf.d/BackupPC.conf'
+      $group_apache       = 'apache'
+      $par_path           = ''
+      $gzip_path          = '/usr/bin/gzip'
+      $bzip2_path         = '/usr/bin/bzip2'
+      $tar_path           = '/bin/gtar'
     }
     default: {
-      fail("Operating system ${operatingsystem} is not supported by this module")
+      fail("Operating system ${::operatingsystem} is not supported by this module")
     }
   }
-}
\ No newline at end of file
+
+  $htpasswd_apache = "${config_directory}/htpasswd"
+}
diff --git a/manifests/server.pp b/manifests/server.pp
new file mode 100644
index 0000000..a9e38a9
--- /dev/null
+++ b/manifests/server.pp
@@ -0,0 +1,420 @@
+# == Class: backuppc::server
+#
+# This module manages backuppc
+#
+# === Parameters
+#
+# [*ensure*]
+# Present or absent
+#
+# [*service_enable*]
+# Boolean. Will enable service at boot
+# and ensure a running service.
+#
+# [*wakup_schedule*]
+# Times at which we wake up, check all the PCs,
+# and schedule necessary backups. Times are measured
+# in hours since midnight. Can be fractional if
+# necessary (eg: 4.25 means 4:15am).
+#
+# [*max_backups*]
+# Maximum number of simultaneous backups to run. If
+# there are no user backup requests then this is the
+# maximum number of simultaneous backups.
+#
+# [*max_user_backups*]
+# Additional number of simultaneous backups that users
+# can run. As many as $Conf{MaxBackups} + $Conf{MaxUserBackups}
+# requests can run at the same time.
+#
+# [*max_pending_cmds*]
+# Maximum number of pending link commands. New backups will only
+# be started if there are no more than $Conf{MaxPendingCmds} plus
+# $Conf{MaxBackups} number of pending link commands, plus running
+# jobs. This limit is to make sure BackupPC doesn't fall too far
+# behind in running BackupPC_link commands.
+#
+# [*max_backup_pc_nightly_jobs*]
+# How many BackupPC_nightly processes to run in parallel. Each night,
+# at the first wakeup listed in $Conf{WakeupSchedule}, BackupPC_nightly
+# is run. Its job is to remove unneeded files in the pool, ie: files that
+# only have one link. To avoid race conditions, BackupPC_nightly and BackupPC_link
+# cannot run at the same time. Starting in v3.0.0, BackupPC_nightly can run
+# concurrently with backups (BackupPC_dump).
+#
+# [*backup_pc_nightly_period*]
+# How many days (runs) it takes BackupPC_nightly to traverse the entire pool.
+# Normally this is 1, which means every night it runs, it does traverse the entire
+# pool removing unused pool files.
+#
+# [*max_old_log_files*]
+# Maximum number of log files we keep around in log directory. These files are aged
+# nightly. A setting of 14 means the log directory will contain about 2 weeks of old
+# log files, in particular at most the files LOG, LOG.0, LOG.1, ... LOG.13 (except today's
+# LOG, these files will have a .z extension if compression is on).
+#
+# [*df_max_usage_pct*]
+# Maximum threshold for disk utilization on the __TOPDIR__ filesystem. If the output
+# from $Conf{DfPath} reports a percentage larger than this number then no new regularly
+# scheduled backups will be run. However, user requested backups (which are usually
+# incremental and tend to be small) are still performed, independent of disk usage. Also,
+# currently running backups will not be terminated when the disk usage exceeds this number.
+#
+# [*trash_clean_sleep_sec*]
+# How long BackupPC_trashClean sleeps in seconds between each check of the trash directory.
+#
+# [*dhcp_address_ranges*]
+# List of DHCP address ranges we search looking for PCs to backup. This is an array of
+# hashes for each class C address range. This is only needed if hosts in the conf/hosts
+# file have the dhcp flag set.
+#
+# [*full_period*]
+# Minimum period in days between full backups. A full dump will only be done if at least
+# this much time has elapsed since the last full dump, and at least $Conf{IncrPeriod}
+# days has elapsed since the last successful dump.
+#
+# [*full_keep_cnt*]
+# Number of full backups to keep.
+#
+# [*full_age_max*]
+# Very old full backups are removed after $Conf{FullAgeMax} days. However, we keep
+# at least $Conf{FullKeepCntMin} full backups no matter how old they are.
+#
+# [*incr_period*]
+# Minimum period in days between incremental backups (a user requested incremental
+# backup will be done anytime on demand).
+#
+# [*incr_keep_cnt*]
+# Number of incremental backups to keep.
+#
+# [*incr_age_max*]
+# Very old incremental backups are removed after $Conf{IncrAgeMax} days. However,
+# we keep at least $Conf{IncrKeepCntMin} incremental backups no matter how old
+# they are.
+#
+# [*incr_levels*]
+# A full backup has level 0. A new incremental of level N will backup all files
+# that have changed since the most recent backup of a lower level.
+#
+# [*partial_age_max*]
+# A failed full backup is saved as a partial backup. The rsync XferMethod can
+# take advantage of the partial full when the next backup is run. This parameter
+# sets the age of the partial full in days: if the partial backup is older than
+# this number of days, then rsync will ignore (not use) the partial full when the
+# next backup is run. If you set this to a negative value then no partials will be
+# saved. If you set this to 0, partials will be saved, but will not be used by the
+# next backup.
+#
+# [*incr_fill*]
+# Boolean. Whether incremental backups are filled. "Filling" means that the most recent fulli
+# (or filled) dump is merged into the new incremental dump using hardlinks. This
+# makes an incremental dump look like a full dump.
+#
+# [*restore_info_keep_cnt*]
+# Number of restore logs to keep. BackupPC remembers information about each restore
+# request. This number per client will be kept around before the oldest ones are pruned.
+#
+# [*archive_info_keep_cnt*]
+# Number of archive logs to keep. BackupPC remembers information about each archive request.
+# This number per archive client will be kept around before the oldest ones are pruned.
+#
+# [*blackout_good_cnt*]
+# PCs that are always or often on the network can be backed up after hours, to reduce PC,
+# network and server load during working hours. For each PC a count of consecutive good
+# pings is maintained. Once a PC has at least $Conf{BlackoutGoodCnt} consecutive good pings
+# it is subject to "blackout" and not backed up during hours and days specified by $Conf{BlackoutPeriods}.
+#
+# [*blackout_zero_files_is_fatal*]
+# Boolean. A backup of a share that has zero files is considered fatal. This is used to catch miscellaneous Xfer
+# errors that result in no files being backed up. If you have shares that might be
+# empty (and therefore an empty backup is valid) you should set this to false.
+#
+# [*email_notify_min_days*]
+# Minimum period between consecutive emails to a single user. This tries to keep annoying email to users to
+# a reasonable level.
+#
+# [*email_from_user_name*]
+# Name to use as the "from" name for email.
+#
+# [*email_admin_user_name*]
+# Destination address to an administrative user who will receive a nightly email with warnings and errors.
+#
+# [*email_notify_old_backup_days*]
+# How old the most recent backup has to be before notifying user. When there have been no backups in this
+# number of days the user is sent an email.
+#
+# [*email_headers*]
+# Additional email headers.
+#
+# [*apache_configuration*]
+# Boolean. Whether to install the apache configuration file that creates an alias for the /backuppc url.
+# Disable this if you intend to install backuppc as a virtual host yourself.
+#
+# [*apache_allow_from*]
+# A space seperated list of hostnames, ip addresses and networks that are permitted to
+# access the backuppc interface.
+#
+# [*apache_require_ssl*]
+# This directive forbids access unless HTTP over SSL (i.e. HTTPS) is used. Relies on mod_ssl.
+#
+# [*backuppc_password*]
+# Password for the backuppc user used to access the web interface.
+#
+# === Examples
+#
+#  See tests folder.
+#
+# === Authors
+#
+# Scott Barr <gsbarr@gmail.com>
+#
+class backuppc::server (
+  $ensure                     = 'present',
+  $service_enable             = true,
+  $wakeup_schedule            = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23],
+  $max_backups                = 4,
+  $max_user_backups           = 4,
+  $max_pending_cmds           = 15,
+  $max_backup_pc_nightly_jobs = 2,
+  $backup_pc_nightly_period   = 1,
+  $max_old_log_files          = 14,
+  $df_max_usage_pct           = 95,
+  $trash_clean_sleep_sec      = 300,
+  $dhcp_address_ranges        = [],
+  $full_period                = '6.97',
+  $full_keep_cnt              = 1,
+  $full_age_max               = 90,
+  $incr_period                = '0.97',
+  $incr_keep_cnt              = 6,
+  $incr_age_max               = 30,
+  $incr_levels                = [1],
+  $incr_fill                  = false,
+  $partial_age_max            = 3,
+  $restore_info_keep_cnt      = 10,
+  $archive_info_keep_cnt      = 10,
+  $blackout_good_cnt          = 7,
+  $blackout_periods           = [ { hourBegin =>  7.0,
+                                    hourEnd   => 19.5,
+                                    weekDays  => [1, 2, 3, 4, 5],
+                                }, ],
+  $blackout_zero_files_is_fatal = true,
+  $email_notify_min_days      = 2.5,
+  $email_from_user_name       = 'backuppc',
+  $email_admin_user_name      = 'backuppc',
+  $email_notify_old_backup_days = 7,
+  $email_headers              = { 'MIME-Version' => 1.0,
+                                  'Content-Type' => 'text/plain; charset="iso-8859-1"', },
+  $apache_configuration       = true,
+  $apache_allow_from          = 'all',
+  $apache_require_ssl         = false,
+  $backuppc_password          = '',
+) {
+  include backuppc::params
+
+  if empty($backuppc_password) {
+    fail('Please provide a password for the backuppc user. This is used to login to the web based administration site.')
+  }
+  validate_bool($service_enable)
+  validate_bool($apache_require_ssl)
+
+  validate_re($ensure, '^(present|absent)$',
+  'ensure parameter must have a value of: present or absent')
+
+  validate_re($max_backups, '^[1-9]([0-9]*)?$',
+  'Max_backups parameter should be a number')
+
+  validate_re($max_user_backups, '^[1-9]([0-9]*)?$',
+  'Max_user_backups parameter should be a number')
+
+  validate_re($max_pending_cmds, '^[1-9]([0-9]*)?$',
+  'Max_pending_cmds parameter should be a number')
+
+  validate_re($max_backup_pc_nightly_jobs, '^[1-9]([0-9]*)?$',
+  'Max_backup_pc_nightly_jobs parameter should be a number')
+
+  validate_re($df_max_usage_pct, '^[1-9]([0-9]*)?$',
+  'Df_max_usage_pct parameter should be a number')
+
+  validate_re($max_old_log_files, '^[1-9]([0-9]*)?$',
+  'Max_old_log_files parameter should be a number')
+
+  validate_re($backup_pc_nightly_period, '^[1-9]([0-9]*)?$',
+  'Backup_pc_nightly_period parameter should be a number')
+
+  validate_re($trash_clean_sleep_sec,  '^[1-9]([0-9]*)?$',
+  'Trash_clean_sleep_sec parameter should be a number')
+
+  validate_re($full_period, '^[0-9]([0-9]*)?(\.[0-9]{1,2})?$',
+  'Full_period parameter should be a number')
+
+  validate_re($incr_period, '^[0-9]([0-9]*)?(\.[0-9]{1,2})?$',
+  'Incr_period parameter should be a number')
+
+  validate_re($full_keep_cnt, '^[1-9]([0-9]*)?$',
+  'Full_keep_cnt parameter should be a number')
+
+  validate_re($full_age_max, '^[1-9]([0-9]*)?$',
+  'Full_age_max parameter should be a number')
+
+  validate_re($incr_keep_cnt, '^[1-9]([0-9]*)?$',
+  'Incr_keep_cnt parameter should be a number')
+
+  validate_re($incr_age_max, '^[1-9]([0-9]*)?$',
+  'Incr_age_max parameter should be a number')
+
+  validate_re($partial_age_max, '^[1-9]([0-9]*)?$',
+  'Partial_age_max parameter should be a number')
+
+  validate_re($restore_info_keep_cnt, '^[1-9]([0-9]*)?$',
+  'Restore_info_keep_cnt parameter should be a number')
+
+  validate_re($archive_info_keep_cnt, '^[1-9]([0-9]*)?$',
+  'Restore_info_keep_cnt parameter should be a number')
+
+  validate_re($blackout_good_cnt, '^[1-9]([0-9]*)?$',
+  'Blackout_good_cnt parameter should be a number')
+
+  validate_re($email_notify_min_days, '^[0-9]([0-9]*)?(\.[0-9]{1,2})?$',
+  'Email_notify_min_days parameter should be a number')
+
+  validate_re($email_notify_old_backup_days, '^[1-9]([0-9]*)?$',
+  'Blackout_good_cnt parameter should be a number')
+
+  validate_array($wakeup_schedule)
+  validate_array($dhcp_address_ranges)
+  validate_array($incr_levels)
+  validate_array($blackout_periods)
+
+  validate_hash($email_headers)
+
+  validate_string($apache_allow_from)
+
+  $real_incr_fill = bool2num($incr_fill)
+  $real_bzfif     = bool2num($blackout_zero_files_is_fatal)
+
+  # Set up dependencies
+  Package[$backuppc::params::package] -> File[$backuppc::params::config] -> Service[$backuppc::params::service]
+
+  # Include preseeding for debian packages
+  if $::osfamily == 'Debian' {
+    file { '/var/cache/debconf/backuppc.seeds':
+      ensure  => $ensure,
+      source  => 'puppet:///modules/backuppc/backuppc.preseed',
+    }
+  }
+
+  # BackupPC package and service configuration
+  package { $backuppc::params::package:
+    ensure  => $ensure,
+  }
+
+  service { $backuppc::params::service:
+    ensure    => $service_enable,
+    enable    => $service_enable,
+    hasstatus => false,
+    pattern   => 'BackupPC'
+  }
+
+  file { $backuppc::params::config:
+    ensure  => $ensure,
+    owner   => 'backuppc',
+    group   => $backuppc::params::group_apache,
+    mode    => '0644',
+    content => template('backuppc/config.pl.erb'),
+  }
+
+  file { $backuppc::params::config_directory:
+    ensure  => $ensure,
+    owner   => 'backuppc',
+    group   => $backuppc::params::group_apache,
+    require => Package[$backuppc::params::package],
+  }
+
+  file { "${backuppc::params::config_directory}/pc":
+    ensure  => link,
+    target  => $backuppc::params::config_directory,
+    require => Package[$backuppc::params::package],
+  }
+
+  # Workaround for client exported resources that are
+  # on a different osfamily. Maintain a symlink to alternative
+  # config directory targets.
+  case $::osfamily {
+    'Debian': {
+      file { '/etc/BackupPC':
+        ensure => link,
+        target => $backuppc::params::config_directory,
+      }
+    }
+    'RedHat': {
+      file { '/etc/backuppc':
+        ensure => link,
+        target => $backuppc::params::config_directory,
+      }
+    }
+    default: {
+      notify { "If you've added support for ${::operatingsystem} you'll need to extend this case statement to.":
+      }
+    }
+  }
+
+  exec { 'backuppc-ssh-keygen':
+    command => "ssh-keygen -f ${backuppc::params::topdir}/.ssh/id_rsa -C 'BackupPC on ${::fqdn}' -N ''",
+    user    => 'backuppc',
+    unless  => "test -f ${backuppc::params::topdir}/.ssh/id_rsa",
+    path    => ['/usr/bin','/bin'],
+    require => Package[$backuppc::params::package],
+  }
+
+  # BackupPC apache configuration
+  if $apache_configuration {
+    file { $backuppc::params::config_apache:
+      ensure  => $ensure,
+      content => template("backuppc/apache_${::osfamily}.erb"),
+      require => Package[$backuppc::params::package],
+    }
+
+    # Create the default admin account
+    backuppc::server::user { 'backuppc':
+      password => $backuppc_password
+    }
+  }
+
+  # Export backuppc's authorized key to all clients
+  # TODO don't rely on facter to obtain the ssh key.
+  if ! empty($::backuppc_pubkey_rsa) {
+    @@ssh_authorized_key { "backuppc_${::fqdn}":
+      ensure  => present,
+      key     => $::backuppc_pubkey_rsa,
+      name    => "backuppc_${::fqdn}",
+      user    => 'backup',
+      options => [
+        'command="~/backuppc.sh"'
+      ],
+      type    => 'ssh-rsa',
+      tag     => "backuppc_${::fqdn}",
+    }
+  }
+
+  # Hosts
+  File <<| tag == "backuppc_config_${::fqdn}" |>> {
+    group   => $backuppc::params::group_apache,
+    notify  => Service[$backuppc::params::service],
+    require => File["${backuppc::params::config_directory}/pc"],
+  }
+  File_line <<| tag == "backuppc_hosts_${::fqdn}" |>> {
+    notify  => Service[$backuppc::params::service],
+    require => Package[$backuppc::params::package],
+  }
+
+  # Ensure readable file permissions on
+  # the known hosts file.
+  file { '/etc/ssh/ssh_known_hosts':
+    ensure => file,
+    owner  => 'root',
+    group  => 'root',
+    mode   => '0644',
+  }
+
+  Sshkey <<| tag == "backuppc_sshkeys_${::fqdn}" |>>
+}
diff --git a/manifests/server/user.pp b/manifests/server/user.pp
new file mode 100644
index 0000000..bc3a700
--- /dev/null
+++ b/manifests/server/user.pp
@@ -0,0 +1,54 @@
+# == Define: backuppc::server::user
+#
+# Add user credentials to the backuppc htpasswd file.
+#
+# === Parameters
+#
+# [*ensure*]
+# Present or absent
+#
+# [*username*]
+# Namevar. Defaults to the title if no value is provided.
+#
+# [*password*]
+# Password for the account. Will be converted to a sha encrypted password.
+#
+# === Authors
+#
+# Scott Barr <gsbarr@gmail.com>
+#
+define backuppc::server::user (
+  $ensure   = 'present',
+  $username = undef,
+  $password = '',
+) {
+  include backuppc::params
+
+  validate_re($ensure, '^(present|absent)$',
+  'ensure parameter must have a value of: present or absent')
+
+  $real_username = $username ? {
+    undef   => $name,
+    default => $username,
+  }
+
+  if empty($password) {
+    fail("A password is required for the backuppc user account named '${real_username}'")
+  }
+  $real_password = inline_template("{SHA}<%= Base64.encode64(Digest::SHA1.digest('${password}')).chomp! %>")
+
+  Exec {
+    require => Package[$backuppc::params::package],
+    path    => ['/usr/bin', '/bin'],
+  }
+
+  if $ensure == 'present' {
+    exec {"test -f ${backuppc::params::htpasswd_apache} || OPT='-c'; htpasswd -bs \${OPT} ${backuppc::params::htpasswd_apache} ${real_username} '${password}'":
+      unless  => "grep -q ${real_username}:${real_password} ${backuppc::params::htpasswd_apache}",
+    }
+  } else {
+    exec {"htpasswd -D ${backuppc::params::htpasswd_apache} ${real_username}":
+      onlyif  => "egrep -q '^${real_username}:' ${backuppc::params::htpasswd_apache}",
+    }
+  }
+}
diff --git a/metadata.json b/metadata.json
deleted file mode 100644
index 8ce7797..0000000
--- a/metadata.json
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
-+-----------------------------------------------------------------------+
-|                                                                       |
-|                    ==> DO NOT EDIT THIS FILE! <==                     |
-|                                                                       |
-|   You should edit the `Modulefile` and run `puppet-module build`      |
-|   to generate the `metadata.json` file for your releases.             |
-|                                                                       |
-+-----------------------------------------------------------------------+
-*/
-
-{}
diff --git a/spec/spec.opts b/spec/spec.opts
deleted file mode 100644
index 91cd642..0000000
--- a/spec/spec.opts
+++ /dev/null
@@ -1,6 +0,0 @@
---format
-s
---colour
---loadby
-mtime
---backtrace
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
deleted file mode 100644
index a4aeeae..0000000
--- a/spec/spec_helper.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require 'pathname'
-dir = Pathname.new(__FILE__).parent
-$LOAD_PATH.unshift(dir, dir + 'lib', dir + '../lib')
-
-require 'mocha'
-require 'puppet'
-gem 'rspec', '=1.2.9'
-require 'spec/autorun'
-
-Spec::Runner.configure do |config|
-    config.mock_with :mocha
-end
-
-# We need this because the RAL uses 'should' as a method.  This
-# allows us the same behaviour but with a different method name.
-class Object
-    alias :must :should
-end
diff --git a/templates/apache_Debian.erb b/templates/apache_Debian.erb
new file mode 100644
index 0000000..30e2e5a
--- /dev/null
+++ b/templates/apache_Debian.erb
@@ -0,0 +1,22 @@
+#
+# This file is managed by puppet.
+#
+Alias /backuppc <%= scope.lookupvar('backuppc::params::cgi_directory') %>
+
+<Directory <%= scope.lookupvar('backuppc::params::cgi_directory') %>>
+  AllowOverride None
+  Order deny,allow
+  Deny from all
+  Allow from <%= @apache_allow_from %>
+  <% if @apache_require_ssl -%>
+  SSLRequireSSL
+  <% end -%>
+  Options ExecCGI FollowSymlinks
+  AddHandler cgi-script .cgi
+  DirectoryIndex index.cgi
+
+  AuthUserFile <%= scope.lookupvar('backuppc::params::htpasswd_apache') %>
+  AuthType basic
+  AuthName "BackupPC"
+  require valid-user
+</Directory>
diff --git a/templates/apache_RedHat.erb b/templates/apache_RedHat.erb
new file mode 100644
index 0000000..57a4c97
--- /dev/null
+++ b/templates/apache_RedHat.erb
@@ -0,0 +1,20 @@
+#
+# This file is managed by puppet.
+#
+Alias           /BackupPC/images        <%= scope.lookupvar('backuppc::params::cgi_image_dir') %>
+ScriptAlias     /BackupPC               <%= scope.lookupvar('backuppc::params::cgi_directory') %>/BackupPC_Admin
+ScriptAlias     /backuppc               <%= scope.lookupvar('backuppc::params::cgi_directory') %>/BackupPC_Admin
+
+<Directory <%= scope.lookupvar('backuppc::params::install_directory') %>>
+  Order deny,allow
+  Deny from all
+  Allow from <%= @apache_allow_from %>
+  <% if @apache_require_ssl -%>
+  SSLRequireSSL
+  <% end -%>
+  
+  AuthType Basic
+  AuthUserFile <%= scope.lookupvar('backuppc::params::htpasswd_apache') %>
+  AuthName "BackupPC"
+  require valid-user    
+</Directory>
diff --git a/files/client/backuppc.sh b/templates/client/backuppc.sh.erb
similarity index 69%
rename from files/client/backuppc.sh
rename to templates/client/backuppc.sh.erb
index 9db94ec..77295f7 100644
--- a/files/client/backuppc.sh
+++ b/templates/client/backuppc.sh.erb
@@ -5,11 +5,11 @@
 #
 
 case "${SSH_ORIGINAL_COMMAND}" in
-/usr/bin/rsync\ --server*)
+  /usr/bin/rsync\ * | <%= scope.lookupvar('backuppc::params::tar_path') %>\ * )
   sudo ${SSH_ORIGINAL_COMMAND}
   ;;
 *)
   echo "REJECTED: ${SSH_ORIGINAL_COMMAND}"
   exit 1
   ;;
-esac
\ No newline at end of file
+esac
diff --git a/templates/config.pl.erb b/templates/config.pl.erb
new file mode 100644
index 0000000..af63a28
--- /dev/null
+++ b/templates/config.pl.erb
@@ -0,0 +1,339 @@
+#
+# This file is managed by Puppet.
+#
+<% if @osfamily == 'Debian' -%>
+$ENV{'PATH'} = '/bin:/usr/bin';
+delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
+<% end -%>
+$Conf{ServerHost} = '<%= @fqdn %>';
+chomp($Conf{ServerHost});
+$Conf{ServerPort} = -1;
+$Conf{ServerMesgSecret} = '';
+$Conf{MyPath} = '/bin';
+$Conf{UmaskMode} = 027;
+$Conf{WakeupSchedule} = [<%= @wakeup_schedule.join(', ') %>];
+$Conf{MaxBackups} = <%= @max_backups %>;
+$Conf{MaxUserBackups} = <%= @max_user_backups %>;
+$Conf{MaxPendingCmds} = <%= @max_pending_cmds %>;
+$Conf{MaxBackupPCNightlyJobs} = <%= @max_backup_pc_nightly_jobs %>;
+$Conf{BackupPCNightlyPeriod} = <%= @backup_pc_nightly_period %>;
+$Conf{MaxOldLogFiles} = <%= @max_old_log_files %>;
+$Conf{DfPath} = '/bin/df';
+$Conf{DfCmd} = '$dfPath $topDir';
+$Conf{SplitPath} = '/usr/bin/split';
+$Conf{ParPath}   = '<%= scope.lookupvar('backuppc::params::par_path') %>';
+$Conf{CatPath}   = '/bin/cat';
+$Conf{GzipPath}  = '<%= scope.lookupvar('backuppc::params::gzip_path') %>';
+$Conf{Bzip2Path} = '<%= scope.lookupvar('backuppc::params::bzip2_path') %>';
+$Conf{DfMaxUsagePct} = <%= @df_max_usage_pct %>;
+$Conf{TrashCleanSleepSec} = <%= @trash_clean_sleep_sec %>;
+$Conf{DHCPAddressRanges} = [
+<% @dhcp_address_ranges.each do |range| -%>
+<% if range.is_a?(Hash) -%>{
+<% range.each_pair do |key,value| -%>
+  <%= key %>  => <% if key == 'ipAddrBase' %>'<%= value %>'<% else %><%= value %><% end %>,
+<% end -%>
+},
+<% end -%>
+<% end -%>];
+$Conf{BackupPCUser} = 'backuppc';
+$Conf{TopDir}      = '<%= scope.lookupvar('backuppc::params::topdir') %>';
+$Conf{ConfDir}     = '<%= scope.lookupvar('backuppc::params::config_directory') %>';
+$Conf{LogDir}      = '<%= scope.lookupvar('backuppc::params::log_directory') %>';
+$Conf{InstallDir}  = '<%= scope.lookupvar('backuppc::params::install_directory') %>';
+$Conf{CgiDir}      = '<%= scope.lookupvar('backuppc::params::cgi_directory') %>';
+$Conf{BackupPCUserVerify} = 1;
+$Conf{HardLinkMax} = 31999;
+$Conf{PerlModuleLoad}     = undef;
+$Conf{ServerInitdPath} = '';
+$Conf{ServerInitdStartCmd} = '';
+$Conf{FullPeriod} = <%= @full_period %>;
+$Conf{IncrPeriod} = <%= @incr_period %>;
+$Conf{FullKeepCnt} = <%= @full_keep_cnt %>;
+$Conf{FullKeepCntMin} = 1;
+$Conf{FullAgeMax}     = <%= @full_age_max %>;
+$Conf{IncrKeepCnt} = <%= @incr_keep_cnt %>;
+$Conf{IncrKeepCntMin} = 1;
+$Conf{IncrAgeMax}     = <%= @incr_age_max %>;
+$Conf{IncrLevels} = [<%= @incr_levels.join(', ') %>];
+$Conf{BackupsDisable} = 0;
+$Conf{PartialAgeMax} = <%= @partial_age_max %>;
+$Conf{IncrFill} = <%= @real_incr_fill %>;
+$Conf{RestoreInfoKeepCnt} = <%= @restore_info_keep_cnt %>;
+$Conf{ArchiveInfoKeepCnt} = <%= @archive_info_keep_cnt %>;
+$Conf{BackupFilesOnly} = undef;
+$Conf{BackupFilesExclude} = undef;
+$Conf{BlackoutBadPingLimit} = 3;
+$Conf{BlackoutGoodCnt}      = <%= @blackout_good_cnt %>;
+$Conf{BlackoutPeriods} = [
+<% @blackout_periods.each do |period| -%>
+<% if period.is_a?(Hash) -%>{
+<% period.each_pair do |key,value| -%>
+  <%= key %>  => <% if value.is_a?(Array) %>[<%= value.join(', ') %>]<% else %><%= value %><% end %>,
+<% end -%>
+},
+<% end -%>
+<% end -%>];
+$Conf{BackupZeroFilesIsFatal} = <%= @real_bzfif %>;
+$Conf{XferMethod} = 'rsync';
+$Conf{XferLogLevel} = 1;
+$Conf{ClientCharset} = '';
+$Conf{ClientCharsetLegacy} = 'iso-8859-1';
+$Conf{SmbShareName} = 'C$';
+$Conf{SmbShareUserName} = '';
+$Conf{SmbSharePasswd} = '';
+$Conf{SmbClientPath} = '/usr/bin/smbclient';
+$Conf{SmbClientFullCmd} = '$smbClientPath \\\\$host\\$shareName'
+      . ' $I_option -U $userName -E -N -d 1'
+            . ' -c tarmode\\ full -Tc$X_option - $fileList';
+$Conf{SmbClientIncrCmd} = '$smbClientPath \\\\$host\\$shareName'
+      . ' $I_option -U $userName -E -N -d 1'
+      . ' -c tarmode\\ full -TcN$X_option $timeStampFile - $fileList';
+$Conf{SmbClientRestoreCmd} = '$smbClientPath \\\\$host\\$shareName'
+            . ' $I_option -U $userName -E -N -d 1'
+            . ' -c tarmode\\ full -Tx -';
+$Conf{TarShareName} = '/';
+$Conf{TarClientCmd} = '$sshPath -q -x -n -l root $host'
+                    . ' env LC_ALL=C $tarPath -c -v -f - -C $shareName+'
+                    . ' --totals';
+$Conf{TarFullArgs} = '$fileList+';
+$Conf{TarIncrArgs} = '--newer=$incrDate+ $fileList+';
+$Conf{TarClientRestoreCmd} = '$sshPath -q -x -l root $host'
+       . ' env LC_ALL=C $tarPath -x -p --numeric-owner --same-owner'
+       . ' -v -f - -C $shareName+';
+$Conf{TarClientPath} = '<%= scope.lookupvar('backuppc::params::tar_path') %>';
+$Conf{RsyncClientPath} = '/usr/bin/rsync';
+$Conf{RsyncClientCmd} = '$sshPath -q -x -l root $host $rsyncPath $argList+';
+$Conf{RsyncClientRestoreCmd} = '$sshPath -q -x -l root $host $rsyncPath $argList+';
+$Conf{RsyncShareName} = '/';
+$Conf{RsyncdClientPort} = 873;
+$Conf{RsyncdUserName} = '';
+$Conf{RsyncdPasswd} = '';
+$Conf{RsyncdAuthRequired} = 1;
+$Conf{RsyncCsumCacheVerifyProb} = 0.01;
+$Conf{RsyncArgs} = [
+      #
+      # Do not edit these!
+      #
+            '--numeric-ids',
+            '--perms',
+            '--owner',
+            '--group',
+            '-D',
+            '--links',
+            '--hard-links',
+            '--times',
+            '--block-size=2048',
+            '--recursive',
+      #
+      # Rsync >= 2.6.3 supports the --checksum-seed option
+            # which allows rsync checksum caching on the server.
+      # Uncomment this to enable rsync checksum caching if
+            # you have a recent client rsync version and you want
+            # to enable checksum caching.
+      #
+      #'--checksum-seed=32761',
+      #
+      # Add additional arguments here
+      #
+];
+$Conf{RsyncRestoreArgs} = [
+      #
+      # Do not edit these!
+      #
+      '--numeric-ids',
+      '--perms',
+      '--owner',
+      '--group',
+      '-D',
+      '--links',
+            '--hard-links',
+      '--times',
+      '--block-size=2048',
+      '--relative',
+      '--ignore-times',
+      '--recursive',
+      #
+      # Rsync >= 2.6.3 supports the --checksum-seed option
+            # which allows rsync checksum caching on the server.
+      # Uncomment this to enable rsync checksum caching if
+            # you have a recent client rsync version and you want
+            # to enable checksum caching.
+      #
+      #'--checksum-seed=32761',
+      #
+      # Add additional arguments here
+      #
+];
+$Conf{BackupPCdShareName} = '/';
+$Conf{BackupPCdPath} = '';
+$Conf{BackupPCdCmd} = '$bpcdPath $host $shareName $poolDir XXXX $poolCompress $topDir/pc/$client/new';
+$Conf{BackupPCdRestoreCmd} = '$bpcdPath TODO';
+$Conf{ArchiveDest} = '/tmp';
+$Conf{ArchiveComp} = 'gzip';
+$Conf{ArchivePar} = 0;
+$Conf{ArchiveSplit} = 0;
+$Conf{ArchiveClientCmd} = '$Installdir/bin/BackupPC_archiveHost'
+  . ' $tarCreatePath $splitpath $parpath $host $backupnumber'
+  . ' $compression $compext $splitsize $archiveloc $parfile *';
+$Conf{SshPath} = '/usr/bin/ssh' if -x '/usr/bin/ssh';
+$Conf{NmbLookupPath} = '/usr/bin/nmblookup';
+$Conf{NmbLookupCmd} = '$nmbLookupPath -A $host';
+$Conf{NmbLookupFindHostCmd} = '$nmbLookupPath $host';
+$Conf{FixedIPNetBiosNameCheck} = 0;
+$Conf{PingPath} = '/bin/ping';
+$Conf{PingCmd} = '$pingPath -c 1 -w 3 $host';
+$Conf{PingMaxMsec} = 20;
+$Conf{CompressLevel} = 3;
+$Conf{ClientTimeout} = 72000;
+$Conf{MaxOldPerPCLogFiles} = 12;
+$Conf{DumpPostUserCmd}    = undef;
+$Conf{DumpPreShareCmd}    = undef;
+$Conf{DumpPostShareCmd}   = undef;
+$Conf{RestorePreUserCmd}  = undef;
+$Conf{RestorePostUserCmd} = undef;
+$Conf{ArchivePreUserCmd}  = undef;
+$Conf{ArchivePostUserCmd} = undef;
+$Conf{UserCmdCheckStatus} = 1;
+$Conf{ClientNameAlias} = undef;
+$Conf{SendmailPath} = '/usr/sbin/sendmail';
+$Conf{EMailNotifyMinDays} = <%= @email_notify_min_days %>;
+$Conf{EMailFromUserName} = '<%= @email_from_user_name %>';
+$Conf{EMailAdminUserName} = '<%= @email_admin_user_name %>';
+$Conf{EMailUserDestDomain} = '';
+$Conf{EMailNoBackupEverSubj} = undef;
+$Conf{EMailNoBackupEverMesg} = undef;
+$Conf{EMailNotifyOldBackupDays} = <%= @email_notify_old_backup_days %>;
+$Conf{EMailNoBackupRecentSubj} = undef;
+$Conf{EMailNoBackupRecentMesg} = undef;
+$Conf{EMailNotifyOldOutlookDays} = 5.0;
+$Conf{EMailOutlookBackupSubj} = undef;
+$Conf{EMailOutlookBackupMesg} = undef;
+$Conf{EMailHeaders} = <<EOF;
+<% @email_headers.each_pair do |header,value| -%>
+<%= header %>: <%= value %>
+<% end -%>
+EOF
+$Conf{CgiAdminUserGroup} = 'backuppc';
+$Conf{CgiAdminUsers}     = 'backuppc';
+$Conf{CgiURL} = 'http://'.$Conf{ServerHost}.'/backuppc/index.cgi';
+$Conf{Language} = 'en';
+$Conf{CgiUserHomePageCheck} = '';
+$Conf{CgiUserUrlCreate}     = 'mailto:%s';
+$Conf{CgiDateFormatMMDD} = 1;
+$Conf{CgiNavBarAdminAllHosts} = 1;
+$Conf{CgiSearchBoxEnable} = 1;
+$Conf{CgiNavBarLinks} = [
+    {
+        link  => "?action=view&type=docs",
+        lname => "Documentation",    # actually displays $Lang->{Documentation}
+    },
+    {
+        link  => "http://backuppc.wiki.sourceforge.net",
+        name  => "Wiki",              # displays literal "Wiki"
+    },
+    {
+        link  => "http://backuppc.sourceforge.net",
+        name  => "SourceForge",      # displays literal "SourceForge"
+    },
+];
+$Conf{CgiStatusHilightColor} = {
+    Reason_backup_failed           => '#ffcccc',
+    Reason_backup_done             => '#ccffcc',
+    Reason_no_ping                 => '#ffff99',
+    Reason_backup_canceled_by_user => '#ff9900',
+    Status_backup_in_progress      => '#66cc99',
+    Disabled_OnlyManualBackups     => '#d1d1d1',   
+    Disabled_AllBackupsDisabled    => '#d1d1d1',          
+};
+$Conf{CgiHeaders} = '<meta http-equiv="pragma" content="no-cache">';
+$Conf{CgiImageDir} = '<%= scope.lookupvar('backuppc::params::cgi_image_dir') %>';
+$Conf{CgiExt2ContentType} = { };
+$Conf{CgiImageDirURL} = '<%= scope.lookupvar('backuppc::params::cgi_image_dir_url') %>';
+$Conf{CgiCSSFile} = 'BackupPC_stnd.css';
+$Conf{CgiUserConfigEditEnable} = 1;
+$Conf{CgiUserConfigEdit} = {
+        FullPeriod                => 1,
+        IncrPeriod                => 1,
+        FullKeepCnt               => 1,
+        FullKeepCntMin            => 1,
+        FullAgeMax                => 1,
+        IncrKeepCnt               => 1,
+        IncrKeepCntMin            => 1,
+        IncrAgeMax                => 1,
+        IncrLevels                => 1,
+        IncrFill                  => 1,
+        PartialAgeMax             => 1,
+        RestoreInfoKeepCnt        => 1,
+        ArchiveInfoKeepCnt        => 1,
+        BackupFilesOnly           => 1,
+        BackupFilesExclude        => 1,
+        BackupsDisable            => 1,
+        BlackoutBadPingLimit      => 1,
+        BlackoutGoodCnt           => 1,
+        BlackoutPeriods           => 1,
+        BackupZeroFilesIsFatal    => 1,
+        ClientCharset             => 1,
+        ClientCharsetLegacy       => 1,
+        XferMethod                => 1,
+        XferLogLevel              => 1,
+        SmbShareName              => 1,
+        SmbShareUserName          => 1,
+        SmbSharePasswd            => 1,
+        SmbClientFullCmd          => 0,
+        SmbClientIncrCmd          => 0,
+        SmbClientRestoreCmd       => 0,
+        TarShareName              => 1,
+        TarFullArgs               => 1,
+        TarIncrArgs               => 1,
+        TarClientCmd              => 0,
+        TarClientRestoreCmd       => 0,
+        TarClientPath             => 0,
+        RsyncShareName            => 1,
+        RsyncdClientPort          => 1,
+        RsyncdPasswd              => 1,
+        RsyncdUserName            => 1,
+        RsyncdAuthRequired        => 1,
+        RsyncCsumCacheVerifyProb  => 1,
+        RsyncArgs                 => 1,
+        RsyncRestoreArgs          => 1,
+        RsyncClientCmd            => 0,
+        RsyncClientRestoreCmd     => 0,
+        RsyncClientPath           => 0,
+        ArchiveDest               => 1,
+        ArchiveComp               => 1,
+        ArchivePar                => 1,
+        ArchiveSplit              => 1,
+        ArchiveClientCmd          => 0,
+        FixedIPNetBiosNameCheck   => 1,
+        NmbLookupCmd              => 0,
+        NmbLookupFindHostCmd      => 0,
+        PingMaxMsec               => 1,
+        PingCmd                   => 0,
+        ClientTimeout             => 1,
+        MaxOldPerPCLogFiles       => 1,
+        CompressLevel             => 1,
+        ClientNameAlias           => 1,
+        DumpPreUserCmd            => 0,
+        DumpPostUserCmd           => 0,
+        RestorePreUserCmd         => 0,
+        RestorePostUserCmd        => 0,
+        ArchivePreUserCmd         => 0,
+        ArchivePostUserCmd        => 0,
+        DumpPostShareCmd          => 0,
+        DumpPreShareCmd           => 0,
+        UserCmdCheckStatus        => 0,
+        EMailNotifyMinDays        => 1,
+        EMailFromUserName         => 1,
+        EMailAdminUserName        => 1,
+        EMailUserDestDomain       => 1,
+        EMailNoBackupEverSubj     => 1,
+        EMailNoBackupEverMesg     => 1,
+        EMailNotifyOldBackupDays  => 1,
+        EMailNoBackupRecentSubj   => 1,
+        EMailNoBackupRecentMesg   => 1,
+        EMailNotifyOldOutlookDays => 1,
+        EMailOutlookBackupSubj    => 1,
+        EMailOutlookBackupMesg    => 1,
+        EMailHeaders              => 1,
+};
diff --git a/templates/host.pl.erb b/templates/host.pl.erb
index aa54caf..8944193 100644
--- a/templates/host.pl.erb
+++ b/templates/host.pl.erb
@@ -1,1635 +1,180 @@
-$ENV{'PATH'} = '/bin:/usr/bin';
-delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
-###########################################################################
-# What to backup and when to do it
-# (can be overridden in the per-PC config.pl)
-###########################################################################
-#
-# Minimum period in days between full backups. A full dump will only be
-# done if at least this much time has elapsed since the last full dump,
-# and at least $Conf{IncrPeriod} days has elapsed since the last
-# successful dump.
-#
-# Typically this is set slightly less than an integer number of days. The
-# time taken for the backup, plus the granularity of $Conf{WakeupSchedule}
-# will make the actual backup interval a bit longer.
-#
-$Conf{FullPeriod} = <%= full_period -%>;
-
-#
-# Minimum period in days between incremental backups (a user requested
-# incremental backup will be done anytime on demand).
-#
-# Typically this is set slightly less than an integer number of days. The
-# time taken for the backup, plus the granularity of $Conf{WakeupSchedule}
-# will make the actual backup interval a bit longer.
-#
-$Conf{IncrPeriod} = <%= incr_period -%>;
-
-#
-# Number of full backups to keep.  Must be >= 1.
-#
-# In the steady state, each time a full backup completes successfully
-# the oldest one is removed.  If this number is decreased, the
-# extra old backups will be removed.
-#
-# If filling of incremental dumps is off the oldest backup always
-# has to be a full (ie: filled) dump.  This might mean one or two
-# extra full dumps are kept until the oldest incremental backups expire.
-#
-# Exponential backup expiry is also supported.  This allows you to specify:
-#
-#   - num fulls to keep at intervals of 1 * $Conf{FullPeriod}, followed by
-#   - num fulls to keep at intervals of 2 * $Conf{FullPeriod},
-#   - num fulls to keep at intervals of 4 * $Conf{FullPeriod},
-#   - num fulls to keep at intervals of 8 * $Conf{FullPeriod},
-#   - num fulls to keep at intervals of 16 * $Conf{FullPeriod},
-#
-# and so on.  This works by deleting every other full as each expiry
-# boundary is crossed.
-#
-# Exponential expiry is specified using an array for $Conf{FullKeepCnt}:
-#
-#   $Conf{FullKeepCnt} = [4, 2, 3];
-#
-# Entry #n specifies how many fulls to keep at an interval of
-# 2^n * $Conf{FullPeriod} (ie: 1, 2, 4, 8, 16, 32, ...).
-#
-# The example above specifies keeping 4 of the most recent full backups
-# (1 week interval) two full backups at 2 week intervals, and 3 full
-# backups at 4 week intervals, eg:
-#
-#    full 0 19 weeks old   \
-#    full 1 15 weeks old    >---  3 backups at 4 * $Conf{FullPeriod}
-#    full 2 11 weeks old   / 
-#    full 3  7 weeks old   \____  2 backups at 2 * $Conf{FullPeriod}
-#    full 4  5 weeks old   /
-#    full 5  3 weeks old   \
-#    full 6  2 weeks old    \___  4 backups at 1 * $Conf{FullPeriod}
-#    full 7  1 week old     /
-#    full 8  current       /
-#
-# On a given week the spacing might be less than shown as each backup
-# ages through each expiry period.  For example, one week later, a
-# new full is completed and the oldest is deleted, giving:
-#
-#    full 0 16 weeks old   \
-#    full 1 12 weeks old    >---  3 backups at 4 * $Conf{FullPeriod}
-#    full 2  8 weeks old   / 
-#    full 3  6 weeks old   \____  2 backups at 2 * $Conf{FullPeriod}
-#    full 4  4 weeks old   /
-#    full 5  3 weeks old   \
-#    full 6  2 weeks old    \___  4 backups at 1 * $Conf{FullPeriod}
-#    full 7  1 week old     /
-#    full 8  current       /
-#
-# You can specify 0 as a count (except in the first entry), and the
-# array can be as long as you wish.  For example:
-#
-#   $Conf{FullKeepCnt} = [4, 0, 4, 0, 0, 2];
-#
-# This will keep 10 full dumps, 4 most recent at 1 * $Conf{FullPeriod},
-# followed by 4 at an interval of 4 * $Conf{FullPeriod} (approx 1 month
-# apart), and then 2 at an interval of 32 * $Conf{FullPeriod} (approx
-# 7-8 months apart).
-#
-# Example: these two settings are equivalent and both keep just
-# the four most recent full dumps:
-#
-#    $Conf{FullKeepCnt} = 4;
-#    $Conf{FullKeepCnt} = [4];
-#
-$Conf{FullKeepCnt} = <%= keep_full -%>;
-
-#
-# Very old full backups are removed after $Conf{FullAgeMax} days.  However,
-# we keep at least $Conf{FullKeepCntMin} full backups no matter how old
-# they are.
-#
-# Note that $Conf{FullAgeMax} will be increased to $Conf{FullKeepCnt}
-# times $Conf{FullPeriod} if $Conf{FullKeepCnt} specifies enough
-# full backups to exceed $Conf{FullAgeMax}.
-#
-$Conf{FullKeepCntMin} = <%= keep_full -%>;
-$Conf{FullAgeMax}     = <%= maxage_full -%>;
-
-#
-# Number of incremental backups to keep.  Must be >= 1.
-#
-# In the steady state, each time an incr backup completes successfully
-# the oldest one is removed.  If this number is decreased, the
-# extra old backups will be removed.
-#
-$Conf{IncrKeepCnt} = <%= keep_incr -%>;
-
-#
-# Very old incremental backups are removed after $Conf{IncrAgeMax} days.
-# However, we keep at least $Conf{IncrKeepCntMin} incremental backups no
-# matter how old they are.
-#
-$Conf{IncrKeepCntMin} = <%= keep_incr -%>;
-$Conf{IncrAgeMax}     = <%= maxage_incr -%>;
-
-#
-# Level of each incremental.  "Level" follows the terminology
-# of dump(1).  A full backup has level 0.  A new incremental
-# of level N will backup all files that have changed since
-# the most recent backup of a lower level.
-#
-# The entries of $Conf{IncrLevels} apply in order to each
-# incremental after each full backup.  It wraps around until
-# the next full backup.  For example, these two settings
-# have the same effect:
-#
-#       $Conf{IncrLevels} = [1, 2, 3];
-#       $Conf{IncrLevels} = [1, 2, 3, 1, 2, 3];
-#
-# This means the 1st and 4th incrementals (level 1) go all
-# the way back to the full.  The 2nd and 3rd (and 5th and
-# 6th) backups just go back to the immediate preceeding
-# incremental.
-#
-# Specifying a sequence of multi-level incrementals will
-# usually mean more than $Conf{IncrKeepCnt} incrementals will
-# need to be kept, since lower level incrementals are needed
-# to merge a complete view of a backup.  For example, with
-#
-#       $Conf{FullPeriod}  = 7;
-#       $Conf{IncrPeriod}  = 1;
-#       $Conf{IncrKeepCnt} = 6;
-#       $Conf{IncrLevels}  = [1, 2, 3, 4, 5, 6];
-#
-# there will be up to 11 incrementals in this case: 
-#
-#       backup #0  (full, level 0, oldest)
-#       backup #1  (incr, level 1)
-#       backup #2  (incr, level 2)
-#       backup #3  (incr, level 3)
-#       backup #4  (incr, level 4)
-#       backup #5  (incr, level 5)
-#       backup #6  (incr, level 6)
-#       backup #7  (full, level 0)
-#       backup #8  (incr, level 1)
-#       backup #9  (incr, level 2)
-#       backup #10 (incr, level 3)
-#       backup #11 (incr, level 4)
-#       backup #12 (incr, level 5, newest)
-#
-# Backup #1 (the oldest level 1 incremental) can't be deleted
-# since backups 2..6 depend on it.  Those 6 incrementals can't
-# all be deleted since that would only leave 5 (#8..12).
-# When the next incremental happens (level 6), the complete
-# set of 6 older incrementals (#1..6) will be deleted, since
-# that maintains the required number ($Conf{IncrKeepCnt})
-# of incrementals.  This situation is reduced if you set
-# shorter chains of multi-level incrementals, eg:
-#
-#       $Conf{IncrLevels}  = [1, 2, 3];
-#
-# would only have up to 2 extra incremenals before all 3
-# are deleted.
-#
-# BackupPC as usual merges the full and the sequence
-# of incrementals together so each incremental can be
-# browsed and restored as though it is a complete backup.
-# If you specify a long chain of incrementals then more
-# backups need to be merged when browsing, restoring,
-# or getting the starting point for rsync backups.
-# In the example above (levels 1..6), browing backup
-# #6 requires 7 different backups (#0..6) to be merged.
-#
-# Because of this merging and the additional incrementals
-# that need to be kept, it is recommended that some
-# level 1 incrementals be included in $Conf{IncrLevels}.
-#
-# Prior to version 3.0 incrementals were always level 1,
-# meaning each incremental backed up all the files that
-# changed since the last full.
-#
-$Conf{IncrLevels} = [1];
-
-#
-# Disable all full and incremental backups.  These settings are
-# useful for a client that is no longer being backed up
-# (eg: a retired machine), but you wish to keep the last
-# backups available for browsing or restoring to other machines.
-#
-# There are three values for $Conf{BackupsDisable}:
-#
-#   0    Backups are enabled.
-#
-#   1    Don't do any regular backups on this client.  Manually
-#        requested backups (via the CGI interface) will still occur.
-#
-#   2    Don't do any backups on this client.  Manually requested
-#        backups (via the CGI interface) will be ignored.
-#
-# In versions prior to 3.0 Backups were disabled by setting
-# $Conf{FullPeriod} to -1 or -2.
-#
-$Conf{BackupsDisable} = 0;
-
-#
-# A failed full backup is saved as a partial backup.  The rsync
-# XferMethod can take advantage of the partial full when the next
-# backup is run. This parameter sets the age of the partial full
-# in days: if the partial backup is older than this number of
-# days, then rsync will ignore (not use) the partial full when
-# the next backup is run.  If you set this to a negative value
-# then no partials will be saved.  If you set this to 0, partials
-# will be saved, but will not be used by the next backup.
-#
-# The default setting of 3 days means that a partial older than
-# 3 days is ignored when the next full backup is done.
-#
-$Conf{PartialAgeMax} = <%= maxage_partial -%>;
-
-#
-# Whether incremental backups are filled.  "Filling" means that the
-# most recent full (or filled) dump is merged into the new incremental
-# dump using hardlinks.  This makes an incremental dump look like a
-# full dump.  Prior to v1.03 all incremental backups were filled.
-# In v1.4.0 and later the default is off.
-#
-# BackupPC, and the cgi interface in particular, do the right thing on
-# un-filled incremental backups.  It will correctly display the merged
-# incremental backup with the most recent filled backup, giving the
-# un-filled incremental backups a filled appearance.  That means it
-# invisible to the user whether incremental dumps are filled or not.
-#
-# Filling backups takes a little extra disk space, and it does cost
-# some extra disk activity for filling, and later removal.  Filling
-# is no longer useful, since file mangling and compression doesn't
-# make a filled backup very useful. It's likely the filling option
-# will be removed from future versions: filling will be delegated to
-# the display and extraction of backup data.
-#
-# If filling is off, BackupPC makes sure that the oldest backup is
-# a full, otherwise the following incremental backups will be
-# incomplete.  This might mean an extra full backup has to be
-# kept until the following incremental backups expire.
-#
-# The default is off.  You can turn this on or off at any
-# time without affecting existing backups.
-#
-$Conf{IncrFill} = 0;
-
-#
-# Number of restore logs to keep.  BackupPC remembers information about
-# each restore request.  This number per client will be kept around before
-# the oldest ones are pruned.
-#
-# Note: files/dirs delivered via Zip or Tar downloads don't count as
-# restores.  Only the first restore option (where the files and dirs
-# are written to the host) count as restores that are logged.
-#
-$Conf{RestoreInfoKeepCnt} = 10;
-
-#
-# Number of archive logs to keep.  BackupPC remembers information
-# about each archive request.  This number per archive client will
-# be kept around before the oldest ones are pruned.
-#
-$Conf{ArchiveInfoKeepCnt} = 10;
-
-#
-# List of directories or files to backup.  If this is defined, only these
-# directories or files will be backed up.
-#
-# For Smb, only one of $Conf{BackupFilesExclude} and $Conf{BackupFilesOnly}
-# can be specified per share. If both are set for a particular share, then
-# $Conf{BackupFilesOnly} takes precedence and $Conf{BackupFilesExclude}
-# is ignored.
-#
-# This can be set to a string, an array of strings, or, in the case
-# of multiple shares, a hash of strings or arrays.  A hash is used
-# to give a list of directories or files to backup for each share
-# (the share name is the key).  If this is set to just a string or
-# array, and $Conf{SmbShareName} contains multiple share names, then
-# the setting is assumed to apply all shares.
-#
-# If a hash is used, a special key "*" means it applies to all
-# shares that don't have a specific entry.
-#
-# Examples:
-#    $Conf{BackupFilesOnly} = '/myFiles';
-#    $Conf{BackupFilesOnly} = ['/myFiles'];     # same as first example
-#    $Conf{BackupFilesOnly} = ['/myFiles', '/important'];
-#    $Conf{BackupFilesOnly} = {
-#       'c' => ['/myFiles', '/important'],      # these are for 'c' share
-#       'd' => ['/moreFiles', '/archive'],      # these are for 'd' share
-#    };
-#    $Conf{BackupFilesOnly} = {
-#       'c' => ['/myFiles', '/important'],      # these are for 'c' share
-#       '*' => ['/myFiles', '/important'],      # these are other shares
-#    };
-#
-$Conf{BackupFilesOnly} = undef;
-
-#
-# List of directories or files to exclude from the backup.  For Smb,
-# only one of $Conf{BackupFilesExclude} and $Conf{BackupFilesOnly}
-# can be specified per share.  If both are set for a particular share,
-# then $Conf{BackupFilesOnly} takes precedence and
-# $Conf{BackupFilesExclude} is ignored.
-#
-# This can be set to a string, an array of strings, or, in the case
-# of multiple shares, a hash of strings or arrays.  A hash is used
-# to give a list of directories or files to exclude for each share
-# (the share name is the key).  If this is set to just a string or
-# array, and $Conf{SmbShareName} contains multiple share names, then
-# the setting is assumed to apply to all shares.
-#
-# The exact behavior is determined by the underlying transport program,
-# smbclient or tar.  For smbclient the exlclude file list is passed into
-# the X option.  Simple shell wild-cards using "*" or "?" are allowed.
-#
-# For tar, if the exclude file contains a "/" it is assumed to be anchored
-# at the start of the string.  Since all the tar paths start with "./",
-# BackupPC prepends a "." if the exclude file starts with a "/".  Note
-# that GNU tar version >= 1.13.7 is required for the exclude option to
-# work correctly.  For linux or unix machines you should add
-# "/proc" to $Conf{BackupFilesExclude} unless you have specified
-# --one-file-system in $Conf{TarClientCmd} or --one-file-system in
-# $Conf{RsyncArgs}.  Also, for tar, do not use a trailing "/" in
-# the directory name: a trailing "/" causes the name to not match
-# and the directory will not be excluded.
-#
-# Users report that for smbclient you should specify a directory
-# followed by "/*", eg: "/proc/*", instead of just "/proc".
-#
-# FTP servers are traversed recursively so excluding directories will
-# also exclude its contents.  You can use the wildcard characters "*"
-# and "?" to define files for inclusion and exclusion.  Both
-# attributes $Conf{BackupFilesOnly} and $Conf{BackupFilesExclude} can
-# be defined for the same share.
-#
-# If a hash is used, a special key "*" means it applies to all
-# shares that don't have a specific entry.
-#
-# Examples:
-#    $Conf{BackupFilesExclude} = '/temp';
-#    $Conf{BackupFilesExclude} = ['/temp'];     # same as first example
-#    $Conf{BackupFilesExclude} = ['/temp', '/winnt/tmp'];
-#    $Conf{BackupFilesExclude} = {
-#       'c' => ['/temp', '/winnt/tmp'],         # these are for 'c' share
-#       'd' => ['/junk', '/dont_back_this_up'], # these are for 'd' share
-#    };
-#    $Conf{BackupFilesExclude} = {
-#       'c' => ['/temp', '/winnt/tmp'],         # these are for 'c' share
-#       '*' => ['/junk', '/dont_back_this_up'], # these are for other shares
-#    };
-#
-$Conf{BackupFilesExclude} = [
-<% exclude.each do |ex| -%>
-  '<%= ex -%>',
+$Conf{XferMethod} = '<%= @xfer_method %>';
+$Conf{XferLogLevel} = <%= @xfer_loglevel %>;
+<% if @backups_disable -%>
+$Conf{BackupsDisable} = <%= @real_backups_disable%>;
 <% end -%>
-];
-
-#
-# PCs that are always or often on the network can be backed up after
-# hours, to reduce PC, network and server load during working hours. For
-# each PC a count of consecutive good pings is maintained. Once a PC has
-# at least $Conf{BlackoutGoodCnt} consecutive good pings it is subject
-# to "blackout" and not backed up during hours and days specified by
-# $Conf{BlackoutPeriods}.
-#
-# To allow for periodic rebooting of a PC or other brief periods when a
-# PC is not on the network, a number of consecutive bad pings is allowed
-# before the good ping count is reset. This parameter is
-# $Conf{BlackoutBadPingLimit}.
-#
-# Note that bad and good pings don't occur with the same interval. If a
-# machine is always on the network, it will only be pinged roughly once
-# every $Conf{IncrPeriod} (eg: once per day). So a setting for
-# $Conf{BlackoutGoodCnt} of 7 means it will take around 7 days for a
-# machine to be subject to blackout. On the other hand, if a ping is
-# failed, it will be retried roughly every time BackupPC wakes up, eg,
-# every one or two hours. So a setting for $Conf{BlackoutBadPingLimit} of
-# 3 means that the PC will lose its blackout status after 3-6 hours of
-# unavailability.
-#
-# To disable the blackout feature set $Conf{BlackoutGoodCnt} to a negative
-# value.  A value of 0 will make all machines subject to blackout.  But
-# if you don't want to do any backups during the day it would be easier
-# to just set $Conf{WakeupSchedule} to a restricted schedule.
-#
-$Conf{BlackoutBadPingLimit} = 3;
-$Conf{BlackoutGoodCnt}      = 7;
-
-#
-# One or more blackout periods can be specified.  If a client is
-# subject to blackout then no regular (non-manual) backups will
-# be started during any of these periods.  hourBegin and hourEnd
-# specify hours fro midnight and weekDays is a list of days of
-# the week where 0 is Sunday, 1 is Monday etc.
-#
-# For example:
-#
-#    $Conf{BlackoutPeriods} = [
-#	{
-#	    hourBegin =>  7.0,
-#	    hourEnd   => 19.5,
-#	    weekDays  => [1, 2, 3, 4, 5],
-#	},
-#    ];
-#
-# specifies one blackout period from 7:00am to 7:30pm local time
-# on Mon-Fri.
-#
-# The blackout period can also span midnight by setting
-# hourBegin > hourEnd, eg:
-#
-#    $Conf{BlackoutPeriods} = [
-#	{
-#	    hourBegin =>  7.0,
-#	    hourEnd   => 19.5,
-#	    weekDays  => [1, 2, 3, 4, 5],
-#	},
-#	{
-#	    hourBegin => 23,
-#	    hourEnd   =>  5,
-#	    weekDays  => [5, 6],
-#	},
-#    ];
-#
-# This specifies one blackout period from 7:00am to 7:30pm local time
-# on Mon-Fri, and a second period from 11pm to 5am on Friday and
-# Saturday night.
-#
-$Conf{BlackoutPeriods} = [
-    {
-	hourBegin =>  7.0,
-	hourEnd   => 19.5,
-	weekDays  => [1, 2, 3, 4, 5],
-    },
-];
-
-#
-# A backup of a share that has zero files is considered fatal. This is
-# used to catch miscellaneous Xfer errors that result in no files being
-# backed up.  If you have shares that might be empty (and therefore an
-# empty backup is valid) you should set this flag to 0.
-#
-$Conf{BackupZeroFilesIsFatal} = 1;
-
-###########################################################################
-# How to backup a client
-# (can be overridden in the per-PC config.pl)
-###########################################################################
-#
-# What transport method to use to backup each host.  If you have
-# a mixed set of WinXX and linux/unix hosts you will need to override
-# this in the per-PC config.pl.
-#
-# The valid values are:
-#
-#   - 'smb':     backup and restore via smbclient and the SMB protocol.
-#                Easiest choice for WinXX.
-#
-#   - 'rsync':   backup and restore via rsync (via rsh or ssh).
-#                Best choice for linux/unix.  Good choice also for WinXX.
-#
-#   - 'rsyncd':  backup and restore via rsync daemon on the client.
-#                Best choice for linux/unix if you have rsyncd running on
-#                the client.  Good choice also for WinXX.
-#
-#   - 'tar':    backup and restore via tar, tar over ssh, rsh or nfs.
-#               Good choice for linux/unix.
-#
-#   - 'archive': host is a special archive host.  Backups are not done.
-#                An archive host is used to archive other host's backups
-#                to permanent media, such as tape, CDR or DVD.
-#               
-#
-$Conf{XferMethod} = '<%= xfer_method -%>';
-
-#
-# Level of verbosity in Xfer log files.  0 means be quiet, 1 will give
-# will give one line per file, 2 will also show skipped files on
-# incrementals, higher values give more output.
-#
-$Conf{XferLogLevel} = <%= xfer_loglevel -%>;
-
-#
-# Filename charset encoding on the client.  BackupPC uses utf8
-# on the server for filename encoding.  If this is empty, then
-# utf8 is assumed and client filenames will not be modified.
-# If set to a different encoding then filenames will converted
-# to/from utf8 automatically during backup and restore.
-#
-# If the file names displayed in the browser (eg: accents or special
-# characters) don't look right then it is likely you haven't set
-# $Conf{ClientCharset} correctly.
-#
-# If you are using smbclient on a WinXX machine, smbclient will convert
-# to the "unix charset" setting in smb.conf.  The default is utf8,
-# in which case leave $Conf{ClientCharset} empty since smbclient does
-# the right conversion.
-#
-# If you are using rsync on a WinXX machine then it does no conversion.
-# A typical WinXX encoding for latin1/western europe is 'cp1252',
-# so in this case set $Conf{ClientCharset} to 'cp1252'.
-#
-# On a linux or unix client, run "locale charmap" to see the client's
-# charset.  Set $Conf{ClientCharset} to this value.  A typical value
-# for english/US is 'ISO-8859-1'.
-#
-# Do "perldoc Encode::Supported" to see the list of possible charset
-# values.  The FAQ at http://www.cl.cam.ac.uk/~mgk25/unicode.html
-# is excellent, and http://czyborra.com/charsets/iso8859.html
-# provides more information on the iso-8859 charsets.
-#
-$Conf{ClientCharset} = '';
-
-#
-# Prior to 3.x no charset conversion was done by BackupPC.  Backups were
-# stored in what ever charset the XferMethod provided - typically utf8
-# for smbclient and the client's locale settings for rsync and tar (eg:
-# cp1252 for rsync on WinXX and perhaps iso-8859-1 with rsync on linux).
-# This setting tells BackupPC the charset that was used to store file
-# names in old backups taken with BackupPC 2.x, so that non-ascii file
-# names in old backups can be viewed and restored.
-#
-$Conf{ClientCharsetLegacy} = 'iso-8859-1';
-
-###########################################################################
-# Samba Configuration
-# (can be overwritten in the per-PC log file)
-###########################################################################
-#
-# Name of the host share that is backed up when using SMB.  This can be a
-# string or an array of strings if there are multiple shares per host.
-# Examples:
-#
-#   $Conf{SmbShareName} = 'c';          # backup 'c' share
-#   $Conf{SmbShareName} = ['c', 'd'];   # backup 'c' and 'd' shares
-#
-# This setting only matters if $Conf{XferMethod} = 'smb'.
-#
-$Conf{SmbShareName} = 'C$';
-
-#
-# Smbclient share user name.  This is passed to smbclient's -U argument.
-#
-# This setting only matters if $Conf{XferMethod} = 'smb'.
-#
-$Conf{SmbShareUserName} = '';
-
-#
-# Smbclient share password.  This is passed to smbclient via its PASSWD
-# environment variable.  There are several ways you can tell BackupPC
-# the smb share password.  In each case you should be very careful about
-# security.  If you put the password here, make sure that this file is
-# not readable by regular users!  See the "Setting up config.pl" section
-# in the documentation for more information.
-#
-# This setting only matters if $Conf{XferMethod} = 'smb'.
-#
-$Conf{SmbSharePasswd} = '';
-
-#
-# Full path for smbclient. Security caution: normal users should not
-# allowed to write to this file or directory.
-#
-# smbclient is from the Samba distribution. smbclient is used to
-# actually extract the incremental or full dump of the share filesystem
-# from the PC.
-#
-# This setting only matters if $Conf{XferMethod} = 'smb'.
-#
-$Conf{SmbClientPath} = '/usr/bin/smbclient';
-
-#
-# Command to run smbclient for a full dump.
-# This setting only matters if $Conf{XferMethod} = 'smb'.
-#
-# The following variables are substituted at run-time:
-#
-#    $smbClientPath   same as $Conf{SmbClientPath}
-#    $host            host to backup/restore
-#    $hostIP          host IP address
-#    $shareName       share name
-#    $userName        user name
-#    $fileList        list of files to backup (based on exclude/include)
-#    $I_option        optional -I option to smbclient
-#    $X_option        exclude option (if $fileList is an exclude list)
-#    $timeStampFile   start time for incremental dump
-#
-# Note: all Cmds are executed directly without a shell, so the prog name
-# needs to be a full path and you can't include shell syntax like
-# redirection and pipes; put that in a script if you need it.
-#
-$Conf{SmbClientFullCmd} = '$smbClientPath \\\\$host\\$shareName'
-	    . ' $I_option -U $userName -E -d 1'
-            . ' -c tarmode\\ full -Tc$X_option - $fileList';
-
-#
-# Command to run smbclient for an incremental dump.
-# This setting only matters if $Conf{XferMethod} = 'smb'.
-#
-# Same variable substitutions are applied as $Conf{SmbClientFullCmd}.
-#
-# Note: all Cmds are executed directly without a shell, so the prog name
-# needs to be a full path and you can't include shell syntax like
-# redirection and pipes; put that in a script if you need it.
-#
-$Conf{SmbClientIncrCmd} = '$smbClientPath \\\\$host\\$shareName'
-	    . ' $I_option -U $userName -E -d 1'
-	    . ' -c tarmode\\ full -TcN$X_option $timeStampFile - $fileList';
-
-#
-# Command to run smbclient for a restore.
-# This setting only matters if $Conf{XferMethod} = 'smb'.
-#
-# Same variable substitutions are applied as $Conf{SmbClientFullCmd}.
-#
-# If your smb share is read-only then direct restores will fail.
-# You should set $Conf{SmbClientRestoreCmd} to undef and the
-# corresponding CGI restore option will be removed.
-#
-# Note: all Cmds are executed directly without a shell, so the prog name
-# needs to be a full path and you can't include shell syntax like
-# redirection and pipes; put that in a script if you need it.
-#
-$Conf{SmbClientRestoreCmd} = '$smbClientPath \\\\$host\\$shareName'
-            . ' $I_option -U $userName -E -d 1'
-            . ' -c tarmode\\ full -Tx -';
-
-###########################################################################
-# Tar Configuration
-# (can be overwritten in the per-PC log file)
-###########################################################################
-#
-# Which host directories to backup when using tar transport.  This can be a
-# string or an array of strings if there are multiple directories to
-# backup per host.  Examples:
-#
-#   $Conf{TarShareName} = '/';			# backup everything
-#   $Conf{TarShareName} = '/home';		# only backup /home
-#   $Conf{TarShareName} = ['/home', '/src'];	# backup /home and /src
-#
-# The fact this parameter is called 'TarShareName' is for historical
-# consistency with the Smb transport options.  You can use any valid
-# directory on the client: there is no need for it to correspond to
-# any Smb share or device mount point.
-#
-# Note also that you can also use $Conf{BackupFilesOnly} to specify
-# a specific list of directories to backup.  It's more efficient to
-# use this option instead of $Conf{TarShareName} since a new tar is
-# run for each entry in $Conf{TarShareName}.
-#
-# On the other hand, if you add --one-file-system to $Conf{TarClientCmd}
-# you can backup each file system separately, which makes restoring one
-# bad file system easier.  In this case you would list all of the mount
-# points here, since you can't get the same result with
-# $Conf{BackupFilesOnly}:
-#
-#     $Conf{TarShareName} = ['/', '/var', '/data', '/boot'];
-#
-# This setting only matters if $Conf{XferMethod} = 'tar'.
-#
-$Conf{TarShareName} = '/';
-
-#
-# Full command to run tar on the client.  GNU tar is required.  You will
-# need to fill in the correct paths for ssh2 on the local host (server)
-# and GNU tar on the client.  Security caution: normal users should not
-# allowed to write to these executable files or directories.
-#
-# See the documentation for more information about setting up ssh2 keys.
-#
-# If you plan to use NFS then tar just runs locally and ssh2 is not needed.
-# For example, assuming the client filesystem is mounted below /mnt/hostName,
-# you could use something like:
-#
-#    $Conf{TarClientCmd} = '$tarPath -c -v -f - -C /mnt/$host/$shareName'
-#                        . ' --totals';
-#
-# In the case of NFS or rsh you need to make sure BackupPC's privileges
-# are sufficient to read all the files you want to backup.  Also, you
-# will probably want to add "/proc" to $Conf{BackupFilesExclude}.
-#
-# The following variables are substituted at run-time:
-#
-#   $host        host name
-#   $hostIP      host's IP address
-#   $incrDate    newer-than date for incremental backups
-#   $shareName   share name to backup (ie: top-level directory path)
-#   $fileList    specific files to backup or exclude
-#   $tarPath     same as $Conf{TarClientPath}
-#   $sshPath     same as $Conf{SshPath}
-#
-# If a variable is followed by a "+" it is shell escaped.  This is
-# necessary for the command part of ssh or rsh, since it ends up
-# getting passed through the shell.
-#
-# This setting only matters if $Conf{XferMethod} = 'tar'.
-#
-# Note: all Cmds are executed directly without a shell, so the prog name
-# needs to be a full path and you can't include shell syntax like
-# redirection and pipes; put that in a script if you need it.
-#
-$Conf{TarClientCmd} = '$sshPath -q -x -n -l root $host'
-                    . ' env LC_ALL=C $tarPath -c -v -f - -C $shareName+'
-                    . ' --totals';
-
-#
-# Extra tar arguments for full backups.  Several variables are substituted at
-# run-time.  See $Conf{TarClientCmd} for the list of variable substitutions.
-#
-# If you are running tar locally (ie: without rsh or ssh) then remove the
-# "+" so that the argument is no longer shell escaped.
-#
-# This setting only matters if $Conf{XferMethod} = 'tar'.
-#
-$Conf{TarFullArgs} = '$fileList+';
-
-#
-# Extra tar arguments for incr backups.  Several variables are substituted at
-# run-time.  See $Conf{TarClientCmd} for the list of variable substitutions.
-#
-# Note that GNU tar has several methods for specifying incremental backups,
-# including:
-#
-#   --newer-mtime $incrDate+
-#          This causes a file to be included if the modification time is
-#          later than $incrDate (meaning its contents might have changed).
-#          But changes in the ownership or modes will not qualify the
-#          file to be included in an incremental.
-#
-#   --newer=$incrDate+
-#          This causes the file to be included if any attribute of the
-#          file is later than $incrDate, meaning either attributes or
-#          the modification time.  This is the default method.  Do
-#          not use --atime-preserve in $Conf{TarClientCmd} above,
-#          otherwise resetting the atime (access time) counts as an
-#          attribute change, meaning the file will always be included
-#          in each new incremental dump.
-#
-# If you are running tar locally (ie: without rsh or ssh) then remove the
-# "+" so that the argument is no longer shell escaped.
-#
-# This setting only matters if $Conf{XferMethod} = 'tar'.
-#
-$Conf{TarIncrArgs} = '--newer=$incrDate+ $fileList+';
-
-#
-# Full command to run tar for restore on the client.  GNU tar is required.
-# This can be the same as $Conf{TarClientCmd}, with tar's -c replaced by -x
-# and ssh's -n removed.
-#
-# See $Conf{TarClientCmd} for full details.
-#
-# This setting only matters if $Conf{XferMethod} = "tar".
-#
-# If you want to disable direct restores using tar, you should set
-# $Conf{TarClientRestoreCmd} to undef and the corresponding CGI
-# restore option will be removed.
-#
-# Note: all Cmds are executed directly without a shell, so the prog name
-# needs to be a full path and you can't include shell syntax like
-# redirection and pipes; put that in a script if you need it.
-#
-$Conf{TarClientRestoreCmd} = '$sshPath -q -x -l root $host'
-		   . ' env LC_ALL=C $tarPath -x -p --numeric-owner --same-owner'
-		   . ' -v -f - -C $shareName+';
-
-#
-# Full path for tar on the client. Security caution: normal users should not
-# allowed to write to this file or directory.
-#
-# This setting only matters if $Conf{XferMethod} = 'tar'.
-#
-$Conf{TarClientPath} = '/bin/tar';
-
-###########################################################################
-# Rsync/Rsyncd Configuration
-# (can be overwritten in the per-PC log file)
-###########################################################################
-#
-# Path to rsync executable on the client
-#
-$Conf{RsyncClientPath} = '/usr/bin/rsync';
-
-#
-# Full command to run rsync on the client machine.  The following variables
-# are substituted at run-time:
-#
-#        $host           host name being backed up
-#        $hostIP         host's IP address
-#        $shareName      share name to backup (ie: top-level directory path)
-#        $rsyncPath      same as $Conf{RsyncClientPath}
-#        $sshPath        same as $Conf{SshPath}
-#        $argList        argument list, built from $Conf{RsyncArgs},
-#                        $shareName, $Conf{BackupFilesExclude} and
-#                        $Conf{BackupFilesOnly}
-#
-# This setting only matters if $Conf{XferMethod} = 'rsync'.
-#
-$Conf{RsyncClientCmd} = '$sshPath -q -x -l backup $host $rsyncPath $argList+';
-
-#
-# Full command to run rsync for restore on the client.  The following
-# variables are substituted at run-time:
-#
-#        $host           host name being backed up
-#        $hostIP         host's IP address
-#        $shareName      share name to backup (ie: top-level directory path)
-#        $rsyncPath      same as $Conf{RsyncClientPath}
-#        $sshPath        same as $Conf{SshPath}
-#        $argList        argument list, built from $Conf{RsyncArgs},
-#                        $shareName, $Conf{BackupFilesExclude} and
-#                        $Conf{BackupFilesOnly}
-#
-# This setting only matters if $Conf{XferMethod} = 'rsync'.
-#
-# Note: all Cmds are executed directly without a shell, so the prog name
-# needs to be a full path and you can't include shell syntax like
-# redirection and pipes; put that in a script if you need it.
-#
-$Conf{RsyncClientRestoreCmd} = '$sshPath -q -x -l root $host $rsyncPath $argList+';
-
-#
-# Share name to backup.  For $Conf{XferMethod} = "rsync" this should
-# be a file system path, eg '/' or '/home'.
-#
-# For $Conf{XferMethod} = "rsyncd" this should be the name of the module
-# to backup (ie: the name from /etc/rsynd.conf).
-#
-# This can also be a list of multiple file system paths or modules.
-# For example, by adding --one-file-system to $Conf{RsyncArgs} you
-# can backup each file system separately, which makes restoring one
-# bad file system easier.  In this case you would list all of the mount
-# points:
-#
-#     $Conf{RsyncShareName} = ['/', '/var', '/data', '/boot'];
-#
-$Conf{RsyncShareName} = '/';
-
-#
-# Rsync daemon port on the client, for $Conf{XferMethod} = "rsyncd".
-#
-$Conf{RsyncdClientPort} = 873;
-
-#
-# Rsync daemon user name on client, for $Conf{XferMethod} = "rsyncd".
-# The user name and password are stored on the client in whatever file
-# the "secrets file" parameter in rsyncd.conf points to
-# (eg: /etc/rsyncd.secrets).
-#
-$Conf{RsyncdUserName} = '';
-
-#
-# Rsync daemon user name on client, for $Conf{XferMethod} = "rsyncd".
-# The user name and password are stored on the client in whatever file
-# the "secrets file" parameter in rsyncd.conf points to
-# (eg: /etc/rsyncd.secrets).
-#
-$Conf{RsyncdPasswd} = '';
-
-#
-# Whether authentication is mandatory when connecting to the client's
-# rsyncd.  By default this is on, ensuring that BackupPC will refuse to
-# connect to an rsyncd on the client that is not password protected.
-# Turn off at your own risk.
-#
-$Conf{RsyncdAuthRequired} = 1;
-
-#
-# When rsync checksum caching is enabled (by adding the
-# --checksum-seed=32761 option to $Conf{RsyncArgs}), the cached
-# checksums can be occasionally verified to make sure the file
-# contents matches the cached checksums.  This is to avoid the
-# risk that disk problems might cause the pool file contents to
-# get corrupted, but the cached checksums would make BackupPC
-# think that the file still matches the client.
-#
-# This setting is the probability (0 means never and 1 means always)
-# that a file will be rechecked.  Setting it to 0 means the checksums
-# will not be rechecked (unless there is a phase 0 failure).  Setting
-# it to 1 (ie: 100%) means all files will be checked, but that is
-# not a desirable setting since you are better off simply turning
-# caching off (ie: remove the --checksum-seed option).
-#   
-# The default of 0.01 means 1% (on average) of the files during a full
-# backup will have their cached checksum re-checked.
-#   
-# This setting has no effect unless checksum caching is turned on.
-#   
-$Conf{RsyncCsumCacheVerifyProb} = 0.01;
-
-#
-# Arguments to rsync for backup.  Do not edit the first set unless you
-# have a thorough understanding of how File::RsyncP works.
-#
-$Conf{RsyncArgs} = [
-	    #
-	    # Do not edit these!
-	    #
-            '--numeric-ids',
-            '--perms',
-            '--owner',
-            '--group',
-            '-D',
-            '--links',
-            '--hard-links',
-            '--times',
-            '--block-size=2048',
-            '--recursive',
-
-	    #
-	    # Rsync >= 2.6.3 supports the --checksum-seed option
-            # which allows rsync checksum caching on the server.
-	    # Uncomment this to enable rsync checksum caching if
-            # you have a recent client rsync version and you want
-            # to enable checksum caching.
-	    #
-	    #'--checksum-seed=32761',
-];
-
-#
-# Additional arguments added to RsyncArgs.  This can be used in
-# conbination with $Conf{RsyncArgs} to allow customization of
-# the rsync arguments on a part-client basis.  The standard
-# arguments go in $Conf{RsyncArgs} and $Conf{RsyncArgsExtra}
-# can be set on a per-client basis.
-#
-# Examples of additional arguments that should work are --exclude/--include,
-# eg:
-#
-#     $Conf{RsyncArgsExtra} = [
-#           '--exclude', '/proc',
-#           '--exclude', '*.tmp',
-#     ];
-#
-# Both $Conf{RsyncArgs} and $Conf{RsyncArgsExtra} are subject
-# to the following variable substitutions:
-#
-#        $client       client name being backed up
-#        $host         host name (could be different from client name if
-#                                 $Conf{ClientNameAlias} is set)
-#        $hostIP       IP address of host
-#        $confDir      configuration directory path
-#
-# This allows settings of the form:
-#
-#     $Conf{RsyncArgsExtra} = [
-#             '--exclude-from=$confDir/pc/$host.exclude',
-#     ];
-#
-$Conf{RsyncArgsExtra} = [
-  '--exclude-from=$confDir/pc/$host/exclude.list',
-];
-
-#
-# Arguments to rsync for restore.  Do not edit the first set unless you
-# have a thorough understanding of how File::RsyncP works.
-#
-# If you want to disable direct restores using rsync (eg: is the module
-# is read-only), you should set $Conf{RsyncRestoreArgs} to undef and
-# the corresponding CGI restore option will be removed.
-#
-# $Conf{RsyncRestoreArgs} is subject to the following variable
-# substitutions:
-#
-#        $client       client name being backed up
-#        $host         host name (could be different from client name if
-#                                 $Conf{ClientNameAlias} is set)
-#        $hostIP       IP address of host
-#        $confDir      configuration directory path
-#
-# Note: $Conf{RsyncArgsExtra} doesn't apply to $Conf{RsyncRestoreArgs}.
-#
-$Conf{RsyncRestoreArgs} = [
-	    #
-	    # Do not edit these!
-	    #
-	    '--numeric-ids',
-	    '--perms',
-	    '--owner',
-	    '--group',
-	    '-D',
-	    '--links',
-            '--hard-links',
-	    '--times',
-	    '--block-size=2048',
-	    '--relative',
-	    '--ignore-times',
-	    '--recursive',
-
-	    #
-	    # Rsync >= 2.6.3 supports the --checksum-seed option
-            # which allows rsync checksum caching on the server.
-	    # Uncomment this to enable rsync checksum caching if
-            # you have a recent client rsync version and you want
-            # to enable checksum caching.
-	    #
-	    #'--checksum-seed=32761',
-
-	    #
-	    # Add additional arguments here
-	    #
-];
-
-###########################################################################
-# FTP Configuration
-# (can be overwritten in the per-PC log file)
-##########################################################################
-#
-# Which host directories to backup when using FTP.  This can be a
-# string or an array of strings if there are multiple shares per host.
-#
-# This value must be specified in one of two ways: either as a
-# subdirectory of the 'share root' on the server, or as the absolute
-# path of the directory.
-#
-# In the following example, if the directory /home/username is the
-# root share of the ftp server with the given username, the following
-# two values will back up the same directory:
-#
-#    $Conf{FtpShareName} = 'www';                # www directory
-#    $Conf{FtpShareName} = '/home/username/www'; # same directory
-#
-# Path resolution is not supported; i.e.; you may not have an ftp
-# share path defined as '../otheruser' or '~/games'.
-#
-#  Multiple shares may also be specified, as with other protocols:
-#
-#    $Conf{FtpShareName} = [ 'www',
-#                            'bin',
-#                            'config' ];
-#
-# Note also that you can also use $Conf{BackupFilesOnly} to specify
-# a specific list of directories to backup.  It's more efficient to
-# use this option instead of $Conf{FtpShareName} since a new tar is
-# run for each entry in $Conf{FtpShareName}.
-#
-# This setting only matters if $Conf{XferMethod} = 'ftp'.
-#
-$Conf{FtpShareName} = '';
-
-#
-# FTP user name.  This is used to log into the server.
-#
-# This setting is used only if $Conf{XferMethod} = 'ftp'.
-#
-$Conf{FtpUserName} = '';
-
-#
-# FTP user password.  This is used to log into the server.
-#
-# This setting is used only if $Conf{XferMethod} = 'ftp'.
-#
-$Conf{FtpPasswd} = '';
-
-#
-# Whether passive mode is used.  The correct setting depends upon
-# whether local or remote ports are accessible from the other machine,
-# which is affected by any firewall or routers between the FTP server
-# on the client and the BackupPC server.
-#
-# This setting is used only if $Conf{XferMethod} = 'ftp'.
-#
-$Conf{FtpPassive} = 1;
-
-#
-# Transfer block size. This sets the size of the amounts of data in
-# each frame. While undefined, this value takes the default value.
-#
-# This setting is used only if $Conf{XferMethod} = 'ftp'.
-#
-$Conf{FtpBlockSize} = 10240;
-
-#
-# The port of the ftp server.  If undefined, 21 is used.
-#
-# This setting is used only if $Conf{XferMethod} = 'ftp'.
-#
-$Conf{FtpPort} = 21;
-
-#
-# Connection timeout for FTP.  When undefined, the default is 120 seconds.
-#
-# This setting is used only if $Conf{XferMethod} = 'ftp'.
-#
-$Conf{FtpTimeout} = 120;
-
-#
-# Behaviour when BackupPC encounters symlinks on the FTP share.
-#
-# Symlinks cannot be restored via FTP, so the desired behaviour will
-# be different depending on the setup of the share. The default for
-# this behavor is 1.  Directory shares with more complicated directory
-# structures should consider other protocols.
-#
-$Conf{FtpFollowSymlinks} = 0;
-
-###########################################################################
-# Archive Configuration
-# (can be overwritten in the per-PC log file)
-###########################################################################
-#
-# Archive Destination
-#
-# The Destination of the archive
-# e.g. /tmp for file archive or /dev/nst0 for device archive
-#
-$Conf{ArchiveDest} = '/tmp';
-
-#
-# Archive Compression type
-#
-# The valid values are:
-#
-#   - 'none':  No Compression
-#
-#   - 'gzip':  Medium Compression. Recommended.
-#
-#   - 'bzip2': High Compression but takes longer.
-#
-$Conf{ArchiveComp} = 'gzip';
-
-#
-# Archive Parity Files
-#
-# The amount of Parity data to generate, as a percentage
-# of the archive size.
-# Uses the commandline par2 (par2cmdline) available from
-# http://parchive.sourceforge.net
-#
-# Only useful for file dumps.
-#
-# Set to 0 to disable this feature.
-#
-$Conf{ArchivePar} = 0;
-
-#
-# Archive Size Split
-#
-# Only for file archives. Splits the output into 
-# the specified size * 1,000,000.
-# e.g. to split into 650,000,000 bytes, specify 650 below.
-# 
-# If the value is 0, or if $Conf{ArchiveDest} is an existing file or
-# device (e.g. a streaming tape drive), this feature is disabled.
-#
-$Conf{ArchiveSplit} = 0;
-
-#
-# Archive Command
-#
-# This is the command that is called to actually run the archive process
-# for each host.  The following variables are substituted at run-time:
-#
-#   $Installdir    The installation directory of BackupPC
-#   $tarCreatePath The path to BackupPC_tarCreate
-#   $splitpath     The path to the split program
-#   $parpath       The path to the par2 program
-#   $host          The host to archive
-#   $backupnumber  The backup number of the host to archive
-#   $compression   The path to the compression program
-#   $compext       The extension assigned to the compression type
-#   $splitsize     The number of bytes to split archives into
-#   $archiveloc    The location to put the archive
-#   $parfile       The amount of parity data to create (percentage)
-#
-# Note: all Cmds are executed directly without a shell, so the prog name
-# needs to be a full path and you can't include shell syntax like
-# redirection and pipes; put that in a script if you need it.
-#
-$Conf{ArchiveClientCmd} = '$Installdir/bin/BackupPC_archiveHost'
-	. ' $tarCreatePath $splitpath $parpath $host $backupnumber'
-	. ' $compression $compext $splitsize $archiveloc $parfile *';
-
-#
-# Full path for ssh. Security caution: normal users should not
-# allowed to write to this file or directory.
-#
-$Conf{SshPath} = '/usr/bin/ssh' if -x '/usr/bin/ssh';
-
-#
-# Full path for nmblookup. Security caution: normal users should not
-# allowed to write to this file or directory.
-#
-# nmblookup is from the Samba distribution. nmblookup is used to get the
-# netbios name, necessary for DHCP hosts.
-#
-$Conf{NmbLookupPath} = '/usr/bin/nmblookup';
-
-#
-# NmbLookup command.  Given an IP address, does an nmblookup on that
-# IP address.  The following variables are substituted at run-time:
-#
-#   $nmbLookupPath      path to nmblookup ($Conf{NmbLookupPath})
-#   $host               IP address
-#
-# This command is only used for DHCP hosts: given an IP address, this
-# command should try to find its NetBios name.
-#
-# Note: all Cmds are executed directly without a shell, so the prog name
-# needs to be a full path and you can't include shell syntax like
-# redirection and pipes; put that in a script if you need it.
-#
-$Conf{NmbLookupCmd} = '$nmbLookupPath -A $host';
-
-#
-# NmbLookup command.  Given a netbios name, finds that host by doing
-# a NetBios lookup.  Several variables are substituted at run-time:
-#
-#   $nmbLookupPath      path to nmblookup ($Conf{NmbLookupPath})
-#   $host               NetBios name
-#
-# In some cases you might need to change the broadcast address, for
-# example if nmblookup uses 192.168.255.255 by default and you find
-# that doesn't work, try 192.168.1.255 (or your equivalent class C
-# address) using the -B option:
-#
-#    $Conf{NmbLookupFindHostCmd} = '$nmbLookupPath -B 192.168.1.255 $host';
-#
-# If you use a WINS server and your machines don't respond to
-# multicast NetBios requests you can use this (replace 1.2.3.4
-# with the IP address of your WINS server):
-#
-#    $Conf{NmbLookupFindHostCmd} = '$nmbLookupPath -R -U 1.2.3.4 $host';
-#
-# This is preferred over multicast since it minimizes network traffic.
-#
-# Experiment manually for your site to see what form of nmblookup command
-# works.
-#
-# Note: all Cmds are executed directly without a shell, so the prog name
-# needs to be a full path and you can't include shell syntax like
-# redirection and pipes; put that in a script if you need it.
-#
-$Conf{NmbLookupFindHostCmd} = '$nmbLookupPath $host';
-
-#
-# For fixed IP address hosts, BackupPC_dump can also verify the netbios
-# name to ensure it matches the host name.  An error is generated if
-# they do not match.  Typically this flag is off.  But if you are going
-# to transition a bunch of machines from fixed host addresses to DHCP,
-# setting this flag is a great way to verify that the machines have
-# their netbios name set correctly before turning on DCHP.
-#
-$Conf{FixedIPNetBiosNameCheck} = 0;
-
-#
-# Full path to the ping command.  Security caution: normal users
-# should not be allowed to write to this file or directory.
-#
-# If you want to disable ping checking, set this to some program
-# that exits with 0 status, eg:
-#
-#     $Conf{PingPath} = '/bin/echo';
-#
-$Conf{PingPath} = '/bin/ping';
-$Conf{Ping6Path} = '';
-
-#
-# Ping command.  The following variables are substituted at run-time:
-#
-#   $pingPath      path to ping ($Conf{PingPath})
-#   $host          host name
-#
-# Wade Brown reports that on solaris 2.6 and 2.7 ping -s returns the wrong
-# exit status (0 even on failure).  Replace with "ping $host 1", which
-# gets the correct exit status but we don't get the round-trip time.
-#
-# Note: all Cmds are executed directly without a shell, so the prog name
-# needs to be a full path and you can't include shell syntax like
-# redirection and pipes; put that in a script if you need it.
-#
-$Conf{PingCmd} = '$pingPath -c 1 $host';
-
-#
-# Maximum round-trip ping time in milliseconds.  This threshold is set
-# to avoid backing up PCs that are remotely connected through WAN or
-# dialup connections.  The output from ping -s (assuming it is supported
-# on your system) is used to check the round-trip packet time.  On your
-# local LAN round-trip times should be much less than 20msec.  On most
-# WAN or dialup connections the round-trip time will be typically more
-# than 20msec.  Tune if necessary.
-#
-$Conf{PingMaxMsec} = 20;
-
-#
-# Compression level to use on files.  0 means no compression.  Compression
-# levels can be from 1 (least cpu time, slightly worse compression) to
-# 9 (most cpu time, slightly better compression).  The recommended value
-# is 3.  Changing to 5, for example, will take maybe 20% more cpu time
-# and will get another 2-3% additional compression. See the zlib
-# documentation for more information about compression levels.
-#
-# Changing compression on or off after backups have already been done
-# will require both compressed and uncompressed pool files to be stored.
-# This will increase the pool storage requirements, at least until all
-# the old backups expire and are deleted.
-#
-# It is ok to change the compression value (from one non-zero value to
-# another non-zero value) after dumps are already done.  Since BackupPC
-# matches pool files by comparing the uncompressed versions, it will still
-# correctly match new incoming files against existing pool files.  The
-# new compression level will take effect only for new files that are
-# newly compressed and added to the pool.
-#
-# If compression was off and you are enabling compression for the first
-# time you can use the BackupPC_compressPool utility to compress the
-# pool.  This avoids having the pool grow to accommodate both compressed
-# and uncompressed backups.  See the documentation for more information.
-#
-# Note: compression needs the Compress::Zlib perl library.  If the
-# Compress::Zlib library can't be found then $Conf{CompressLevel} is
-# forced to 0 (compression off).
-#
-$Conf{CompressLevel} = 3;
-
-#
-# Timeout in seconds when listening for the transport program's
-# (smbclient, tar etc) stdout. If no output is received during this
-# time, then it is assumed that something has wedged during a backup,
-# and the backup is terminated.
-#
-# Note that stdout buffering combined with huge files being backed up
-# could cause longish delays in the output from smbclient that
-# BackupPC_dump sees, so in rare cases you might want to increase
-# this value.
-#
-# Despite the name, this parameter sets the timeout for all transport
-# methods (tar, smb etc).
-#
-$Conf{ClientTimeout} = 72000;
-
-#
-# Maximum number of log files we keep around in each PC's directory
-# (ie: pc/$host).  These files are aged monthly.  A setting of 12
-# means there will be at most the files LOG, LOG.0, LOG.1, ... LOG.11
-# in the pc/$host directory (ie: about a years worth).  (Except this
-# month's LOG, these files will have a .z extension if compression
-# is on).
-#
-# If you decrease this number after BackupPC has been running for a
-# while you will have to manually remove the older log files.
-#
-$Conf{MaxOldPerPCLogFiles} = 12;
-
-#
-# Optional commands to run before and after dumps and restores,
-# and also before and after each share of a dump.
-#
-# Stdout from these commands will be written to the Xfer (or Restore)
-# log file.  One example of using these commands would be to
-# shut down and restart a database server, dump a database
-# to files for backup, or doing a snapshot of a share prior
-# to a backup.  Example:
-#
-#    $Conf{DumpPreUserCmd} = '$sshPath -q -x -l root $host /usr/bin/dumpMysql';
-#
-# The following variable substitutions are made at run time for
-# $Conf{DumpPreUserCmd}, $Conf{DumpPostUserCmd}, $Conf{DumpPreShareCmd}
-# and $Conf{DumpPostShareCmd}:
-#
-#        $type         type of dump (incr or full)
-#        $xferOK       1 if the dump succeeded, 0 if it didn't
-#        $client       client name being backed up
-#        $host         host name (could be different from client name if
-#                                 $Conf{ClientNameAlias} is set)
-#        $hostIP       IP address of host
-#        $user         user name from the hosts file
-#        $moreUsers    list of additional users from the hosts file
-#        $share        the first share name (or current share for
-#                        $Conf{DumpPreShareCmd} and $Conf{DumpPostShareCmd})
-#        $shares       list of all the share names
-#        $XferMethod   value of $Conf{XferMethod} (eg: tar, rsync, smb)
-#        $sshPath      value of $Conf{SshPath},
-#        $cmdType      set to DumpPreUserCmd or DumpPostUserCmd
-#
-# The following variable substitutions are made at run time for
-# $Conf{RestorePreUserCmd} and $Conf{RestorePostUserCmd}:
-#
-#        $client       client name being backed up
-#        $xferOK       1 if the restore succeeded, 0 if it didn't
-#        $host         host name (could be different from client name if
-#                                 $Conf{ClientNameAlias} is set)
-#        $hostIP       IP address of host
-#        $user         user name from the hosts file
-#        $moreUsers    list of additional users from the hosts file
-#        $share        the first share name
-#        $XferMethod   value of $Conf{XferMethod} (eg: tar, rsync, smb)
-#        $sshPath      value of $Conf{SshPath},
-#        $type         set to "restore"
-#        $bkupSrcHost  host name of the restore source
-#        $bkupSrcShare share name of the restore source
-#        $bkupSrcNum   backup number of the restore source
-#        $pathHdrSrc   common starting path of restore source
-#        $pathHdrDest  common starting path of destination
-#        $fileList     list of files being restored
-#        $cmdType      set to RestorePreUserCmd or RestorePostUserCmd
-#
-# The following variable substitutions are made at run time for
-# $Conf{ArchivePreUserCmd} and $Conf{ArchivePostUserCmd}:
-#
-#        $client       client name being backed up
-#        $xferOK       1 if the archive succeeded, 0 if it didn't
-#        $host         Name of the archive host
-#        $user         user name from the hosts file
-#        $share        the first share name
-#        $XferMethod   value of $Conf{XferMethod} (eg: tar, rsync, smb)
-#        $HostList     list of hosts being archived
-#        $BackupList   list of backup numbers for the hosts being archived
-#        $archiveloc   location where the archive is sent to
-#        $parfile      amount of parity data being generated (percentage)
-#        $compression  compression program being used (eg: cat, gzip, bzip2)
-#        $compext      extension used for compression type (eg: raw, gz, bz2)
-#        $splitsize    size of the files that the archive creates
-#        $sshPath      value of $Conf{SshPath},
-#        $type         set to "archive"
-#        $cmdType      set to ArchivePreUserCmd or ArchivePostUserCmd
-#
-# Note: all Cmds are executed directly without a shell, so the prog name
-# needs to be a full path and you can't include shell syntax like
-# redirection and pipes; put that in a script if you need it.
-#
-$Conf{DumpPreUserCmd}     = undef;
-$Conf{DumpPostUserCmd}    = undef;
-$Conf{DumpPreShareCmd}    = undef;
-$Conf{DumpPostShareCmd}   = undef;
-$Conf{RestorePreUserCmd}  = undef;
-$Conf{RestorePostUserCmd} = undef;
-$Conf{ArchivePreUserCmd}  = undef;
-$Conf{ArchivePostUserCmd} = undef;
-
-#
-# Whether the exit status of each PreUserCmd and
-# PostUserCmd is checked.
-#
-# If set and the Dump/Restore/Archive Pre/Post UserCmd
-# returns a non-zero exit status then the dump/restore/archive
-# is aborted.  To maintain backward compatibility (where
-# the exit status in early versions was always ignored),
-# this flag defaults to 0.
-#
-# If this flag is set and the Dump/Restore/Archive PreUserCmd
-# fails then the matching Dump/Restore/Archive PostUserCmd is
-# not executed.  If DumpPreShareCmd returns a non-exit status,
-# then DumpPostShareCmd is not executed, but the DumpPostUserCmd
-# is still run (since DumpPreUserCmd must have previously
-# succeeded).
-#
-# An example of a DumpPreUserCmd that might fail is a script
-# that snapshots or dumps a database which fails because
-# of some database error.
-#
+<% if @full_period -%>
+$Conf{FullPeriod} = <%= @full_period %>;
+<% end -%>
+<% if @incr_period -%>
+$Conf{IncrPeriod} = <%= @incr_period %>;
+<% end -%>
+<% if @full_keep_cnt -%>
+$Conf{FullKeepCnt} = <%= @full_keep_cnt %>;
+<% end -%>
+<% if @full_age_max -%>
+$Conf{FullAgeMax}     = <%= @full_age_max %>;
+<% end -%>
+<% if @incr_keep_cnt -%>
+$Conf{IncrKeepCnt} = <%= @incr_keep_cnt %>;
+<% end -%>
+<% if @incr_age_max -%>
+$Conf{IncrAgeMax}     = <%= @incr_age_max %>;
+<% end -%>
+<% if @incr_fill -%>
+$Conf{IncrFill} = <%= @real_incr_fill %>;
+<% end -%>
+<% if @incr_levels.is_a?(Array) and  @incr_levels.count > 0 -%>
+$Conf{IncrLevels} = [<%= @incr_levels.join(', ') %>];
+<% end -%>
+<% if @partial_age_max -%>
+$Conf{PartialAgeMax} = <%= @partial_age_max %>;
+<% end -%>
+<% if @blackout_bad_ping_limit -%>
+$Conf{BlackoutBadPingLimit} = <%= @blackout_bad_ping_limit %>;
+<% end -%>
+<% if @blackout_good_cnt -%>
+$Conf{BlackoutGoodCnt}      = <%= @blackout_good_cnt %>;
+<% end -%>
+<% if @backup_files_only -%>
+<% if @backup_files_only.is_a?(Hash) -%>
+$Conf{BackupFilesOnly} = {
+<% @backup_files_only.each_pair do |key,value| -%>
+  '<%= key %>'  => <% if value.is_a?(Array) %>['<%= value.join("', '") %>']<% else %><%= value %><% end %>,
+<% end -%>
+};
+<% elsif @backup_files_only.is_a?(Array) -%>
+$Conf{BackupFilesOnly} = ['<%= @backup_files_only.join("', '") %>'];
+<% else -%>
+$Conf{BackupFilesOnly} = '<%= @backup_files_only %>';
+<% end -%>
+<% end -%>
+<% if @backup_files_exclude -%>
+<% if @backup_files_exclude.is_a?(Hash) -%>
+$Conf{BackupFilesExclude} = {
+<% @backup_files_exclude.each_pair do |key,value| -%>
+  '<%= key %>'  => <% if value.is_a?(Array) %>['<%= value.join("', '") %>']<% else %><%= value %><% end %>,
+<% end -%>
+};
+<% elsif @backup_files_exclude.is_a?(Array) -%>
+$Conf{BackupFilesExclude} = ['<%= @backup_files_exclude.join("', '") %>'];
+<% else -%>
+$Conf{BackupFilesExclude} = '<%= @backup_files_exclude %>';
+<% end -%>
+<% end -%>
+<% if @smb_share_name %>
+$Conf{SmbShareName} = '<%= @smb_share_name %>';
+<% end -%>
+<% if @smb_share_username -%>
+$Conf{SmbShareUserName} = '<%= @smb_share_username %>';
+<% end -%>
+<% if @smb_share_passwd -%>
+$Conf{SmbSharePasswd} = '<%= @smb_share_passwd %>';
+<% end -%>
+<% if @smb_client_full_cmd -%>
+$Conf{SmbClientFullCmd} = '<%= @smb_client_full_cmd %>';
+<% end -%>
+<% if @smb_client_incr_cmd -%>
+$Conf{SmbClientIncrCmd} = '<%= @smb_client_incr_cmd %>';
+<% end -%>
+<% if @smb_client_restore_cmd -%>
+$Conf{SmbClientRestoreCmd} = '<%= @smb_client_restore_cmd %>';
+<% end -%>
+<% if @tar_share_name -%>
+<% if @tar_share_name.is_a?(Array) -%>
+$Conf{TarShareName} = ['<%= @tar_share_name.join("', '") %>'];
+<% else -%>
+$Conf{TarShareName} = '<%= @tar_share_name %>';
+<% end -%>
+<% end -%>
+<% if @tar_client_cmd -%>
+$Conf{TarClientCmd} = '<%= @tar_client_cmd %>';
+<% elsif not @system_account.empty? -%>
+$Conf{TarClientCmd} = '$sshPath -q -x -n -l <%= @system_account %> $host'
+. ' env LC_ALL=C $tarPath -c -v -f - -C $shareName+'
+. ' --totals';
+<% end -%>
+<% if @tar_full_args -%>
+$Conf{TarFullArgs} = '<%= @tar_full_args %>';
+<% end -%>
+<% if @tar_incr_args -%>
+$Conf{TarIncrArgs} = '<%= @tar_incr_args %>';
+<% end -%>
+<% if @tar_client_restore_cmd -%>
+$Conf{TarClientRestoreCmd} = '<%= @tar_client_restore_cmd %>';
+<% elsif not @system_account.empty? -%>
+$Conf{TarClientRestoreCmd} = '$sshPath -q -x -l <%= @system_account %> $host'
+. ' env LC_ALL=C $tarPath -x -p --numeric-owner --same-owner'
+. ' -v -f - -C $shareName+';
+<% end -%>
+<% if @rsync_client_cmd -%>
+$Conf{RsyncClientCmd} = '<%= @rsync_client_cmd %>';
+<% elsif not @system_account.empty? %>
+$Conf{RsyncClientCmd} = '$sshPath -q -x -l <%= @system_account %> $host $rsyncPath $argList+';
+<% end -%>
+<% if @rsync_client_restore_cmd -%>
+$Conf{RsyncClientRestoreCmd} = '<%= @rsync_client_restore_cmd %>';
+<% elsif not @system_account.empty? -%>
+$Conf{RsyncClientRestoreCmd} = '$sshPath -q -x -l <%= @system_account %> $host $rsyncPath $argList+';
+<% end -%>
+<% if @rsync_share_name -%>
+<% if @rsync_share_name.is_a?(Array) -%>
+$Conf{RsyncShareName} = ['<%= @rsync_share_name.join("', '") %>'];
+<% else -%>
+$Conf{RsyncShareName} = '<%= @rsync_share_name %>'; 
+<% end -%>
+<% end -%>
+<% if @rsyncd_client_port -%>
+$Conf{RsyncdClientPort} = <%= @rsyncd_client_port %>;
+<% end -%>
+<% if @rsyncd_user_name -%>
+$Conf{RsyncdUserName} = '<%= @rsyncd_user_name %>';
+<% end -%>
+<% if @rsyncd_passwd -%>
+$Conf{RsyncdPasswd} = '<%= @rsyncd_passwd %>';
+<% end -%>
+<% if @rsyncd_auth_required -%>
+$Conf{RsyncdAuthRequired} = <%= @real_rsyncd_auth_required %>;
+<% end -%>
+<% if @rsync_csum_cache_verify_prob -%>
+$Conf{RsyncCsumCacheVerifyProb} = <%= @rsync_csum_cache_verify_prob %>;
+<% end -%>
+<% if @rsync_args.is_a?(Array) and @rsync_args.count > 0 -%>
+$Conf{RsyncArgs} = ['<%= @rsync_args.join("', '") %>'];
+<% end -%>
+<% if @rsync_restore_args.is_a?(Array) and @rsync_restore_args.count > 0 -%>
+$Conf{RsyncRestoreArgs} = ['<%= @rsync_restore_args.join("', '") %>'];
+<% end -%>
+<% if @dump_pre_user_cmd -%>
+$Conf{DumpPreUserCmd} = '<%= @dump_pre_user_cmd %>';
+<% end -%>
+<% if @dump_post_user_cmd -%>
+$Conf{DumpPostUserCmd}    = '<%= @dump_post_user_cmd %>';
+<% end -%>
+<% if @dump_pre_share_cmd -%>
+$Conf{DumpPreShareCmd}    = '<%= @dump_pre_share_cmd %>';
+<% end -%>
+<% if @dump_post_share_cmd -%>
+$Conf{DumpPostShareCmd}   = '<%= @dump_post_share_cmd %>';
+<% end -%>
+<% if @restore_pre_user_cmd -%>
+$Conf{RestorePreUserCmd}  = '<%= @restore_pre_user_cmd %>';
+<% end -%>
+<% if @restore_post_user_cmd -%>
+$Conf{RestorePostUserCmd} = '<%= @restore_post_user_cmd %>';
+<% end -%>
+<% if not @user_cmd_check_status -%>
 $Conf{UserCmdCheckStatus} = 0;
-
-#
-# Override the client's host name.  This allows multiple clients
-# to all refer to the same physical host.  This should only be
-# set in the per-PC config file and is only used by BackupPC at
-# the last moment prior to generating the command used to backup
-# that machine (ie: the value of $Conf{ClientNameAlias} is invisible
-# everywhere else in BackupPC).  The setting can be a host name or
-# IP address, eg:
-#
-#         $Conf{ClientNameAlias} = 'realHostName';
-#         $Conf{ClientNameAlias} = '192.1.1.15';
-#
-# will cause the relevant smb/tar/rsync backup/restore commands to be
-# directed to realHostName, not the client name.
-#
-# Note: this setting doesn't work for hosts with DHCP set to 1.
-#
-$Conf{ClientNameAlias} = undef;
-
-###########################################################################
-# Email reminders, status and messages
-# (can be overridden in the per-PC config.pl)
-###########################################################################
-#
-# Full path to the sendmail command.  Security caution: normal users
-# should not allowed to write to this file or directory.
-#
-$Conf{SendmailPath} = '/usr/sbin/sendmail';
-
-#
-# Minimum period between consecutive emails to a single user.
-# This tries to keep annoying email to users to a reasonable
-# level.  Email checks are done nightly, so this number is effectively
-# rounded up (ie: 2.5 means a user will never receive email more
-# than once every 3 days).
-#
-$Conf{EMailNotifyMinDays} = 2.5;
-
-#
-# Name to use as the "from" name for email.  Depending upon your mail
-# handler this is either a plain name (eg: "admin") or a fully-qualified
-# name (eg: "admin@mydomain.com").
-#
-$Conf{EMailFromUserName} = 'backuppc';
-
-#
-# Destination address to an administrative user who will receive a
-# nightly email with warnings and errors.  If there are no warnings
-# or errors then no email will be sent.  Depending upon your mail
-# handler this is either a plain name (eg: "admin") or a fully-qualified
-# name (eg: "admin@mydomain.com").
-#
-$Conf{EMailAdminUserName} = 'backuppc';
-
-#
-# Destination domain name for email sent to users.  By default
-# this is empty, meaning email is sent to plain, unqualified
-# addresses.  Otherwise, set it to the destintation domain, eg:
-#
-#    $Cong{EMailUserDestDomain} = '@mydomain.com';
-#
-# With this setting user email will be set to 'user@mydomain.com'.
-#
-$Conf{EMailUserDestDomain} = '';
-
-#
-# This subject and message is sent to a user if their PC has never been
-# backed up.
-#
-# These values are language-dependent.  The default versions can be
-# found in the language file (eg: lib/BackupPC/Lang/en.pm).  If you
-# need to change the message, copy it here and edit it, eg:
-#
-#   $Conf{EMailNoBackupEverMesg} = <<'EOF';
-#   To: $user$domain
-#   cc:
-#   Subject: $subj
-#   
-#   Dear $userName,
-#   
-#   This is a site-specific email message.
-#   EOF
-#
-$Conf{EMailNoBackupEverSubj} = undef;
-$Conf{EMailNoBackupEverMesg} = undef;
-
-#
-# How old the most recent backup has to be before notifying user.
-# When there have been no backups in this number of days the user
-# is sent an email.
-#
-$Conf{EMailNotifyOldBackupDays} = 7.0;
-
-#
-# This subject and message is sent to a user if their PC has not recently
-# been backed up (ie: more than $Conf{EMailNotifyOldBackupDays} days ago).
-#
-# These values are language-dependent.  The default versions can be
-# found in the language file (eg: lib/BackupPC/Lang/en.pm).  If you
-# need to change the message, copy it here and edit it, eg:
-#
-#   $Conf{EMailNoBackupRecentMesg} = <<'EOF';
-#   To: $user$domain
-#   cc:
-#   Subject: $subj
-#   
-#   Dear $userName,
-#   
-#   This is a site-specific email message.
-#   EOF
-#
-$Conf{EMailNoBackupRecentSubj} = undef;
-$Conf{EMailNoBackupRecentMesg} = undef;
-
-#
-# How old the most recent backup of Outlook files has to be before
-# notifying user.
-#
-$Conf{EMailNotifyOldOutlookDays} = 5.0;
-
-#
-# This subject and message is sent to a user if their Outlook files have
-# not recently been backed up (ie: more than $Conf{EMailNotifyOldOutlookDays}
-# days ago).
-#
-# These values are language-dependent.  The default versions can be
-# found in the language file (eg: lib/BackupPC/Lang/en.pm).  If you
-# need to change the message, copy it here and edit it, eg:
-#
-#   $Conf{EMailOutlookBackupMesg} = <<'EOF';
-#   To: $user$domain
-#   cc:
-#   Subject: $subj
-#   
-#   Dear $userName,
-#   
-#   This is a site-specific email message.
-#   EOF
-#
-$Conf{EMailOutlookBackupSubj} = undef;
-$Conf{EMailOutlookBackupMesg} = undef;
-
-#
-# Additional email headers.  This sets to charset to
-# utf8.
-#
-$Conf{EMailHeaders} = <<EOF;
-MIME-Version: 1.0
-Content-Type: text/plain; charset="utf-8"
-EOF
-
+<% end -%>
+<% if @email_notify_min_days -%>
+$Conf{EMailNotifyMinDays} = <%= @email_notify_min_days %>;
+<% end -%>
+<% if @email_from_user_name -%>
+$Conf{EMailFromUserName} = '<%= @email_from_user_name %>';
+<% end -%>
+<% if @email_admin_user_name -%>
+$Conf{EMailAdminUserName} = '<%= @email_admin_user_name %>';
+<% end -%>
+<% if @email_notify_old_backup_days -%>
+$Conf{EMailNotifyOldBackupDays} = <%= @email_notify_old_backup_days %>;
+<% end -%>
diff --git a/tests/init.pp b/tests/init.pp
index d5a0d1d..b412a79 100644
--- a/tests/init.pp
+++ b/tests/init.pp
@@ -1 +1,43 @@
-include backuppc2
+class { 'backuppc::server':
+  wakeup_schedule              => [1, 2, 3, 4, 5, 21, 22, 23],
+  max_backups                  => 2,
+  max_user_backups             => 1,
+  blackout_zero_files_is_fatal => false,
+  backuppc_password            => 'test1234',
+  max_pending_cmds             => 10,
+  max_backup_pc_nightly_jobs   => 3,
+  backup_pc_nightly_period     => 2,
+  max_old_log_files            => 7,
+  df_max_usage_pct             => 85,
+  trash_clean_sleep_sec        => 500,
+  dhcp_address_ranges          => [],
+  full_period                  => '5.97',
+  full_keep_cnt                => 2,
+  full_age_max                 => 30,
+  incr_period                  => '1.37',
+  incr_keep_cnt                => 5,
+  incr_age_max                 => 15,
+  incr_levels                  => [1,2],
+  incr_fill                    => true,
+  partial_age_max              => 2,
+  restore_info_keep_cnt        => 20,
+  archive_info_keep_cnt        => 20,
+  blackout_good_cnt            => 5,
+  blackout_periods             => [
+    {
+      hourBegin =>  7.0,
+      hourEnd   => 19.5,
+      weekDays  => [1, 2, 3, 4, 5],
+    },
+    {
+      hourBegin => 23,
+      hourEnd   =>  5,
+      weekDays  => [5, 6],
+    },
+  ],
+  email_notify_min_days        => 1.5,
+  email_from_user_name         => 'bpcreport',
+  email_admin_user_name        => 'backuppc-alt',
+  email_notify_old_backup_days => 7,
+  apache_allow_from            => '127.0.0.1',
+}