add paths to plugin files in copyright
[ikiwiki.git] / IkiWiki / Plugin / rsync.pm
blobe38801e4a110b0b9e4790935de65f08bce30441e
1 #!/usr/bin/perl
2 package IkiWiki::Plugin::rsync;
4 use warnings;
5 use strict;
6 use IkiWiki 3.00;
8 sub import {
9 hook(type => "getsetup", id => "rsync", call => \&getsetup);
10 hook(type => "change", id => "rsync", call => \&postrefresh);
11 hook(type => "delete", id => "rsync", call => \&postrefresh);
14 sub getsetup () {
15 return
16 plugin => {
17 safe => 0,
18 rebuild => 0,
20 rsync_command => {
21 type => "string",
22 example => "rsync -qa --delete . user\@host:/path/to/docroot/",
23 description => "command to run to sync updated pages",
24 safe => 0,
25 rebuild => 0,
29 my $ran=0;
31 sub postrefresh () {
32 if (defined $config{rsync_command} && ! $ran) {
33 $ran=1;
34 chdir($config{destdir}) || error("chdir: $!");
35 system $config{rsync_command};
36 if ($? == -1) {
37 warn(sprintf(gettext("failed to execute rsync_command: %s"), $!))."\n";
39 elsif ($? != 0) {
40 warn(sprintf(gettext("rsync_command exited %d"), $? >> 8))."\n";