Re: [webmin-devel] Integrate with Apache module?

Chris Wik <[email protected]> Wed, 03 Mar 2010 01:04:25 +0100
Newsgroups gmane.comp.web.webmin.devel
Message-ID <[email protected]>
On 02.03.10 22:03, Jamie Cameron wrote:
> Yes, absolutely - you can use code like this :
> 
> foreign_require("apache");
> $conf = apache::get_config();
> @vhosts = apache::find_directive_struct("VirtualHost", $conf);
> foreach $v (@vhosts) {
>   $sn = apache::find_directive("ServerName", $v->{'members'});
>   if ($sn eq "whatever.com") {
>     @includes = apache::find_directive("Include", $v->{'members'});
>     push(@includes, "/path/to/file.lasso");
>     apache::save_directive("Include", \@includes, $v->{'members'}, $conf);
>     flush_file_lines($v->{'file'});
>     }
>   }

I'm stuck, hopefully something stupid you can easily spot..

I'm getting 'Failed to save Site : flush_file_lines called on non-loaded
file /etc/httpd/conf.d/ssl.conf' when running:


sub update_apache_vhosts {
	my ($site) = @_;
	my $conf_path	= $site->{'directory'} . '/lasso/fastcgi.conf';
	
	# servernames from ui_select (multiple) on edit form
	my @servernames	= split(/\0/, $site->{'servername'});
	
	foreach $servername(@servernames) {
		foreign_require("apache");
		$conf = apache::get_config();
		@vhosts = apache::find_directive_struct("VirtualHost", $conf);
		foreach $v (@vhosts) {
			$sn = apache::find_directive("ServerName", $v->{'members'});
			@includes = apache::find_directive("Include", $v->{'members'});
			if ($sn eq $servername) {
				push(@includes, $conf_path);
			} else {
				delete $includes[$conf_path];
			}
			apache::save_directive("Include", \@includes, $v->{'members'}, $conf);
			flush_file_lines($v->{'file'});
		}
	}
}

Any ideas?

Thanks

-- 
Chris Wik
Anu Internet Services Ltd

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
-
Forwarded by the Webmin development list at [email protected]
To remove yourself from this list, go to
http://lists.sourceforge.net/lists/listinfo/webadmin-devel