From 62bd7b940f3e2b61b48df6a76678efe513360559 Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Mon, 6 May 2013 01:25:46 -0700 Subject: [PATCH] New remirror-project.pl utility script --- toolbox/remirror-project.pl | 49 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100755 toolbox/remirror-project.pl diff --git a/toolbox/remirror-project.pl b/toolbox/remirror-project.pl new file mode 100755 index 0000000..9823376 --- /dev/null +++ b/toolbox/remirror-project.pl @@ -0,0 +1,49 @@ +#!/usr/bin/perl + +# Initiate a re-mirror of a project + +use strict; +use warnings; +use IO::Socket; +use lib @basedir@; + +use Girocco::Config; +use Girocco::Project; + +sub mydie +{ + print STDERR "@_\n"; + exit(255); +} + +undef(*CORE::GLOBAL::die); +*CORE::GLOBAL::die = \&mydie; + +my $project = shift @ARGV || die "Please give project name on command line."; + +my $p = Girocco::Project->load($project) || die "Project '$project' not found!"; + +if (!$p->{mirror}) { + die "Project '$project' is a push project, not a mirror project." +} + +if ($p->{clone_in_progress} && !$p->{clone_failed}) { + die "Project '$project' already has a clone underway at this moment." +} + +unlink($p->_clonefail_path); +unlink($p->_clonelog_path); +my $cp = $p->_clonep_path; +open X, '>'.$cp or die "failed to create $cp: $!"; +close X; + +my $sock = IO::Socket::UNIX->new($Girocco::Config::chroot.'/etc/taskd.socket') or die "cannot connect to taskd.socket: $!"; +$sock->print("clone ".$p->{name}."\n"); +# Just ignore reply, we are going to succeed anyway and the I/O +# would apparently get quite hairy. +$sock->flush(); +sleep 2; # *cough* +$sock->close(); + +print "Project '$project' remirror initiated.\n"; +exit 0 -- 2.11.4.GIT