Handle hostnames with upper-case letters
[webmin.git] / webmin / export_mod.cgi
1 #!/usr/local/bin/perl
2 # Create and output a wbm.gz file of selected modules
3
4 require './webmin-lib.pl';
5 &ReadParse();
6 &error_setup($text{'export_err'});
7 @mods = split(/\0/, $in{'mod'});
8 @mods || &error($text{'delete_enone'});
9
10 # Make sure we have the needed commands
11 &has_command("tar") || &error(&text('export_ecmd', "<tt>tar</tt>"));
12 &has_command("gzip") || &error(&text('export_ecmd', "<tt>gzip</tt>"));
13 $in{'to'} == 0 || $in{'file'} =~ /^\// || &error($text{'export_efile'});
14
15 # Make the tar.gz file
16 $temp = $in{'to'} ? $in{'file'} : &transname();
17 chdir(&module_root_directory($mods[0])."/..");
18 $cmd = "tar chf -";
19 foreach $m (@mods) {
20         $cmd .= " $m";
21         }
22 $cmd .= " | gzip -c >".quotemeta($temp);
23 $out = &backquote_logged("($cmd) 2>&1 </dev/null");
24 $? && &error("<pre>$out</pre>");
25
26 if ($in{'to'} == 0) {
27         # Output the file
28         print "Content-type: application/octet-stream\n\n";
29         open(TEMP, $temp);
30         while(<TEMP>) {
31                 print $_;
32                 }
33         close(TEMP);
34         unlink($temp);
35         }
36 else {
37         # Tell the user
38         &ui_print_header(undef, $text{'export_title'}, "");
39
40         print &text('export_done', "<tt>$in{'file'}</tt>"),"<p>\n";
41
42         &ui_print_footer("/$module_name/edit_mods.cgi", $text{'mods_return'},
43                          "", $text{'index_return'});
44         }
45
46