| Index: modules/updateserver/manifests/init.pp | 
| =================================================================== | 
| --- a/modules/updateserver/manifests/init.pp | 
| +++ b/modules/updateserver/manifests/init.pp | 
| @@ -21,17 +21,28 @@ | 
| require => Package['nginx'] | 
| } | 
|  | 
| -  file {'/var/www/update': | 
| +  $update_dir = '/var/www/update' | 
| + | 
| +  file {$update_dir: | 
| ensure => directory, | 
| mode => 0755 | 
| } | 
|  | 
| -  file {'/var/www/update/adblockplusie': | 
| +  $update_manifest_dirs = ["${update_dir}/gecko", | 
| +                           "${update_dir}/adblockplusandroid", | 
| +                           "${update_dir}/adblockplussafari"] | 
| + | 
| +  file {$update_manifest_dirs: | 
| ensure => directory, | 
| mode => 0755 | 
| } | 
|  | 
| -  file {'/var/www/update/adblockplusie/update.json': | 
| +  file {"${update_dir}/adblockplusie": | 
| +    ensure => directory, | 
| +    mode => 0755 | 
| +  } | 
| + | 
| +  file {"${update_dir}/adblockplusie/update.json": | 
| ensure => file, | 
| source => 'puppet:///modules/updateserver/adblockplusie/update.json', | 
| mode => 0644 | 
| @@ -44,4 +55,67 @@ | 
| private_key => $private_key, | 
| log => 'access_log_update' | 
| } | 
| + | 
| +  class {'sitescripts': | 
| +    sitescriptsini_source => 'puppet:///modules/updateserver/sitescripts' | 
| +  } | 
| + | 
| +  $base_dir = '/var/lib/adblockplus' | 
| + | 
| +  file {$base_dir: | 
| +    ensure => directory, | 
| +    mode => 0755 | 
| +  } | 
| + | 
| +  $safari_certificate_path = "${base_dir}/adblockplussafari.pem" | 
| + | 
| +  file {$safari_certificate_path: | 
| +    source => 'puppet:///modules/private/adblockplussafari.pem' | 
| +  } | 
| + | 
| +  $repositories_to_sync = ['downloads', 'adblockplus', 'adblockplusandroid', | 
| +                           'adblockpluschrome', 'elemhidehelper', 'abpwatcher', | 
| +                           'abpcustomization', 'urlfixer'] | 
| + | 
| +  define fetch_repository() { | 
| +    $repository_path = "${updateserver::base_dir}/${title}" | 
| +    exec {"fetch_repository_${title}": | 
| +      command => "hg clone -U https://hg.adblockplus.org/${title} ${repository_path}", | 
| +      path => '/usr/local/bin:/usr/bin:/bin', | 
| +      timeout => 0, | 
| +      onlyif => "test ! -d ${repository_path}", | 
| +      require => [Package['mercurial'], File[$updateserver::base_dir]] | 
| +    } | 
| +  } | 
| + | 
| +  fetch_repository {$repositories_to_sync: } | 
| + | 
| +  $update_update_manifests_script = '/usr/local/bin/update_update_manifests' | 
| + | 
| +  file {$update_update_manifests_script: | 
| +    mode => '0755', | 
| +    content => template('updateserver/update_update_manifests.erb') | 
| +  } | 
| + | 
| +  $update_update_manifests_dependencies = ['python-m2crypto', 'python-jinja2'] | 
| + | 
| +  package {$update_update_manifests_dependencies:} | 
| + | 
| +  exec {'update_update_manifests': | 
| +    command => $update_update_manifests_script, | 
| +    timeout => 0, | 
| +    require => [Exec['fetch_sitescripts'], | 
| +                Fetch_repository[$repositories_to_sync], | 
| +                File[$update_update_manifests_script], | 
| +                File[$update_manifest_dirs], File[$safari_certificate_path], | 
| +                Package[$update_update_manifests_dependencies]] | 
| +  } | 
| + | 
| +  cron {'update_update_manifests': | 
| +    ensure => present, | 
| +    environment => ['MAILTO=admins@adblockplus.org'], | 
| +    command => $update_update_manifests_script, | 
| +    minute => '*/10', | 
| +    require => Exec['update_update_manifests'] | 
| +  } | 
| } | 
|  |