summaryrefslogtreecommitdiff
path: root/pinyadmin
diff options
context:
space:
mode:
Diffstat (limited to 'pinyadmin')
-rw-r--r--pinyadmin/debian/control2
-rwxr-xr-xpinyadmin/sbin/newrepo50
2 files changed, 38 insertions, 14 deletions
diff --git a/pinyadmin/debian/control b/pinyadmin/debian/control
index 126b57c..b41d5b5 100644
--- a/pinyadmin/debian/control
+++ b/pinyadmin/debian/control
@@ -8,7 +8,7 @@ Standards-version: 3.9.1
Package: pinyadmin
Architecture: all
-Depends: ${perl:Depends}, ${misc:Depends}, libpiny-perl (>= 0.14), moreutils
+Depends: ${perl:Depends}, ${misc:Depends}, libpiny-perl (>= 0.14), libgetopt-tabular-perl, moreutils
Description: Administrative programs for piny
The command-line programs for day-to-day administrative tasks in the Piny
infrastructure.
diff --git a/pinyadmin/sbin/newrepo b/pinyadmin/sbin/newrepo
index a13a0dc..8f13873 100755
--- a/pinyadmin/sbin/newrepo
+++ b/pinyadmin/sbin/newrepo
@@ -3,26 +3,35 @@
use strict;
use warnings;
+use Getopt::Tabular qw( );
+
use Moose::Util::TypeConstraints qw( find_type_constraint );
use Piny;
-my ( $batch, $name, $remote );
-if ( $ARGV[0] eq "--batch" ) {
- ( $batch, $name, $remote ) = @ARGV;
-} else {
- ( $name, $remote ) = @ARGV;
-};
+my ( $batch ) = ( 0 );
+my ( $name, $remote, $ikiwiki );
+
+Getopt::Tabular::SetOptionPatterns( "(--)[\\w-]+", "(-)\\w" );
+Getopt::Tabular::SetHelpOption( "--help" );
+Getopt::Tabular::GetOptions(
+ [
+ [ "--batch", "const", 1, \$batch, "enable batch mode, for use as a backend by other scripts" ],
+ [ "--enable-ikiwiki|--disable-ikiwiki", "boolean", 0, \$ikiwiki, "enable or disable creation of an ikiwiki site for this repo" ]
+ ], \@ARGV
+) or exit( 0 );
+
+( $name, $remote ) = @ARGV;
if ( not defined $name ) {
- print "Usage: newrepo REPONAME\n";
- exit 1;
+ 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;
+ exit( 2 );
};
my $description;
@@ -33,8 +42,8 @@ while( 1 ) {
if ( not find_type_constraint( "SimpleText" )->check( $description ) ) {
print "Must be 1-80 characters long; control characters (including tab) not allowed.\n";
- if ( defined $batch ) {
- exit;
+ if ( $batch ) {
+ exit( 3 );
};
next;
};
@@ -74,5 +83,20 @@ if( defined( $remote ) ) {
$repo = Piny::Repo->create( $name, $description );
};
-print "Repo URL: " . $repo->ikiwiki_url . "\n";
-print "Repo URL: " . $repo->cgit_url . "\n";
+$repo->rebuild_git;
+
+if ( defined( $ikiwiki ) ) {
+ $repo->config->piny_ikiwiki( $ikiwiki );
+ if ( $repo->config->piny_ikiwiki ne $ikiwiki ) {
+ print( "Override in place for piny.ikiwiki.\n" );
+ };
+};
+
+if ( $repo->config->piny_ikiwiki ) {
+ $repo->rebuild_ikiwiki;
+ print( "Repo URL: " . $repo->ikiwiki_url . "\n" );
+} else {
+ print( "Ikiwiki disabled.\n" );
+};
+
+print( "Repo URL: " . $repo->cgit_url . "\n" );