From: Nigel McNie Date: Tue, 3 Apr 2007 12:47:31 +0000 (+1200) Subject: Fixed problem where template files were being moved to a place but with an incorrect... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=c60abaee29cc9498d0bf3130328204c24efe6b2e;p=vserverctl.git Fixed problem where template files were being moved to a place but with an incorrect name (.template). 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. --- diff --git a/vserverctl b/vserverctl index b9b4133..467c2a3 100755 --- a/vserverctl +++ b/vserverctl @@ -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} ) {