/usr/share/perl5/IkiWiki/Plugin/gitpush.pm is in ikiwiki-hosting-common 0.20170622ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | #!/usr/bin/perl
package IkiWiki::Plugin::gitpush;
use warnings;
use strict;
use IkiWiki 3.00;
sub import {
hook(type => "getsetup", id => "gitpush", call => \&getsetup);
hook(type => "refresh", id => "gitpush", call => \&refresh);
hook(type => "savestate", id => "gitpush", call => \&savestate);
}
sub getsetup () {
my $keyurl=length $config{cgiurl} ? IkiWiki::cgiurl(do => "sshkey") : "";
return
plugin => {
safe => 1,
rebuild => 0,
section => "core",
},
git_push_to => {
type => "string",
example => [],
description => "git repository urls that changes are pushed to",
htmldescription => "git repository urls that changes are pushed to (using <a href=\"$keyurl\">this ssh key</a>)",
safe => 1,
rebuild => 0,
},
}
# Pushing is deferred to the end to avoid running at the same time
# as site building.
my $need_push;
sub refresh {
$need_push=1;
}
sub savestate {
if ($need_push && $config{rcs} eq 'git' &&
ref($config{git_push_to}) eq 'ARRAY' &&
scalar @{$config{git_push_to}}) {
# daemonise
defined(my $pid = fork) or error("Can't fork: $!");
return if $pid;
chdir '/';
open STDIN, '/dev/null';
open STDOUT, '>/dev/null';
POSIX::setsid() or error("Can't start a new session: $!");
open STDERR, '>&STDOUT' or error("Can't dup stdout: $!");
# Don't need to keep a lock on the wiki as a daemon.
IkiWiki::unlockwiki();
# Low priority job.
eval q{use POSIX; POSIX::nice(10)};
# Ensure we have a ssh key generated to use.
IkiWiki::Plugin::ikiwikihosting::get_ssh_public_key();
# Avoid ssh host key checking prompts.
$ENV{GIT_SSH}="iki-ssh-unsafe";
chdir "$ENV{HOME}/source.git/" || die $!;
foreach my $url (@{$config{git_push_to}}) {
next unless length $url;
system('git', 'push', '--quiet', '--mirror', $url);
}
exit 0;
}
}
1
|