summaryrefslogtreecommitdiff
path: root/usr
diff options
context:
space:
mode:
authorJulian Blake Kongslie <jblake@omgwallhack.org>2010-07-07 15:44:46 -0700
committerJulian Blake Kongslie <jblake@omgwallhack.org>2010-07-07 15:44:46 -0700
commitd809044c2f00d7f8358dc8013c4e6639760aba67 (patch)
treed15343ee934bc6b23a395046d35f7fb4e6131459 /usr
parentf5674a8b57fe48d470fae283ac3d3c259f8aa9c7 (diff)
downloadpiny-code-d809044c2f00d7f8358dc8013c4e6639760aba67.tar.gz
piny-code-d809044c2f00d7f8358dc8013c4e6639760aba67.zip
Revising newrepo to use libpiny.
Diffstat (limited to 'usr')
-rw-r--r--usr/src/libpiny/debian/changelog6
-rw-r--r--usr/src/libpiny/lib/Piny.pm1
-rw-r--r--usr/src/libpiny/lib/Piny/Email.pm2
-rw-r--r--usr/src/libpiny/lib/Piny/Repo.pm127
-rw-r--r--usr/src/libpiny/lib/Piny/User.pm4
-rw-r--r--usr/src/libpiny/lib/Piny/User/IkiWiki.pm33
-rw-r--r--usr/src/pinyadmin/debian/changelog6
-rw-r--r--usr/src/pinyadmin/debian/control2
-rwxr-xr-xusr/src/pinyadmin/sbin/newrepo235
9 files changed, 173 insertions, 243 deletions
diff --git a/usr/src/libpiny/debian/changelog b/usr/src/libpiny/debian/changelog
index 01b3a02..1e99808 100644
--- a/usr/src/libpiny/debian/changelog
+++ b/usr/src/libpiny/debian/changelog
@@ -1,3 +1,9 @@
+libpiny-perl (0.9) unstable; urgency=low
+
+ * Creating new repos.
+
+ -- Julian Blake Kongslie <jblake@omgwallhack.org> Wed, 07 Jul 2010 15:34:37 -0700
+
libpiny-perl (0.8) unstable; urgency=low
* Added apache config stuff.
diff --git a/usr/src/libpiny/lib/Piny.pm b/usr/src/libpiny/lib/Piny.pm
index 2dc2b84..2ed139b 100644
--- a/usr/src/libpiny/lib/Piny.pm
+++ b/usr/src/libpiny/lib/Piny.pm
@@ -10,5 +10,6 @@ use Piny::Environment;
use Piny::Group;
use Piny::Repo;
use Piny::User;
+use Piny::User::IkiWiki;
1;
diff --git a/usr/src/libpiny/lib/Piny/Email.pm b/usr/src/libpiny/lib/Piny/Email.pm
index 7ad17d8..e031c34 100644
--- a/usr/src/libpiny/lib/Piny/Email.pm
+++ b/usr/src/libpiny/lib/Piny/Email.pm
@@ -18,6 +18,8 @@ subtype 'EmailAddress'
=> message { 'That does not appear to be a valid email address.' }
;
+Moose::Util::TypeConstraints::export_type_constraints_as_functions;
+
# Attributes
has 'address' =>
diff --git a/usr/src/libpiny/lib/Piny/Repo.pm b/usr/src/libpiny/lib/Piny/Repo.pm
index 5ad7007..48690c4 100644
--- a/usr/src/libpiny/lib/Piny/Repo.pm
+++ b/usr/src/libpiny/lib/Piny/Repo.pm
@@ -7,11 +7,15 @@ use Moose;
use Moose::Util::TypeConstraints;
use File::Find qw( find );
+use File::Temp qw( );
+use IO::Dir qw( );
use IkiWiki::FakeSetup qw( readSetup writeSetup );
+use Piny::Environment;
use Piny::Group;
use Piny::User;
+use Piny::User::IkiWiki;
# Types
@@ -27,6 +31,8 @@ subtype 'SimpleText'
=> message { 'That description is not in the correct format for a piny repo.' }
;
+Moose::Util::TypeConstraints::export_type_constraints_as_functions;
+
# Attributes
has 'name' =>
@@ -239,6 +245,103 @@ sub all_repos {
return @ret;
};
+sub create {
+ my ( $class, $name, $description ) = @_;
+
+ my $user = Piny::Environment->new->user;
+
+ Reponame->assert_valid( $name );
+ SimpleText->assert_valid( $description );
+
+ my $repo = $class->new( "name" => $name );
+
+ mkdir( $repo->path ) or die "The repo $name appears to already exist! ($!)";
+
+ system( "/usr/sbin/adduser", "--quiet", "--system", "--group", "--gecos", $name, "ikiwiki-$name" ) and die "Could not create ikiwiki user!";
+
+ my $ikiuser = Piny::User::IkiWiki->new( "name" => "ikiwiki-$name" );
+
+ system( "/usr/sbin/addgroup", "--quiet", "git-$name" ) and die "Could not create repo group!";
+
+ my $group = Piny::Group->new( "name" => "git-$name" );
+
+ system( "/usr/sbin/adduser", "--quiet", $user->name, $group->name ) and die "Could not add you to the repo group!";
+ system( "/usr/sbin/adduser", "--quiet", $ikiuser->name, $group->name ) and die "Could not add ikiwiki user to the repo group!";
+
+ $ENV{"GIT_DIR"} = $repo->path;
+ system( "/usr/bin/git", "init", "--template=/srv/git-template.git", "--quiet", "--shared" ) and die "Could not initialize git repo!";
+ delete $ENV{"GIT_DIR"};
+
+ $repo->set_description( $description );
+
+ open( TOUCH, ">", $repo->path . "/git-daemon-export-ok" ) or die "Could not touch git-daemon-export-ok for repo: $!";
+ close( TOUCH );
+
+ system( "/bin/chown", "-R", $user->name . "." . $group->name, $repo->path ) and die "Could not change ownership of git repo!";
+ system( "/bin/chown", "-R", $ikiuser->name . "." . $ikiuser->name, $repo->path . "/hooks" ) and die "Could not change ownership of git hooks!";
+
+ open( SETUP, ">", "/etc/ikiwiki/piny/" . $repo->name . ".setup" ) or die "Could not open new ikiwiki setup file: $!";
+ print SETUP $repo->ikiwiki_setup;
+ close( SETUP ) or die "Could not close new ikiwiki setup file: $!";
+
+ open( APACHE, ">", "/etc/apache2/piny-available/" . $repo->name ) or die "Could not open new apache config: $!";
+ print APACHE $repo->apache_config;
+ close( APACHE ) or die "Could not close new apache config: $!";
+
+ symlink( "/etc/apache2/piny-available/" . $repo->name, "/etc/apache2/piny-enabled/" . $repo->name ) or die "Could not symlink apache config: $!";
+
+ system( "/etc/init.d/apache2", "reload" ) and die "Could not reload apache config!";
+
+ system( "/usr/bin/git", "clone", "--quiet", $repo->path, $repo->ikiwiki_srcdir ) and die "Could not clone repo to ikiwiki srcdir!";
+
+ mkdir( $repo->ikiwiki_destdir ) or die "Could not create ikiwiki destdir: $!";
+ mkdir( $repo->secure_path ) or die "Could not create secure dir: $!";
+
+ system( "/bin/chown", "-R", $ikiuser->name . "." . $ikiuser->name, $repo->ikiwiki_srcdir, $repo->ikiwiki_destdir, $repo->secure_path ) and die "Could not change ownership of ikiwiki directories!";
+
+ open( WIKILIST, ">", "/etc/ikiwiki/wikilist.d/" . $repo->name ) or die "Could not create wikilist.d file: $!";
+ print WIKILIST $ikiuser->name . " /etc/ikiwiki/piny/" . $repo->name . ".setup\n";
+ close( WIKILIST ) or die "Could not close wikilist.d file: $!";
+
+ my $temp = File::Temp->new( ) or die "Could not create temporary file: $!";
+ $temp->unlink_on_destroy( 0 );
+
+ my $dh = IO::Dir->new( "/etc/ikiwiki/wikilist.d" ) or die "Could not open wikilist.d directory: $!";
+ while ( defined ( my $entry = $dh->read ) ) {
+ next if ( $entry =~ /^\./ );
+ open( FILE, "<", "/etc/ikiwiki/wikilist.d/" . $entry ) or die "Could not open wikilist.d entry $entry: $!";
+ print $temp <FILE>;
+ close( FILE ) or die "Could not close wikilist.d entry $entry: $!";
+ };
+
+ $temp->close or die "Could not close new wikilist: $!";
+
+ rename( $temp->filename, "/etc/ikiwiki/wikilist" ) or die "Could not rename over old wikilist: $!";
+
+ open( CGITLIST, ">", "/etc/cgitrc.d/" . $repo->name ) or die "Could not create cgitrc.d file: $!";
+ print CGITLIST "repo.url=" . $repo->name . "\nrepo.path=" . $repo->path . "\nrepo.desc=" . $repo->description . "\nrepo.owner=" . $repo->owner->email . "\n\n";
+ close( CGITLIST ) or die "Could not close cgitrc.d file: $!";
+
+ $temp = File::Temp->new( ) or die "Could not create temporary file: $!";
+ $temp->unlink_on_destroy( 0 );
+
+ $dh = IO::Dir->new( "/etc/cgitrc.d" ) or die "Could not open cgitrc.d directory: $!";
+ while ( defined ( my $entry = $dh->read ) ) {
+ next if ( $entry =! /^\./ );
+ open( FILE, "<", "/etc/cgitrc.d/" . $entry ) or die "Could not open cgitrc.d entry $entry: $!";
+ print $temp <FILE>;
+ close( FILE ) or die "Could not close cgitrc.d entry $entry: $!";
+ };
+
+ $temp->close or die "Could not close new cgitrc: $!";
+
+ rename( $temp->filename, "/etc/cgitrepos" ) or die "Could not rename over old cgitrc: $!";
+
+ system( "/usr/bin/sudo", "-u", $ikiuser->name, "/usr/bin/ikiwiki", "--setup", "/etc/ikiwiki/piny/" . $repo->name . ".setup" ) and die "Could not do initial compile of ikiwiki!";
+
+ return $repo;
+};
+
# Builder methods
# If constructed with just one argument, then treat it as a repo name.
@@ -261,13 +364,7 @@ sub _build_group {
sub _build_path {
my ( $s ) = @_;
- my $dir = "/srv/git/" . $s->name . ".git";
-
- if ( -d $dir ) {
- return $dir;
- } else {
- die "Expected repo $dir does not exist!";
- };
+ return "/srv/git/" . $s->name . ".git";
};
sub _build_description {
@@ -345,25 +442,13 @@ sub _build_ikiwiki_setup {
sub _build_ikiwiki_destdir {
my ( $s ) = @_;
- my $dir = "/srv/www/piny.be/" . $s->name;
-
- if ( -d $dir ) {
- return $dir;
- } else {
- die "Expected destdir $dir does not exist!";
- };
+ return "/srv/www/piny.be/" . $s->name;
};
sub _build_ikiwiki_srcdir {
my ( $s ) = @_;
- my $dir = "/srv/ikiwiki/" . $s->name;
-
- if ( -d $dir ) {
- return $dir;
- } else {
- die "Expected srcdir $dir does not exist!";
- };
+ return "/srv/ikiwiki/" . $s->name;
};
sub _build_ikiwiki_url {
diff --git a/usr/src/libpiny/lib/Piny/User.pm b/usr/src/libpiny/lib/Piny/User.pm
index 173b592..fb9a20f 100644
--- a/usr/src/libpiny/lib/Piny/User.pm
+++ b/usr/src/libpiny/lib/Piny/User.pm
@@ -13,10 +13,12 @@ use Piny::Group;
subtype 'Username'
=> as 'Str'
- => where { $_ =~ /^(?!(git|ikiwiki)-)[[a-zA-Z][a-zA-Z0-9_.-]*$/ }
+ => where { $_ =~ /^(?!(git|ikiwiki)-)[a-zA-Z][a-zA-Z0-9_.-]*$/ }
=> message { 'That username is not in the correct format for a piny user.' }
;
+Moose::Util::TypeConstraints::export_type_constraints_as_functions;
+
# Attributes
has 'uid' =>
diff --git a/usr/src/libpiny/lib/Piny/User/IkiWiki.pm b/usr/src/libpiny/lib/Piny/User/IkiWiki.pm
new file mode 100644
index 0000000..b522ad8
--- /dev/null
+++ b/usr/src/libpiny/lib/Piny/User/IkiWiki.pm
@@ -0,0 +1,33 @@
+# Copyright © 2010 Julian Blake Kongslie <jblake@omgwallhack.org>
+# Licensed under the BSD 3-clause license.
+
+package Piny::User::IkiWiki;
+
+use Moose;
+use Moose::Util::TypeConstraints;
+
+use Piny::User;
+
+extends "Piny::User";
+
+# Types
+
+subtype 'IkiWikiUsername'
+ => as 'Str'
+ => where { $_ =~ /^ikiwiki-[a-zA-Z][a-zA-Z0-9_.-]*$/ }
+ => message { 'That username is not in the correct format for an ikiwiki user.' }
+ ;
+
+# Attributes
+
+has 'name' =>
+ ( is => 'ro'
+ , isa => 'IkiWikiUsername'
+ , lazy_build => 1
+ );
+
+# Moose boilerplate
+
+__PACKAGE__->meta->make_immutable;
+
+1;
diff --git a/usr/src/pinyadmin/debian/changelog b/usr/src/pinyadmin/debian/changelog
index 4f0a8eb..723c7e0 100644
--- a/usr/src/pinyadmin/debian/changelog
+++ b/usr/src/pinyadmin/debian/changelog
@@ -1,3 +1,9 @@
+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.
diff --git a/usr/src/pinyadmin/debian/control b/usr/src/pinyadmin/debian/control
index 25df07d..950a6c9 100644
--- a/usr/src/pinyadmin/debian/control
+++ b/usr/src/pinyadmin/debian/control
@@ -7,7 +7,7 @@ Standards-version: 3.8.4
Package: pinyadmin
Architecture: all
-Depends: ${perl:Depends}, ${misc:Depends}, libpiny-perl (>= 0.5)
+Depends: ${perl:Depends}, ${misc:Depends}, libpiny-perl (>= 0.9)
Description: Administrative programs for piny
The command-line programs for day-to-day administrative tasks in the Piny
infrastructure.
diff --git a/usr/src/pinyadmin/sbin/newrepo b/usr/src/pinyadmin/sbin/newrepo
index 15bbde6..1f83e82 100755
--- a/usr/src/pinyadmin/sbin/newrepo
+++ b/usr/src/pinyadmin/sbin/newrepo
@@ -3,241 +3,36 @@
use strict;
use warnings;
-my( $errorto ) = 'jrayhawk+piny.be@omgwallhack.org'; # Email address to send horrible errors to.
-my( $reponame, $email, @errors, $wikilisttempfile, $cgitrctempfile, $description );
+use Piny;
-if ( ( ! scalar $ARGV[0] ) or ( scalar $ARGV[1] ) or ( $ARGV[0] !~ /^[a-z0-9][a-z0-9-]+$/ ) ) {
- print( "Usage: newrepo REPONAME\n" );
- print( " REPONAME must consist only of lower case letters (a-z), digits (0-9), and minus (-) signs.\n" );
- print( " REPONAME must be at least two characters long and must start with an alphanumeric character.\n" );
- exit( 1 );
-} else {
- $reponame = $ARGV[0];
-};
+my ( $name ) = @ARGV;
-# We want to check to see if
-# 1) $reponame already exists in some form so we don't try to create it, and
-# 2) $reponame is only partially created, in which case we want to email someone who can sanity check and fix it.
-open (PASSWD, '/etc/passwd');
-while(<PASSWD>) {
- if( $_ =~ /^$ENV{SUDO_USER}:.+?:.+?:.+?:(.+?):/ ) { $email = $1; }; # While we're here, may as well grab the email address.
- if( $_ =~ /^ikiwiki-$reponame:/ ) { push( @errors, "user ikiwiki-$reponame already exists!\n"); };
-};
-close(PASSWD);
-open (GROUP, '/etc/group');
-while(<GROUP>) {
- if( $_ =~ /^git-$reponame:/ ) { push( @errors, "group git-$reponame already exists!\n"); };
+if ( not defined $name ) {
+ print "Usage: newrepo REPONAME\n";
+ exit 1;
};
-close(GROUP);
-if( -d "/srv/git/$reponame.git" ) { push( @errors, "/srv/git/$reponame.git already exists!\n"); };
-if( -d "/srv/ikiwiki/$reponame" ) { push( @errors, "/srv/ikiwiki/$reponame already exists!\n"); };
-if( -d "/srv/www/piny.be/$reponame" ) { push( @errors, "/srv/www/piny.svcs.cs.pdx.edu/$reponame already exists!\n"); };
-if( -d "/srv/www/secure.piny.be/repos/$reponame" ) { push( @errors, "/srv/www/cgi.piny.be/repos/$reponame already exists!\n"); };
-if( -f "/etc/ikiwiki/piny/$reponame.setup" ) { push( @errors, "/etc/ikiwiki/piny/$reponame.setup already exists!\n"); };
-if( -f "/etc/ikiwiki/wikilist.d/$reponame" ) { push( @errors, "/etc/ikiwiki/wikilist.d/$reponame already exists!\n"); };
-if( -f "/etc/apache2/piny-available/$reponame" ) { push( @errors, "/etc/apache2/piny-available/$reponame already exists!\n"); };
-if( -f "/etc/cgitrc.d/$reponame" ) { push( @errors, "/etc/cgitrc.d/$reponame already exists!\n"); };
-if( @errors ) {
- if( @errors == 10 ) { # Everything's fine, nothing is broken
- print( "$reponame already exists!\n" );
- } else { # IT'S ARMAGEDDON
- open ( MAIL, "|/usr/lib/sendmail -t" );
- print( MAIL "To: $errorto\n" );
- print( MAIL "From: newrepo\@piny.be\n" );
- print( MAIL "Subject: Piny error: $ENV{SUDO_USER} found inconsistent $reponame in the creation process!\n" );
- print( MAIL "MIME-Version: 1.0\n" );
- print( MAIL "Content-Type: text/plain; charset=us-ascii\n" );
- print( MAIL "\n" );
- print( MAIL "@errors\n" );
- close( MAIL );
- print( "$reponame already exists but is in an inconsistent state! The Piny admins probably screwed up; they have been notified and will take a look at it.\n" );
- };
- exit( 2 );
+if ( not Piny::Repo::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" );
+ print "Provide a one-line description to be used in repo listings, the shorter the better:\n";
chomp( $description = <STDIN> );
- if( $description !~ /^[\x{0020}-\x{FDCF}\x{FDF0}-\x{FFFD}]{1,80}$/ ) { # everything but control characters and unicode-defined non-characters
- print( "Must be 1-80 characters long; control characters (including tab) not allowed.\n" );
+ if ( not Piny::Repo::SimpleText->check( $description ) ) {
+ print "Must be 1-80 characters long; control characters (including tab) not allowed.\n";
next;
};
- print( "Okay! Working, please wait...\n" );
+ print "Okay! Working, please wait...\n";
last;
};
-# CREATE USER/GROUPS
-unless( system( "mkdir /srv/git/$reponame.git" ) == 0 ) { # We need a locking or atomic operation as our first to check against simultaneous execution.
- print( "Somebody else has created the same repo as you in the course of executing this program!\n" );
- exit( 3 );
-};
-system( "/usr/sbin/addgroup --quiet git-$reponame" );
-system( "/usr/sbin/adduser --quiet --system --group --gecos $reponame ikiwiki-$reponame" );
-system( "/usr/sbin/adduser --quiet ikiwiki-$reponame git-$reponame | grep -v 'Adding user'" );
-system( "/usr/sbin/adduser --quiet $ENV{SUDO_USER} git-$reponame | grep -v 'Adding user '" );
-
-# CREATE REPO
-system( "GIT_DIR=/srv/git/$reponame.git /usr/bin/git init --template=/srv/git-template.git --quiet --shared" );
-open ( DESC, ">/srv/git/$reponame.git/description" );
-print( DESC "$description" );
-close( DESC );
-# ln -f post-receive /srv/git/$reponame.git/hooks/ # turn on e-mail commit notices
-system( "/bin/chown -R $ENV{SUDO_USER}.git-$reponame /srv/git/$reponame.git/" );
-system( "/bin/chown -R ikiwiki-$reponame.ikiwiki-$reponame /srv/git/$reponame.git/hooks/" );
-system( "/bin/touch /srv/git/$reponame.git/git-daemon-export-ok" );
-
-# WRITE IKIWIKI SETUP FILE
-open ( SETUP, ">/etc/ikiwiki/piny/$reponame.setup" );
-print( SETUP
-'#!/usr/bin/perl
-# Configuration file for ikiwiki.
-# Passing this to ikiwiki --setup will make ikiwiki generate wrappers and
-# build the wiki.
-#
-# Remember to re-run ikiwiki --setup any time you edit this file.
-
-use IkiWiki::Setup::Standard {
- wikiname => \'' . $reponame . '\', # PINY
- adminemail => \'' . $email . '\', # PINY
- srcdir => \'/srv/ikiwiki/' . $reponame . '\', # PINY
- destdir => \'/srv/www/piny.be/' . $reponame . '\', # PINY
- url => \'http://piny.be/' . $reponame . '\', # PINY
- cgiurl => \'https://secure.piny.be/repos/' . $reponame . '/ikiwiki.cgi\', # PINY
- historyurl => \'https://secure.piny.be/cgit/' . $reponame . '/log/[[file]]\', # PINY
- diffurl => \'https://secure.piny.be/cgit/' . $reponame . '/diff/?id=[[sha1_commit]]\', # PINY
-
- templatedir => "/srv/templates",
- underlaydir => "/etc/ikiwiki/share/underlay",
-
- rcs => "git",
- gitorigin_branch => "origin",
- gitmaster_branch => "master",
-
- wrappers => [
- {
- cgi => 1,
- wrapper => \'/srv/www/secure.piny.be/repos/' . $reponame . '/ikiwiki.cgi\', # PINY
- wrappermode => "06755",
- wrappergroup => \'git-' . $reponame . '\', # PINY
- },
- {
- wrapper => \'/srv/git/' . $reponame . '.git/hooks/post-update\', # PINY
- wrappermode => "06755",
- wrappergroup => \'git-' . $reponame . '\', # PINY
-
- notify => 0,
- },
- ],
-
- # Generate rss feeds for blogs?
- rss => 1,
- # Generate atom feeds for blogs?
- atom => 0,
- # Include discussion links on all pages?
- discussion => 0,
- # To exclude files matching a regexp from processing. This adds to
- # the default exclude list.
- #exclude => qr/*\.wav/,
- # To change the extension used for generated html files.
- #htmlext => "htm",
- # Time format (for strftime)
- #timeformat => "%c",
- # Locale to use. Must be a UTF-8 locale.
- #locale => "en_US.UTF-8",
- # Only send cookies over SSL connections.
- sslcookie => 1,
- # Logging settings:
- verbose => 0,
- syslog => 1,
- # To link to user pages in a subdirectory of the wiki.
- #userdir => "users",
- # To create output files named page.html rather than page/index.html.
- usedirs => 1,
- # Simple spam prevention: require an account-creation password.
- #account_creation_password => "example",
- # Use new "!"-prefixed preprocessor directive syntax
- prefix_directives => 1,
- httpauth => 1,
- # To add plugins, list them here.
- add_plugins => [qw{sidebar toc meta table tag graphviz httpauth img attachment rename remove autoindex map teximg version edittemplate}],
- disable_plugins => [qw{openid passwordauth}],
- teximg_prefix => \'\\documentclass{scrartcl}
-\\usepackage[version=3]{mhchem}
-\\usepackage{amsmath}
-\\usepackage{amsfonts}
-\\usepackage{amssymb}
-\\pagestyle{empty}
-\\newcommand{\unit}[1]{\\ensuremath{\\, \\mathrm{#1}}}
-\\begin{document}\',
-
- teximg_dvipng => 1,
-
- # For use with the tag plugin, make all tags be located under a
- # base page.
- tagbase => "tag",
-
- # For use with the search plugin if your estseek.cgi is located
- # somewhere else.
- #estseek => "/usr/lib/estraier/estseek.cgi",
-}');
-close( SETUP );
-open ( WIKILIST, '>>/etc/ikiwiki/wikilist' );
-print( WIKILIST "ikiwiki-$reponame /etc/ikiwiki/piny/$reponame.setup\n" );
-close( WIKILIST );
-
-# WRITE APACHE CONFIG
-open ( APACHE, ">/etc/apache2/piny-available/$reponame" );
-print( APACHE '<Directory /srv/www/secure.piny.be/repos/' . $reponame . '>
- AuthPAM_Enabled on
- AuthGROUP_Enabled on
- AuthPAM_FallThrough off
- AuthBasicAuthoritative off
- AuthType Basic
- AuthName "User access to ' . $reponame . ' repository needed."
- Require group git-' . $reponame . '
-</Directory>' );
-close( APACHE );
-link( "/etc/apache2/piny-available/$reponame", "/etc/apache2/piny-enabled/$reponame");
-system( '/etc/init.d/apache2 reload | grep -v "Reloading web server config: apache2."' );
-
-
-# CREATE IKIWIKI WORKING DIR
-system( "/usr/bin/git clone --quiet /srv/git/$reponame /srv/ikiwiki/$reponame" );
-mkdir( "/srv/www/piny.be/$reponame" );
-mkdir( "/srv/www/secure.piny.be/repos/$reponame" );
-system( "/bin/chown -R ikiwiki-$reponame /srv/ikiwiki/$reponame /srv/www/piny.be/$reponame /srv/www/secure.piny.be/repos/$reponame" );
-
-open ( WIKILIST, ">/etc/ikiwiki/wikilist.d/$reponame" ); # Maybe someday ikiwiki will support wikilist.d.
-print( WIKILIST "ikiwiki-$reponame /etc/ikiwiki/piny/$reponame.setup\n" ); # In the meantime, we fake it.
-close( WIKILIST );
-$wikilisttempfile = `/bin/mktemp`;
-chomp( $wikilisttempfile );
-chmod ( 0644, $wikilisttempfile );
-system( "/bin/cat /etc/ikiwiki/wikilist.d/* > $wikilisttempfile" );
-system( "/bin/mv $wikilisttempfile /etc/ikiwiki/wikilist" ); # This is marginally racy, but the consequences are probably ignorable.
-
-open ( CGITRC, ">/etc/cgitrc.d/$reponame" ); # Maybe someday cgit will support cgitrc.d.
-print( CGITRC # In the meantime, we fake it.
-"repo.url=$reponame
-repo.path=/srv/git/$reponame.git
-repo.desc=$description
-repo.owner=$email
-
-" ); # cgit already escapes HTML, so we don't need to do it on $description
-close( CGITRC );
-$cgitrctempfile = `/bin/mktemp`;
-chomp( $cgitrctempfile );
-chmod ( 0644, $cgitrctempfile );
-system( "/bin/cat /etc/cgitrc.d/* > $cgitrctempfile" );
-system( "/bin/mv $cgitrctempfile /etc/cgitrepos" ); # This is marginally racy, but the consequences are minor.
-
-# COMPILE
-system( "/usr/bin/sudo -u ikiwiki-$reponame /usr/bin/ikiwiki --setup /etc/ikiwiki/piny/$reponame.setup | grep -v 'successfully generated'" );
+my $repo = Piny::Repo->create( $reponame, $description );
-print( "Web interface: http://piny.be/$reponame/\n" );
-print( "Repo information: https://secure.piny.be/cgit/$reponame/\n" );
+print "Repo URL: " . $repo->ikiwiki_url . "\n";