]> git.mjollnir.org Git - vserverctl.git/commitdiff
Fixed problem where template files were being moved to a place but with an incorrect...
authorNigel McNie <nigel@catalyst.net.nz>
Tue, 3 Apr 2007 12:47:31 +0000 (00:47 +1200)
committerNigel McNie <nigel@freud.wgtn.cat-it.co.nz>
Tue, 3 Apr 2007 12:47:31 +0000 (00:47 +1200)
Allowed extramodules=modulename to work, allowing you to make a profile that contains extra stuff to run as well as whatever profile you're basing the vserver off of. Only supports one name at the moment, easy enough to change to support a comma separated list.

The other thing I'd want to do is move them to modules/* instead of having them in the base directory. Alternatively, they could stay, and with a profile.conf could become configurations for new vservers themselves. Something to discuss.

vserverctl

index b9b41338d989ea5d693457f3713273809c1a61c6..467c2a3642fe3ac503bd01dae262a8ec59f7091e 100755 (executable)
@@ -128,6 +128,10 @@ if ( $action eq 'add' ) {
     my %templates = split(/\s+/ms, $config->{files}{templates});
     foreach my $key ( keys %templates ) {
         print "TEMPLATE: '$key' => '${vsroot}$templates{$key}'\n";
+
+        my $filename = '';
+        $filename = '/' . basename($key) if ( -d ${vsroot} . $templates{$key});
+
         my $data = slurp($key);
         $data =~ s/__VSNAME__/$vsname/g;
         $data =~ s/__VSIPADDR__/$ipaddr/g;
@@ -137,7 +141,7 @@ if ( $action eq 'add' ) {
             $data =~ s/__PROFILEOPTION_${key}__/$value/g;
         }
         write_file($vsroot . '.template', $data);
-        system('mv', $vsroot . '.template', $vsroot . $templates{$key});
+        system('mv', $vsroot . '.template', $vsroot . $templates{$key} . $filename);
     }
 
     open $scriptFH, '|-', 'vserver', $vsname, 'exec', '/bin/bash';
@@ -187,6 +191,11 @@ sub readConfig { # {{{
     }
     unshift @{$config}, $defaultConfig;
 
+    if ( defined $profileOptions->{extramodules} ) {
+        $cfg = { name => $profileOptions->{extramodules} };
+        push @{$config}, $cfg;
+    }
+
     my $generatedConfig = {};
 
     foreach my $cfg ( @{$config} ) {