summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xpinyadmin/sbin/pinyconfig37
1 files changed, 33 insertions, 4 deletions
diff --git a/pinyadmin/sbin/pinyconfig b/pinyadmin/sbin/pinyconfig
index 039d6b4..233bc5c 100755
--- a/pinyadmin/sbin/pinyconfig
+++ b/pinyadmin/sbin/pinyconfig
@@ -5,19 +5,45 @@ use warnings;
use Piny;
+use Getopt::Long qw(:config bundling auto_abbrev);
+
+my ( $fast, $user, $help ) = ( 0, 0, 0 );
+
+GetOptions (
+ "fast" => \$fast,
+ "user" => \$user,
+ "help" => \$help
+);
+
my ( $reponame, $attr, $value ) = @ARGV;
-if ( not defined $reponame ) {
- die "Usage: $0 reponame|--user [tweakable [value]]\n";
+sub usage {
+ print <<EOF;
+Usage: $0 [--fast] <reponame|--user> [attribute] [value]
+Summary of options:
+ --fast, -f Skip rebuild
+ --user, -u Configure user
+EOF
+
+ exit ( 1 );
+};
+
+if ( $help ) {
+ &usage;
};
my $repo;
my $config;
my $env = Piny::Environment->instance( );
-if ( $reponame eq "--user" ) {
+if ( $user ) {
+ ( $attr, $value ) = @ARGV;
$config = $env->user->config;
} else {
+ ( $reponame, $attr, $value ) = @ARGV;
+ if ( not defined $reponame ) {
+ &usage;
+ };
$repo = Piny::Repo->new( $reponame );
$config = $repo->config;
};
@@ -41,7 +67,7 @@ if ( not defined $attr ) {
$attr =~ s/\./_/g;
if ( defined $value ) {
- unless ( $env->user->uid == 0 or $reponame eq "--user" or $repo->owner->uid == $env->user->uid ) {
+ unless ( $env->user->uid == 0 or $user or $repo->owner->uid == $env->user->uid ) {
print "You are not the owner of that repo!\n";
exit( 3 );
};
@@ -58,6 +84,9 @@ if ( not defined $attr ) {
print STDERR "Failed to set $attr (perhaps an override is in place)\n";
exit( 5 );
};
+ if ( $attr =~ /sharedrepository|ikiwiki/i and not $user ) { # FIXME: define in Config.pm instead of here
+ $repo->rebuild;
+ };
};
undef $@;