[Bps-public-commit] r16303 - in Pushmi/trunk: . Pushmi-Admin/etc Pushmi-Admin/lib/Pushmi/Admin Pushmi-Admin/lib/Pushmi/Admin/Action

alexmv at bestpractical.com alexmv at bestpractical.com
Wed Oct 15 14:34:16 EDT 2008


Author: alexmv
Date: Wed Oct 15 14:34:13 2008
New Revision: 16303

Modified:
   Pushmi/trunk/   (props changed)
   Pushmi/trunk/Pushmi-Admin/etc/config.yml
   Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin.pm
   Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Action/Configure.pm
   Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Dispatcher.pm
   Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/View.pm

Log:
 r38194 at kohr-ah:  chmrr | 2008-10-15 14:34:06 -0400
  * Don't provide undef as arguments which get overriden with
    arrayrefs, or the arrayrefs end up with undefs at the start
  * Write out new apache index as part of configure
  * Use Pushmi::Admin->admin_uri instead of Jifty-web->url because the
    latter tries to be smart about the hostname (explicitly _not_ what
    we want!) and it gives us a chance to override the port.
  * 'configured' may not be -x if it has spaces in it
  * Change double-dots to real ellipses
  * Add configuration link to apache dev index


Modified: Pushmi/trunk/Pushmi-Admin/etc/config.yml
==============================================================================
--- Pushmi/trunk/Pushmi-Admin/etc/config.yml	(original)
+++ Pushmi/trunk/Pushmi-Admin/etc/config.yml	Wed Oct 15 14:34:13 2008
@@ -59,8 +59,6 @@
   time_zone: EST
   data_root: %var/data%
   pushmi_bin: /usr/bin/pushmi
-  configured: ~
-  htpasswd: ~
   apache:
     root: http://localhost/
     document_root: ~

Modified: Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin.pm
==============================================================================
--- Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin.pm	(original)
+++ Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin.pm	Wed Oct 15 14:34:13 2008
@@ -106,6 +106,7 @@
 
 sub update_apache {
     my $class = shift;
+    my %args = (restart => 1, @_);
 
     my $apache_version = '2.2'; # XXX: detect 2.0
 
@@ -144,9 +145,12 @@
 EOT
         print INDEX qq{    <li><a href="/@{[$_->dav_root]}">@{[$_->name]}</a></li>\n}
             for @{$replicas->items_array_ref};
-        print INDEX <<EOT;
+        print INDEX <<"EOT";
    </ul>
   </div>
+  <div id="configuration">
+    <a href="@{[Pushmi::Admin->admin_uri]}">Configuration...</a>
+  </div>
  </div>
 </body>
 </html>
@@ -166,7 +170,16 @@
     }
 
     my $hup = Jifty->config->app("apache")->{bin};
-    system("$hup restart >/dev/null");
+    if ($args{restart} and $hup) {
+	system("$hup restart >/dev/null");
+    }
+}
+
+sub admin_uri {
+    my $self = shift;
+    my $uri = URI->new(Jifty->config->framework("Web")->{BaseURL});
+    $uri->port(Jifty->config->app("proxy") || Jifty->config->framework("Web")->{Port});
+    return $uri->canonical->as_string;
 }
 
 1;

Modified: Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Action/Configure.pm
==============================================================================
--- Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Action/Configure.pm	(original)
+++ Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Action/Configure.pm	Wed Oct 15 14:34:13 2008
@@ -47,11 +47,12 @@
 
     Jifty->config(Jifty::Config->new); # Reload the config;
 
+    # Write out a new apache index with the new hostname
+    Pushmi::Admin->update_apache(restart => 0);
+
     # Write a new .htpasswd if we know where it lives
     if ($self->argument_value("password") and Jifty->config->app("htpasswd")) {
-        my @htpasswd = Jifty->config->app("htpasswd");
-        @htpasswd = @{$htpasswd[0]} if ref $htpasswd[0] and @htpasswd == 1;
-        system(@htpasswd, $self->argument_value("password"));
+        system(@{Jifty->config->app("htpasswd")}, $self->argument_value("password"));
     }
 }
 

Modified: Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Dispatcher.pm
==============================================================================
--- Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Dispatcher.pm	(original)
+++ Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Dispatcher.pm	Wed Oct 15 14:34:13 2008
@@ -27,19 +27,19 @@
     my $root = URI->new(Jifty->config->app('apache')->{root});
     return if $root->host eq "localhost";
     # If we're configured now, redirect to the internal URL
-    redirect Jifty->web->url;
-}
+    Jifty->web->_redirect(Pushmi::Admin->admin_uri);
+};
 after '/firstrun' => run {
     my $root = URI->new(Jifty->config->app('apache')->{root});
     return if $root->host eq "localhost";
     return unless Jifty->config->app('configured');
-    return unless -x Jifty->config->app('configured');
+    return unless Jifty->config->app('configured') =~ / /
+	or -x Jifty->config->app('configured');
     # Once we're configured, call the configuration executable
-    warn "Going to run 'configured' callback: ".Jifty->config->app('configured');
     if (fork) {
         exec(Jifty->config->app('configured')) or die "Configured call failed: $@";
     }
-}
+};
 
 # Redirect to the created replica
 on '/created' => run {

Modified: Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/View.pm
==============================================================================
--- Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/View.pm	(original)
+++ Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/View.pm	Wed Oct 15 14:34:13 2008
@@ -88,7 +88,7 @@
         { id is 'configuration' }
         hyperlink(
             url   => "/configuration",
-            label => "Configuration.."
+            label => "Configuration..."
         );
     }
 };
@@ -406,7 +406,7 @@
         { id is 'advanced' }
         hyperlink(
             url   => "/advanced/" . $replica->clean_name,
-            label => "Advanced.."
+            label => "Advanced..."
         );
     }
 };



More information about the Bps-public-commit mailing list