summaryrefslogtreecommitdiff
path: root/libpiny
diff options
context:
space:
mode:
Diffstat (limited to 'libpiny')
-rw-r--r--libpiny/lib/Piny/Config.pm12
-rw-r--r--libpiny/lib/Piny/Repo.pm22
-rw-r--r--libpiny/lib/Piny/User.pm33
-rw-r--r--libpiny/share/ikiwiki.setup24
4 files changed, 77 insertions, 14 deletions
diff --git a/libpiny/lib/Piny/Config.pm b/libpiny/lib/Piny/Config.pm
index 5cd99da..535df33 100644
--- a/libpiny/lib/Piny/Config.pm
+++ b/libpiny/lib/Piny/Config.pm
@@ -35,8 +35,8 @@ subtype 'PathDir'
subtype 'HttpUrl'
=> as 'Str'
- => where { $_ =~ /^http:\/\//i }
- => message { 'Not a http:// URL.' }
+ => where { $_ =~ /^(http|https):\/\//i }
+ => message { 'Not a http:// or https:// URL.' }
;
subtype 'HttpsUrl'
@@ -107,6 +107,10 @@ sub _build__conf {
};
+ foreach my $key ( keys %$conf ) {
+ $conf->{$key} = "" unless defined $conf->{$key};
+ };
+
return $conf;
};
@@ -204,6 +208,7 @@ sub tweakable {
# The tweakables
+# Repo-specific tweakables, in the repos' .git/config files.
tweakable "piny_ikiwikidestdir" => "/srv/www/piny.be/", 'PathDir';
tweakable "piny_ikiwikisrcdir" => "/srv/ikiwiki/", 'PathDir';
tweakable "piny_ikiwikiurl" => "http://piny.be/", 'HttpUrl';
@@ -211,6 +216,9 @@ tweakable "piny_ikiwikisecureurl" => "https://secure.piny.be/", 'HttpsUrl'
tweakable "piny_ikiwikisecurepath" => "/srv/www/secure.piny.be/", 'PathDir';
tweakable "receive_denynonfastforwards" => "true", 'GitBool';
+# User-specific tweakables, in the users' ~/.gitconfig files.
+tweakable "user_email" => undef, 'Maybe[Str]';
+
# Moose boilerplate
__PACKAGE__->meta->make_immutable;
diff --git a/libpiny/lib/Piny/Repo.pm b/libpiny/lib/Piny/Repo.pm
index 17142ed..cfa73bd 100644
--- a/libpiny/lib/Piny/Repo.pm
+++ b/libpiny/lib/Piny/Repo.pm
@@ -203,6 +203,17 @@ sub has_access {
sub rebuild {
my ( $s ) = @_;
+ unless( getgrnam("git-" . $s->name ) ) {
+ system( "/usr/sbin/addgroup", "--quiet", "git-" . $s->name ) and die "Could not create repo group!";
+ system( "/usr/sbin/adduser", "--quiet", $s->owner->name, "git-" . $s->name ) and die "Could not add you to the repo group!";
+ system( "/usr/sbin/adduser", "--quiet", "ikiwiki-" . $s->name, "git-" . $s->name ) and print "...But that's probably okay.\n";
+ };
+
+ unless( getpwnam("ikiwiki-" . $s->name ) ) {
+ system( "/usr/sbin/adduser", "--quiet", "--system", "--group", "--gecos", $s->name, "ikiwiki-" . $s->name ) and die "Could not create ikiwiki user!";
+ system( "/usr/sbin/adduser", "--quiet", "ikiwiki-" . $s->name, "git-" . $s->name ) and die "Could not add ikiwiki user to the repo group!";
+ };
+
my $ikiuser = Piny::User::IkiWiki->new( "name" => "ikiwiki-" . $s->name );
foreach( "git-daemon-export-ok", "packed-refs" ) {
@@ -210,7 +221,7 @@ sub rebuild {
close( TOUCH );
};
- foreach( "info", "logs" ) {
+ foreach( "info", "logs", "branches" ) {
(-e $s->path . "/" . $_) or mkdir( $s->path . "/" . $_ ) or die "Could not mkdir $_ for repo: $!";
};
@@ -226,7 +237,14 @@ sub rebuild {
print SETUP $s->ikiwiki_setup;
close( SETUP ) or die "Could not close new ikiwiki setup file: $!";
- system( "/bin/chown", "-R", $ikiuser->name . "." . $ikiuser->name, $s->ikiwiki_srcdir, $s->ikiwiki_destdir, $s->secure_path ) and die "Could not change ownership of ikiwiki directories!";
+ unless( -d $s->ikiwiki_srcdir ) {
+ system( "/usr/bin/git", "clone", "--quiet", $s->path, $s->ikiwiki_srcdir ) and die "Could not clone repo to ikiwiki srcdir!";
+ };
+
+ foreach( $ikiuser->name, $s->ikiwiki_srcdir, $s->ikiwiki_destdir, $s->secure_path ) {
+ unless( -d $_ ) { mkdir( $_ ) };
+ system( "/bin/chown", "-R", $ikiuser->name . ".", $_ ) and die "Could not change ownership of ikiwiki directories!";
+ };
open( WIKILIST, ">", "/etc/ikiwiki/wikilist.d/" . $s->name ) or die "Could not create wikilist.d file: $!";
print WIKILIST $ikiuser->name . " /etc/ikiwiki/piny/" . $s->name . ".setup\n";
diff --git a/libpiny/lib/Piny/User.pm b/libpiny/lib/Piny/User.pm
index 6267ecb..780a698 100644
--- a/libpiny/lib/Piny/User.pm
+++ b/libpiny/lib/Piny/User.pm
@@ -10,6 +10,7 @@ use Moose;
use Moose::Util::TypeConstraints;
use MooseX::StrictConstructor;
+use Piny::Config;
use Piny::Email;
use Piny::Group;
@@ -49,6 +50,20 @@ has 'password_hash' =>
, init_arg => undef
);
+has 'home' =>
+ ( is => 'ro'
+ , isa => 'Path'
+ , lazy_build => 1
+ , init_arg => undef
+ );
+
+has 'config' =>
+ ( is => 'ro'
+ , isa => 'Piny::Config'
+ , lazy_build => 1
+ , init_arg => undef
+ );
+
has 'email' =>
( is => 'ro'
, isa => 'Piny::Email'
@@ -180,10 +195,26 @@ sub _build_password_hash {
return $s->pwent( )->[1];
};
+sub _build_home {
+ my ( $s ) = @_;
+
+ return $s->pwent( )->[7];
+};
+
+sub _build_config {
+ my ( $s ) = @_;
+
+ return Piny::Config->new( confpath => $s->home . "/.gitconfig" );
+};
+
sub _build_email {
my ( $s ) = @_;
- return Piny::Email->new( address => $s->pwent( )->[6] );
+ if ( not defined $s->config->user_email ) {
+ die "You must provide a user.email attribute in your .gitconfig!\nPlease run pinyconfig --user user.email your\@email.com";
+ };
+
+ return Piny::Email->new( address => $s->config->user_email );
};
sub _build_groups {
diff --git a/libpiny/share/ikiwiki.setup b/libpiny/share/ikiwiki.setup
index e6619d4..1128143 100644
--- a/libpiny/share/ikiwiki.setup
+++ b/libpiny/share/ikiwiki.setup
@@ -6,14 +6,14 @@
# Remember to re-run ikiwiki --setup any time you edit this file.
use IkiWiki::Setup::Standard {
- # wikiname => "', # LATER MODIFIED BY LATER MODIFIED BY PINY
- # adminemail => "', # LATER MODIFIED BY LATER MODIFIED BY PINY
- # srcdir => "', # LATER MODIFIED BY PINY
- # destdir => "', # LATER MODIFIED BY PINY
- # url => "', # LATER MODIFIED BY PINY
- # cgiurl => "', # LATER MODIFIED BY PINY
- # historyurl => "', # LATER MODIFIED BY PINY
- # diffurl => "', # LATER MODIFIED BY PINY
+ # wikiname => "', # OVERWRITTEN BY PINY
+ # adminemail => "', # OVERWRITTEN BY PINY
+ # srcdir => "', # OVERWRITTEN BY PINY
+ # destdir => "', # OVERWRITTEN BY PINY
+ # url => "', # OVERWRITTEN BY PINY
+ # cgiurl => "', # OVERWRITTEN BY PINY
+ # historyurl => "', # OVERWRITTEN BY PINY
+ # diffurl => "', # OVERWRITTEN BY PINY
templatedir => "/srv/templates", # TODO: user-customizable templates
underlaydir => "/usr/share/ikiwiki/basewiki",
@@ -54,8 +54,9 @@ use IkiWiki::Setup::Standard {
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 map teximg version edittemplate rawhtml}],
+ add_plugins => [qw{autoindex sidebar toc meta table tag graphviz httpauth img attachment rename remove map teximg version edittemplate rawhtml}],
disable_plugins => [qw{openid passwordauth}],
+
teximg_prefix => "\\documentclass{scrartcl}
\\usepackage[version=3]{mhchem}
\\usepackage{amsmath}
@@ -69,6 +70,11 @@ use IkiWiki::Setup::Standard {
# For use with the tag plugin, make all tags be located under a
# base page.
tagbase => "tag",
+ tag_autocreate => 1,
+
+ # this uses transient.pm, which shows up in Ikiwiki in early 2011
+ tag_autocreate_commit => 0,
+ autoindex_commit => 0,
# For use with the search plugin if your estseek.cgi is located
# somewhere else.