]> sipb.mit.edu Git - ikiwiki.git/blob - IkiWiki/Plugin/rsync.pm
doc update, add --exclude ikiwiki.cgi to examples
[ikiwiki.git] / IkiWiki / Plugin / rsync.pm
1 #!/usr/bin/perl
2 package IkiWiki::Plugin::rsync;
3
4 use warnings;
5 use strict;
6 use IkiWiki 3.00;
7
8 sub import {
9         hook(type => "getsetup", id => "rsync", call => \&getsetup);
10         hook(type => "postrefresh", id => "rsync", call => \&postrefresh);
11 }
12
13 sub getsetup () {
14         return
15                 plugin => {
16                         safe => 0,
17                         rebuild => 0,
18                 },
19                 rsync_command => {
20                         type => "string",
21                         example => "rsync -qa --delete . user\@host:/path/to/docroot/ --exclude ikiwiki.cgi",
22                         description => "command to run to sync updated pages",
23                         safe => 0,
24                         rebuild => 0,
25                 },
26 }
27
28 sub postrefresh () {
29         if (defined $config{rsync_command}) {
30                 chdir($config{destdir}) || error("chdir: $!");
31                 system $config{rsync_command};
32                 if ($? == -1) {
33                         warn(sprintf(gettext("failed to execute rsync_command: %s"), $!))."\n";
34                 }
35                 elsif ($? != 0) {
36                         warn(sprintf(gettext("rsync_command exited %d"), $? >> 8))."\n";
37                 }
38         }
39 }
40
41 1