Handle hostnames with upper-case letters
[webmin.git] / apache / remove_vserv.pl
1 #!/usr/local/bin/perl
2 # remove_vserv.pl
3 # Delete an apache virtual server by server name
4
5 @ARGV == 1 || die "usage: remove_vserv.pl <servername>";
6
7 $no_acl_check++;
8 $ENV{'WEBMIN_CONFIG'} = "/etc/webmin";
9 $ENV{'WEBMIN_VAR'} = "/var/webmin";
10 if ($0 =~ /^(.*\/)[^\/]+$/) {
11         chdir($1);
12         }
13 require './apache-lib.pl';
14 $module_name eq 'apache' || die "Command must be run with full path";
15 $conf = &get_config();
16 @virts = &find_directive_struct("VirtualHost", $conf);
17 foreach $v (@virts) {
18         local $sn = &find_directive("ServerName", $v->{'members'});
19         if ($sn eq $ARGV[0]) {
20                 # Found the one to delete ..
21                 &save_directive_struct($v, undef, $conf, $conf);
22                 &flush_file_lines();
23                 print "Delete virtual server from $v->{'file'} at line ",
24                       ($v->{'line'}+1),"\n";
25                 exit;
26                 }
27         }
28 print "Failed to find virtual server\n";
29