2012-03-20 16:43:45 +05:30
|
|
|
#!/usr/bin/perl
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
2012-04-06 20:29:05 +05:30
|
|
|
use lib $ENV{GL_LIBDIR};
|
2012-03-20 23:00:29 +05:30
|
|
|
use Gitolite::Easy;
|
2012-03-20 16:43:45 +05:30
|
|
|
|
|
|
|
=for usage
|
2012-03-27 19:28:56 +05:30
|
|
|
Usage: gitolite writable <reponame>|@all on|off
|
2012-03-20 16:43:45 +05:30
|
|
|
|
2012-03-30 15:14:25 +05:30
|
|
|
Disable/re-enable pushes to all repos or named repo. Useful to run
|
|
|
|
non-git-aware backups and so on.
|
|
|
|
|
2012-03-20 16:43:45 +05:30
|
|
|
'on' enables, 'off' disables, writes (pushes) to the named repo or all repos.
|
|
|
|
|
|
|
|
With 'off', any subsequent text is taken to be the message to be shown to
|
|
|
|
users when their pushes get rejected. If it is not supplied, it will take it
|
|
|
|
from STDIN; this allows longer messages.
|
|
|
|
=cut
|
|
|
|
|
|
|
|
usage() if not @ARGV or @ARGV < 2 or $ARGV[0] eq '-h';
|
2012-03-27 19:28:56 +05:30
|
|
|
usage() if $ARGV[1] ne 'on' and $ARGV[1] ne 'off';
|
2012-03-20 16:43:45 +05:30
|
|
|
|
|
|
|
my $repo = shift;
|
2012-03-27 19:28:56 +05:30
|
|
|
my $on = ( shift eq 'on' );
|
2012-03-20 16:43:45 +05:30
|
|
|
|
2012-03-20 23:00:29 +05:30
|
|
|
if ( $repo eq '@all' ) {
|
2012-04-16 17:14:03 +05:30
|
|
|
_die "you are not authorized" if $ENV{GL_USER} and not is_admin();
|
2012-03-20 23:00:29 +05:30
|
|
|
} else {
|
2012-04-16 17:14:03 +05:30
|
|
|
_die "you are not authorized" if $ENV{GL_USER} and not owns($repo);
|
2012-03-20 23:00:29 +05:30
|
|
|
}
|
|
|
|
|
2012-03-20 16:43:45 +05:30
|
|
|
my $msg = join( " ", @ARGV );
|
|
|
|
# try STDIN only if no msg found in args *and* it's an 'off' command
|
|
|
|
if ( not $msg and not $on ) {
|
|
|
|
say2 "...please type the message to be shown to users:";
|
|
|
|
$msg = join( "", <> );
|
|
|
|
}
|
|
|
|
|
|
|
|
my $sf = ".gitolite.down";
|
2012-03-20 23:00:29 +05:30
|
|
|
my $rb = $ENV{GL_REPO_BASE};
|
2012-03-20 16:43:45 +05:30
|
|
|
|
|
|
|
if ( $repo eq '@all' ) {
|
|
|
|
target( $ENV{HOME} );
|
|
|
|
} else {
|
|
|
|
target("$rb/$repo.git");
|
|
|
|
}
|
|
|
|
|
|
|
|
sub target {
|
|
|
|
my $repodir = shift;
|
|
|
|
if ($on) {
|
|
|
|
unlink "$repodir/$sf";
|
|
|
|
} else {
|
|
|
|
_print( "$repodir/$sf", $msg );
|
|
|
|
}
|
|
|
|
}
|