summaryrefslogtreecommitdiff
path: root/pinyadmin/sbin/pinyconfig
diff options
context:
space:
mode:
authorjrayhawk+piny.be@omgwallhack.org <jrayhawk+piny.be@omgwallhack.org>2012-08-30 23:39:06 -0700
committerjrayhawk+piny.be@omgwallhack.org <jrayhawk+piny.be@omgwallhack.org>2012-08-30 23:39:06 -0700
commit32ae3bd0c9aa956302e5015b0d459cdac1239ece (patch)
tree2bd989ce1f147cde38727baee3fb9a56588169d6 /pinyadmin/sbin/pinyconfig
parent6bd82e8bb3aded8fa697b8ffe30bcf7ec3ab39c4 (diff)
downloadpiny-code-32ae3bd0c9aa956302e5015b0d459cdac1239ece.tar.gz
piny-code-32ae3bd0c9aa956302e5015b0d459cdac1239ece.zip
pinyconfig: adding 'rebuild unless told not to' logic
Diffstat (limited to 'pinyadmin/sbin/pinyconfig')
-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 $@;