diff options
author | Joe Rayhawk <jrayhawk@richardiv.omgwallhack.org> | 2010-10-30 07:31:35 -0700 |
---|---|---|
committer | Joe Rayhawk <jrayhawk@richardiv.omgwallhack.org> | 2010-10-30 07:31:35 -0700 |
commit | c952a7e6d5e66e2ecd653bb5c177609b59619808 (patch) | |
tree | d2be5d0dee505ae00c4b85a5f4129efc2456d5f6 /pinyadmin | |
parent | d03e1eb495c79c19dc70bbe8eab81eadce98210a (diff) | |
parent | 79c284badd015f88d8fd42d941e30bca70dd4eb9 (diff) | |
download | piny-code-c952a7e6d5e66e2ecd653bb5c177609b59619808.tar.gz piny-code-c952a7e6d5e66e2ecd653bb5c177609b59619808.zip |
Merge branch 'master' of piny.be:/srv/git/piny-code
Diffstat (limited to 'pinyadmin')
36 files changed, 570 insertions, 0 deletions
diff --git a/pinyadmin/Makefile b/pinyadmin/Makefile new file mode 100644 index 0000000..64ac713 --- /dev/null +++ b/pinyadmin/Makefile @@ -0,0 +1,12 @@ +build: + mkdir -p man + for f in doc/*.latex; do latex2man $$f man/$$(basename $$f .latex).man; done + ln -s newuser.man man/createuser.man + +install: + install -o root -g root -m 755 -d $(DESTDIR)/usr/bin $(DESTDIR)/usr/sbin + install -o root -g root -m 755 bin/* $(DESTDIR)/usr/bin + install -o root -g root -m 755 sbin/* $(DESTDIR)/usr/sbin + +clean: + rm -rf man diff --git a/pinyadmin/bin/addaccess b/pinyadmin/bin/addaccess new file mode 100755 index 0000000..849119d --- /dev/null +++ b/pinyadmin/bin/addaccess @@ -0,0 +1,2 @@ +#!/bin/sh +exec /usr/bin/sudo /usr/sbin/addaccess "$@" diff --git a/pinyadmin/bin/appendkeys b/pinyadmin/bin/appendkeys new file mode 100755 index 0000000..a4b7d98 --- /dev/null +++ b/pinyadmin/bin/appendkeys @@ -0,0 +1,5 @@ +#!/bin/sh + +/bin/mkdir -p ~/.ssh +/bin/echo Please input authorized keys to be appended. ctrl-d to finish, ctrl-c to abort current line. +/bin/cat >> ~/.ssh/authorized_keys diff --git a/pinyadmin/bin/createuser b/pinyadmin/bin/createuser new file mode 120000 index 0000000..e9d7937 --- /dev/null +++ b/pinyadmin/bin/createuser @@ -0,0 +1 @@ +newuser
\ No newline at end of file diff --git a/pinyadmin/bin/lsaccess b/pinyadmin/bin/lsaccess new file mode 100755 index 0000000..ce41fc4 --- /dev/null +++ b/pinyadmin/bin/lsaccess @@ -0,0 +1,30 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Piny; + +my $env = Piny::Environment->instance( ); + +my ( $reponame ) = @ARGV; + +if ( defined $reponame ) { + + my $repo = Piny::Repo->new( $reponame ); + + foreach my $user ( Piny::User->all_users( ) ) { + if ( $repo->has_access( $user ) ) { + print $user->name . "\n"; + }; + }; + +} else { + + foreach my $repo ( Piny::Repo->all_repos( ) ) { + if ( $repo->has_access( $env->user ) ) { + print $repo->name . "\n"; + }; + }; + +}; diff --git a/pinyadmin/bin/lsrepo b/pinyadmin/bin/lsrepo new file mode 100755 index 0000000..2d88eb5 --- /dev/null +++ b/pinyadmin/bin/lsrepo @@ -0,0 +1,10 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Piny; + +foreach my $repo ( Piny::Repo->all_repos( ) ) { + print $repo->name . "\n"; +}; diff --git a/pinyadmin/bin/newrepo b/pinyadmin/bin/newrepo new file mode 100755 index 0000000..025e0cf --- /dev/null +++ b/pinyadmin/bin/newrepo @@ -0,0 +1,2 @@ +#!/bin/sh +exec /usr/bin/sudo /usr/sbin/newrepo "$@" diff --git a/pinyadmin/bin/newuser b/pinyadmin/bin/newuser new file mode 100755 index 0000000..1f73ed6 --- /dev/null +++ b/pinyadmin/bin/newuser @@ -0,0 +1,2 @@ +#!/bin/sh +exec /usr/bin/sudo /usr/sbin/newuser diff --git a/pinyadmin/bin/pinyconfig b/pinyadmin/bin/pinyconfig new file mode 100755 index 0000000..4e54f76 --- /dev/null +++ b/pinyadmin/bin/pinyconfig @@ -0,0 +1,2 @@ +#!/bin/sh +exec /usr/bin/sudo /usr/sbin/pinyconfig "$@" diff --git a/pinyadmin/bin/pinyshell b/pinyadmin/bin/pinyshell new file mode 100755 index 0000000..0db88a8 --- /dev/null +++ b/pinyadmin/bin/pinyshell @@ -0,0 +1,5 @@ +#!/bin/sh +cd /srv/rbin +export PATH=/srv/rbin + +exec /bin/rbash "$@" diff --git a/pinyadmin/bin/readkeys b/pinyadmin/bin/readkeys new file mode 100755 index 0000000..745bd8d --- /dev/null +++ b/pinyadmin/bin/readkeys @@ -0,0 +1,3 @@ +#!/bin/sh + +/bin/cat ~/.ssh/authorized_keys diff --git a/pinyadmin/bin/rmaccess b/pinyadmin/bin/rmaccess new file mode 100755 index 0000000..665052c --- /dev/null +++ b/pinyadmin/bin/rmaccess @@ -0,0 +1,2 @@ +#!/bin/sh +exec /usr/bin/sudo /usr/sbin/rmaccess "$@" diff --git a/pinyadmin/bin/rmrepo b/pinyadmin/bin/rmrepo new file mode 100755 index 0000000..e0e8085 --- /dev/null +++ b/pinyadmin/bin/rmrepo @@ -0,0 +1,2 @@ +#!/bin/sh +exec /usr/bin/sudo /usr/sbin/rmrepo "$@" diff --git a/pinyadmin/bin/writekeys b/pinyadmin/bin/writekeys new file mode 100755 index 0000000..61a7760 --- /dev/null +++ b/pinyadmin/bin/writekeys @@ -0,0 +1,5 @@ +#!/bin/sh + +/bin/mkdir -p ~/.ssh +/bin/echo Please input all authorized keys. ctrl-d to finish, ctrl-c to abort. +/usr/bin/sponge ~/.ssh/authorized_keys diff --git a/pinyadmin/debian/changelog b/pinyadmin/debian/changelog new file mode 100644 index 0000000..e11d900 --- /dev/null +++ b/pinyadmin/debian/changelog @@ -0,0 +1,48 @@ +pinyadmin (0.8) unstable; urgency=low + + * New config tweakable stuff. + + -- Julian Blake Kongslie <jblake@omgwallhack.org> Mon, 11 Oct 2010 21:56:04 -0700 + +pinyadmin (0.7) unstable; urgency=low + + * Creating ssh key management utilities. + + -- Joe Rayhawk <jrayhawk@omgwallhack.org> Fri, 03 Sep 2010 01:40:01 -0700 + +pinyadmin (0.6) unstable; urgency=low + + * Revised newrepo to use libpiny. + + -- Julian Blake Kongslie <jblake@omgwallhack.org> Wed, 07 Jul 2010 15:44:31 -0700 + +pinyadmin (0.5) unstable; urgency=low + + * Listing repos and repo access rights. + + -- Julian Blake Kongslie <jblake@omgwallhack.org> Tue, 29 Jun 2010 22:32:30 -0700 + +pinyadmin (0.4) unstable; urgency=low + + * Minor typo in manpage. + + -- Julian Blake Kongslie <jblake@omgwallhack.org> Sun, 18 Apr 2010 13:51:13 -0700 + +pinyadmin (0.3) unstable; urgency=low + + * A few more manpages. + + -- Julian Blake Kongslie <jblake@omgwallhack.org> Sun, 18 Apr 2010 13:19:34 -0700 + +pinyadmin (0.2) unstable; urgency=low + + * Switch to native packaging. + * Add manpages. + + -- Julian Blake Kongslie <jblake@omgwallhack.org> Sun, 18 Apr 2010 13:01:32 -0700 + +pinyadmin (0.1-1) unstable; urgency=low + + * Initial release. + + -- Julian Blake Kongslie <jblake@omgwallhack.org> Thu, 18 Mar 2010 13:55:40 -0700 diff --git a/pinyadmin/debian/compat b/pinyadmin/debian/compat new file mode 100644 index 0000000..7f8f011 --- /dev/null +++ b/pinyadmin/debian/compat @@ -0,0 +1 @@ +7 diff --git a/pinyadmin/debian/control b/pinyadmin/debian/control new file mode 100644 index 0000000..e8c2d70 --- /dev/null +++ b/pinyadmin/debian/control @@ -0,0 +1,13 @@ +Source: pinyadmin +Maintainer: Julian Blake Kongslie <jblake@omgwallhack.org> +Section: admin +Build-depends: debhelper (>= 7), texlive-extra-utils +Priority: extra +Standards-version: 3.8.4 + +Package: pinyadmin +Architecture: all +Depends: ${perl:Depends}, ${misc:Depends}, libpiny-perl (>= 0.14), moreutils +Description: Administrative programs for piny + The command-line programs for day-to-day administrative tasks in the Piny + infrastructure. diff --git a/pinyadmin/debian/copyright b/pinyadmin/debian/copyright new file mode 100644 index 0000000..9d12aab --- /dev/null +++ b/pinyadmin/debian/copyright @@ -0,0 +1,3 @@ +Copyright © 2010 Joe Rayhawk <jrayhawk@omgwallhack.org> +Copyright © 2010 Julian Blake Kongslie <jblake@omgwallhack.org> +Licensed under the BSD 3-clause license. diff --git a/pinyadmin/debian/pinyadmin.manpages b/pinyadmin/debian/pinyadmin.manpages new file mode 100644 index 0000000..85c5e00 --- /dev/null +++ b/pinyadmin/debian/pinyadmin.manpages @@ -0,0 +1 @@ +man/* diff --git a/pinyadmin/debian/rules b/pinyadmin/debian/rules new file mode 100755 index 0000000..2d33f6a --- /dev/null +++ b/pinyadmin/debian/rules @@ -0,0 +1,4 @@ +#!/usr/bin/make -f + +%: + dh $@ diff --git a/pinyadmin/debian/source/format b/pinyadmin/debian/source/format new file mode 100644 index 0000000..89ae9db --- /dev/null +++ b/pinyadmin/debian/source/format @@ -0,0 +1 @@ +3.0 (native) diff --git a/pinyadmin/doc/addaccess.latex b/pinyadmin/doc/addaccess.latex new file mode 100644 index 0000000..a8c29f9 --- /dev/null +++ b/pinyadmin/doc/addaccess.latex @@ -0,0 +1,17 @@ +\usepackage{latex2man} + +\begin{Name}{1piny}{addaccess}{Piny Team}{Piny}{addaccess} + +\Prog{addaccess} - allow access to a repository + +\section{Synopsis} + +\Prog{addaccess} \Arg{reponame} \Arg{username} \Dots + +\section{Description} + +The \Prog{addaccess} command grants users write access to a repository. +It may only be run by the owner of the repository. + +For each \Arg{username} passed on the command line, \Prog{addaccess} will grant write permission to the repository. +Other users are not affected. diff --git a/pinyadmin/doc/newrepo.latex b/pinyadmin/doc/newrepo.latex new file mode 100644 index 0000000..a708b6c --- /dev/null +++ b/pinyadmin/doc/newrepo.latex @@ -0,0 +1,15 @@ +\usepackage{latex2man} + +\begin{Name}{1piny}{newrepo}{Piny Team}{Piny}{newrepo} + +\Prog{newrepo} - create a new repository + +\section{Synopsis} + +\Prog{newrepo} \Arg{reponame} + +\section{Description} + +The \Prog{newrepo} command creates a new repository with the given name. +The current user is set as the owner of the new repository. +No other users are given access to the new repository. diff --git a/pinyadmin/doc/newuser.latex b/pinyadmin/doc/newuser.latex new file mode 100644 index 0000000..721d468 --- /dev/null +++ b/pinyadmin/doc/newuser.latex @@ -0,0 +1,16 @@ +\usepackage{latex2man} + +\begin{Name}{8piny}{newuser}{Piny Team}{Piny}{createuser} + +\Prog{newuser} - add a piny user + +\section{Synopsis} + +\Prog{newuser} + +\Prog{createuser} + +\section{Description} + +The \Prog{newuser} program is an interactive script which walks the user through the process of creating a new Piny account. +Normally it is set as the shell of a passwordless user such as "newuser" or "createuser", so that users can create accounts without any assistance from a sysadmin. diff --git a/pinyadmin/doc/pinyconfig.latex b/pinyadmin/doc/pinyconfig.latex new file mode 100644 index 0000000..4908dbb --- /dev/null +++ b/pinyadmin/doc/pinyconfig.latex @@ -0,0 +1,17 @@ +\usepackage{latex2man} + +\begin{Name}{1piny}{pinyconfig}{Piny Team}{Piny}{pinyconfig} + +\Prog{pinyconfig} - change tweakables on a repo + +\section{Synopsis} + +\Prog{pinyconfig} \Arg{reponame} \Arg{tweakable} \oArg{value} + +\section{Description} + +The \Prog{pinyconfig} command reads and writes tweakables for a repo. + +When run, it prints the value of the tweakable for the repo named. +If a value was passed, it sets the value of the tweakable to that value +before printing it. diff --git a/pinyadmin/doc/pinyshell.latex b/pinyadmin/doc/pinyshell.latex new file mode 100644 index 0000000..481ddf3 --- /dev/null +++ b/pinyadmin/doc/pinyshell.latex @@ -0,0 +1,19 @@ +\usepackage{latex2man} + +\begin{Name}{8piny}{pinyshell}{Piny Team}{Piny}{pinyshell} + +\Prog{pinyshell} - a restricted shell + +\section{Synopsis} + +\Prog{pinyshell} + +\section{Description} + +\Prog{pinyshell} is just another way to invoke \Cmd{1}{rbash}; the separate name is used for accounting purposes within the piny infrastructure. + +Users which should be managed by the Piny infrastructure should have \Prog{pinyshell} as their shell. + +\section{See Also} + +\Cmd{1}{rbash} diff --git a/pinyadmin/doc/rebuildrepo.latex b/pinyadmin/doc/rebuildrepo.latex new file mode 100644 index 0000000..a2e0935 --- /dev/null +++ b/pinyadmin/doc/rebuildrepo.latex @@ -0,0 +1,16 @@ +\usepackage{latex2man} + +\begin{Name}{8piny}{rebuildrepo}{Piny Team}{Piny}{rebuildrepo} + +\Prog{rebuildrepo} - rebuild a repo configuration + +\section{Synopsis} + +\Prog{rebuildrepo} \Arg{reponame} \Dots + +\section{Description} + +The \Prog{rebuildrepo} command rewrites all of the configuration files for +the given repo and adjusts ownership and group membership of its files to a +normalized state. It is needed to propagate certain kinds of changes; +normally only the system administrator should run it. diff --git a/pinyadmin/doc/rmaccess.latex b/pinyadmin/doc/rmaccess.latex new file mode 100644 index 0000000..41f7af4 --- /dev/null +++ b/pinyadmin/doc/rmaccess.latex @@ -0,0 +1,22 @@ +\usepackage{latex2man} + +\begin{Name}{1piny}{rmaccess}{Piny Team}{Piny}{rmaccess} + +\Prog{rmaccess} - remove access to a repository + +\section{Synopsis} + +\Prog{rmaccess} \Arg{reponame} \Arg{username} \Dots + +\section{Description} + +The \Prog{rmaccess} command denies users write access to a repository. +It may only be run by the owner of the repository. + +For each \Arg{username} passed on the command line, \Prog{addaccess} will deny write permission to the repository. +Other users are not affected. + +\section{Bugs} + +You cannot deny write permission to the owner of the repository. +If you try, the program will appear to succeed, but the owner will still be able to make changes. diff --git a/pinyadmin/doc/rmrepo.latex b/pinyadmin/doc/rmrepo.latex new file mode 100644 index 0000000..12b58df --- /dev/null +++ b/pinyadmin/doc/rmrepo.latex @@ -0,0 +1,14 @@ +\usepackage{latex2man} + +\begin{Name}{1piny}{rmrepo}{Piny Team}{Piny}{rmrepo} + +\Prog{rmrepo} - delete a repository + +\section{Synopsis} + +\Prog{rmrepo} \Arg{reponame} \Dots + +\section{Description} + +The \Prog{rmrepo} command permanently destroys the repository with the given name. +The current user must be the owner of the repository. diff --git a/pinyadmin/sbin/addaccess b/pinyadmin/sbin/addaccess new file mode 100755 index 0000000..e351114 --- /dev/null +++ b/pinyadmin/sbin/addaccess @@ -0,0 +1,19 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Piny; + +my $env = Piny::Environment->instance( ); + +my ( $reponame, @users ) = @ARGV; + +my $repo = Piny::Repo->new( $reponame ); + +if ( $repo->owner->uid != $env->user->uid ) { + print "You are not the owner of that repo!\n"; + exit( 3 ); +}; + +$repo->add_access( map { Piny::User->new( $_ ) } @users ); diff --git a/pinyadmin/sbin/newrepo b/pinyadmin/sbin/newrepo new file mode 100755 index 0000000..a178ecb --- /dev/null +++ b/pinyadmin/sbin/newrepo @@ -0,0 +1,40 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Moose::Util::TypeConstraints qw( find_type_constraint ); + +use Piny; + +my ( $name ) = @ARGV; + +if ( not defined $name ) { + print "Usage: newrepo REPONAME\n"; + exit 1; +}; + +if ( not find_type_constraint( "Reponame" )->check( $name ) ) { + print "That is not a valid repo name; must be at least 1 character long, begin with a lowercase alphanumeric character, and contain only alphanumeric characters and dashes.\n"; + exit 1; +}; + +my $description; +while( 1 ) { + + print "Provide a one-line description to be used in repo listings, the shorter the better:\n"; + chomp( $description = <STDIN> ); + + if ( not find_type_constraint( "SimpleText" )->check( $description ) ) { + print "Must be 1-80 characters long; control characters (including tab) not allowed.\n"; + next; + }; + + print "Okay! Working, please wait...\n"; + last; + +}; + +my $repo = Piny::Repo->create( $name, $description ); + +print "Repo URL: " . $repo->ikiwiki_url . "\n"; diff --git a/pinyadmin/sbin/newuser b/pinyadmin/sbin/newuser new file mode 100755 index 0000000..e064f06 --- /dev/null +++ b/pinyadmin/sbin/newuser @@ -0,0 +1,129 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Email::Valid::Loose qw( ); + +# If they passed any arguments, complain and exit. +if ( scalar @ARGV ) { + print "You can't pass any arguments to this script!\n"; + exit 2; +}; + +# If they didn't provide a terminal definition, then assume xterm. +# Everybody emulates xterm to at least a basic extent. +if ( not exists $ENV{"TERM"} ) { + $ENV{"TERM"} = "xterm"; + print "I don't know what terminal you're using; guessing xterm...\n"; +}; + +# Disable buffering. +$|++; + +# Configure the strictness of our email checks. +my $checker = Email::Valid::Loose->new + ( "-fqdn" => 1 + , "-fudge" => 0 + , "-local_rules" => 0 + , "-mxcheck" => 1 + , "-tldcheck" => 0 + ); + +my ( $email, $username, $password1, $password2 ); + +while ( 1 ) { + + print "Email address to associate with new user: "; + chomp ( $email = <STDIN> ); + + if ( $email eq "" ) { + print "You must provide an email address!\n"; + next; + }; + + $email = $checker->address( $email ); + if ( not defined $email ) { + print "Please, at least pretend to provide a valid email address.\n"; + next; + }; + + last; + +}; + +while ( 1 ) { + + print "Desired username: "; + chomp ( $username = <STDIN> ); + + if ( $username eq "" ) { + print "You have to enter a username!\n"; + next; + }; + + if ( $username =~ /^git-|^ikiwiki-/ ) { + print "Your username cannot start with git- or ikiwiki-!\n"; + next + }; + + if ( $username !~ /^[a-zA-Z0-9_.][a-zA-Z0-9_.-]+$/ ) { + print( "Usernames must consist only of letters, digits, underscores, periods, and dashes, and not start with a dash. Usernames are case sensitive.\n" ); + next + }; + + last; + +}; + +while ( 1 ) { + + system( "stty", "-echo" ); + print "Desired password: "; + chomp ( $password1 = <STDIN> ); + print "\nRetype password: "; + chomp ( $password2 = <STDIN> ); + print "\n"; + system( "stty", "echo" ); + + if ( $password1 ne $password2 ) { + print "Provided passwords do not match; try again.\n"; + next; + }; + + if ( $password1 eq "" ) { + print "You have to enter a password!\n"; + next; + }; + + last; + +}; + +my @saltchars = + ( 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' + , 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' + , '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' + , '.', '/' + ); + +my $salt = "\$6\$"; + +foreach my $n ( 1 .. 16 ) { + $salt .= $saltchars[int ( rand ( scalar @saltchars ) )]; +}; + +$salt .= "\$"; + +my $crypt = crypt( $password1, $salt ); + +my $ret = system( "/usr/sbin/useradd", "-c", "$email", "-k", "/var/empty", "-g", "users", "-m", "-p", $crypt, "-s", "/usr/bin/pinyshell", $username ); + +if ( $ret ) { + print "An error occured creating the user; most likely, that username is already taken.\n"; + exit 1; +}; + +print "Your user has been created. Try logging in!\n"; + +exit 0; diff --git a/pinyadmin/sbin/pinyconfig b/pinyadmin/sbin/pinyconfig new file mode 100755 index 0000000..f6752db --- /dev/null +++ b/pinyadmin/sbin/pinyconfig @@ -0,0 +1,38 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Piny; + +my ( $reponame, $attr, $value ) = @ARGV; + +if ( not defined $reponame or not defined $attr ) { + die "Usage: $0 reponame tweakable [value]\n"; +}; + +$attr = lc $attr; +$attr =~ s/\./_/g; + +my $repo = Piny::Repo->new( $reponame ); + +if ( defined $value ) { + undef $@; + eval { + $repo->config->$attr( $value ); + }; + if ( $@ ) { + print STDERR "$attr is not a legal tweakable, or $value is not a legal value for that tweakable.\n$@\n"; + }; + if ( $value ne $repo->config->$attr ) { + print STDERR "Failed to set $attr (perhaps an override is in place)\n"; + }; +}; + +undef $@; +eval { + print "$attr = " . $repo->config->$attr . "\n"; +}; +if ( $@ ) { + print STDERR "$attr is not a legal tweakable, or its current value is illegal.\n$@\n"; +}; diff --git a/pinyadmin/sbin/rebuildrepo b/pinyadmin/sbin/rebuildrepo new file mode 100755 index 0000000..9d4e359 --- /dev/null +++ b/pinyadmin/sbin/rebuildrepo @@ -0,0 +1,14 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Piny; + +foreach my $reponame ( @ARGV ) { + + my $repo = Piny::Repo->new( $reponame ); + + $repo->rebuild; + +}; diff --git a/pinyadmin/sbin/rmaccess b/pinyadmin/sbin/rmaccess new file mode 100755 index 0000000..d6c22a9 --- /dev/null +++ b/pinyadmin/sbin/rmaccess @@ -0,0 +1,19 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Piny; + +my $env = Piny::Environment->instance( ); + +my ( $reponame, @users ) = @ARGV; + +my $repo = Piny::Repo->new( $reponame ); + +if ( $repo->owner->uid != $env->user->uid ) { + print "You are not the owner of that repo!\n"; + exit( 3 ); +}; + +$repo->remove_access( map { Piny::User->new( $_ ) } @users ); diff --git a/pinyadmin/sbin/rmrepo b/pinyadmin/sbin/rmrepo new file mode 100755 index 0000000..dff8fe5 --- /dev/null +++ b/pinyadmin/sbin/rmrepo @@ -0,0 +1,21 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Piny; + +my $env = Piny::Environment->instance( ); + +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; + }; + + $repo->destroy; + +}; |