summaryrefslogtreecommitdiff
path: root/pinyadmin/sbin/rmrepo
blob: acc9c56cbb9432531b4a4284de1080568f0184b7 (plain)
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
#!/usr/bin/perl

use strict;
use warnings;

use Piny;

my $env = Piny::Environment->instance( );

my $config = Piny::Config->new( );
my $dest = $config->piny_newuseremail;

foreach my $reponame ( @ARGV ) {

  my $repo = Piny::Repo->new( $reponame );

  if ( $env->user->uid != 0 and $repo->owner->uid != $env->user->uid ) {
    print STDERR "You are not the owner of $reponame!\n";
    exit 1;
  };

  unless( open( MAIL, "|/usr/lib/sendmail -t" ) ) {
    die "Couldn't execute sendmail: $!\n";
  };
  print MAIL <<END;
  To: $dest
  Subject: Removing piny repo $reponame
  Content-type: text/plain; charset=us-ascii

  The piny repo ``$reponame'' has been removed.
  END
  close( MAIL );

  $repo->destroy;

};