Changeset 1223 in MondoRescue
- Timestamp:
- Mar 3, 2007, 9:19:16 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/mondo-web/mondo-web.pl
r1222 r1223 29 29 #print Dumper($cfgfile); 30 30 31 my $command=""; 32 31 33 # Fake it for now 32 34 my %media = ( 33 "CD " => "CD-R",35 "CDR" => "CD-R", 34 36 "CDRW" => "CD-RW", 35 37 "DVD" => "DVD+/-R/RW", … … 42 44 my @media = sort keys %media; 43 45 my %options = ( 44 'FLOPPY' => 'Boot floppy production', 46 'NOFLOPPY' => 'No Boot floppy production', 47 'NOBOOTABLE' => 'Create Non-Bootable media', 45 48 'AUTO', => 'Auto Restore Mode', 46 49 'NFSEXCL' => 'Exclude Network File Systems', … … 67 70 ); 68 71 my @comp = sort keys %comp; 69 my % compsize= (72 my %ratio = ( 70 73 0 => '0', 71 74 1 => '1', … … 79 82 9 => '9', 80 83 ); 81 my @ compsize = sort {$a <=> $b} keys %compsize;84 my @ratio = sort {$a <=> $b} keys %ratio; 82 85 my %boot = ( 83 'LILO' => "LILO (ELILO for ia64)",86 'LILO' => "LILO", 84 87 'GRUB' => "GRUB", 88 'ELILO' => "ELILO (ia64)", 89 'RAW' => "RAW", 85 90 'NATIVE' => "Autodetected", 86 91 ); … … 125 130 -labels=>\%comp); 126 131 print "</TD><TD WIDTH=300>\n"; 127 print "Compression ratio: ",$cgi->popup_menu(-name=>'comp size',128 -values=>\@ compsize,132 print "Compression ratio: ",$cgi->popup_menu(-name=>'compratio', 133 -values=>\@ratio, 129 134 -default=>6, 130 -labels=>\% compsize);135 -labels=>\%ratio); 131 136 print "</TD></TR></TABLE>\n"; 132 137 print $cgi->hr; … … 136 141 print $cgi->checkbox_group(-name=>'options', 137 142 -values=>\@options, 138 -defaults=>['NFSEXCL' ],143 -defaults=>['NFSEXCL', 'NOFLOPPY'], 139 144 -linebreak=>'true', 140 145 -labels=>\%options); … … 181 186 -maxlenght=>150); 182 187 print "<BR>"; 188 print "NFS (server:export):\n"; 189 print $cgi->textfield(-name=>'nfs', 190 -default=>'', 191 -size=>30, 192 -maxlenght=>150); 193 print "<BR>"; 183 194 print "</TD></TR>\n"; 184 195 print "<TR><TD>\n"; … … 188 199 -linebreak=>'true', 189 200 -labels=>\%boot); 201 print "<BR>"; 202 print "Debug:\n"; 203 print $cgi->popup_menu(-name=>'debug', 204 -values=>\@ratio, 205 -default=>2, 206 -labels=>\%ratio); 190 207 print "</TD><TD>\n"; 191 208 print "Excluded directories:\n"; … … 218 235 print $cgi->end_form; 219 236 } else { 220 print $cgi->h2('You made the following choices :'); 221 print $cgi->hr; 222 print "<BOLD>Mandatory options </BOLD> - "; 223 print "Language : <em>",$cgi->param('language'),", </em>"; 224 print "Keyboard : <em>",$cgi->param('keyboard'),", </em>"; 225 print "Timezone : <em>",$cgi->param('timezone'),"</em>"; 226 print $cgi->hr; 227 print "<BOLD>Network</BOLD> configuration mode "; 228 if ($cgi->param('mode') eq 'STATIC') { 229 print "<em>static</em><P>"; 230 print "Name : <em>",$cgi->param('name'),"</em><P>"; 231 print "IP address : <em>",$cgi->param('address'),", </em>"; 232 print "Netmask : <em>",$cgi->param('netmask'),"</em><P>"; 233 print "Gateway : <em>",$cgi->param('gateway'),", </em>"; 234 print "DNS server : <em>",$cgi->param('dns'),", </em>"; 237 $command="mondoarchive -O -K ".$cgi->param('debug')." "; 238 if ($cgi->param('debug') eq 'STATIC') { 239 } else { 235 240 } 236 else { 237 print "<em>dynamic (DHCP)</em>" 241 foreach my $s ($cgi->param('options')) { 242 $command .= "-F " if ($s =~ /NOFLOPPY/); 243 $command .= "-W " if ($s =~ /NOBOOTABLE/); 244 $command .= "-H " if ($s =~ /AUTO/); 245 $command .= "-N " if ($s =~ /NFSEXCL/); 246 $command .= "-m " if ($s =~ /MANEJECT/); 247 $command .= "-D " if ($s =~ /DIFF/); 248 $command .= "-V " if ($s =~ /VERIF/); 249 $command .= "-z " if ($s =~ /XATTR/); 238 250 } 239 print $cgi->hr; 240 print "<BOLD>Services</BOLD> activated at boot time : "; 241 foreach my $s ($cgi->param('options')) { 242 print "- <em>FTP server</em> -" if ( $s =~ /FTP/); 243 print "- <em>Web server</em> -" if ($s =~ /WWW/); 244 print "- <em>DNS server</em> -" if ($s =~ /DNS/); 245 print "- <em>Proxy/Cache server</em> -" if ($s =~ /SQUID/); 246 } 247 print $cgi->hr; 248 print "Your customization parameters are now being commited to the server which will then reboot to ensure a proper environement.<P>"; 251 my $speed = $cgi->param('speed'); 252 $command .= "-c $speed " if ($cgi->param('media') =~ /^CDR$/); 253 $command .= "-w $speed " if ($cgi->param('media') =~ /^CDRW$/); 254 $command .= "-n ".$cgi->param('nfs')." " if (($cgi->param('media') =~ /NFS/) && ($cgi->param('nfs') ne "")); 255 $command .= "-r " if ($cgi->param('media') =~ /DVD/); 256 $command .= "-i " if ($cgi->param('media') =~ /ISO/); 257 $command .= "-U " if ($cgi->param('media') =~ /USB/); 258 $command .= "-t " if ($cgi->param('media') =~ /TAPE/); 259 $command .= "-b ".$cgi->param('block')." " if (($cgi->param('media') =~ /TAPE/) && ($cgi->param('block') ne "")); 260 $command .= "-u " if ($cgi->param('media') =~ /STREAM/); 261 $command .= "-L " if ($cgi->param('comp') =~ /LZO/); 262 $command .= "-G " if ($cgi->param('comp') =~ /GZIP/); 263 $command .= "-E \"".$cgi->param('exclude')."\" " if ($cgi->param('exclude') ne ""); 264 $command .= "-I \"".$cgi->param('include')."\" " if ($cgi->param('include') ne ""); 265 $command .= "-T ".$cgi->param('temp')." " if ($cgi->param('temp') ne ""); 266 $command .= "-S ".$cgi->param('scratch')." " if ($cgi->param('scratch') ne ""); 267 $command .= "-B ".$cgi->param('before')." " if ($cgi->param('before') ne ""); 268 $command .= "-A ".$cgi->param('after')." " if ($cgi->param('after') ne ""); 269 $command .= "-p ".$cgi->param('prefix')." " if ($cgi->param('prefix') ne ""); 270 $command .= "-P ".$cgi->param('postnuke')." " if ($cgi->param('postnuke') ne ""); 271 $command .= "-l ".$cgi->param('boot')." " if ($cgi->param('boot') ne 'NATIVE'); 272 $command .= "-k ".$cgi->param('kernel')." " if (($cgi->param('kernel') ne "") && ($cgi->param('kernel') ne 'NATIVE')); 273 $command .= "-d ".$cgi->param('dest')." -s ".$cgi->param('size')." -".$cgi->param('compratio')." "; 274 275 print $cgi->h2('Here is the mondoarchive command generated:'); 276 print $cgi->hr; 277 print $command; 278 279 print $cgi->hr; 280 print "That mondoarchive is now being commited to the server which launch the disaster recovery procedure.<P>"; 249 281 print "Please wait till it's done ..."; 250 282 print $cgi->end_form; … … 253 285 # Now doing the job ... 254 286 # 255 256 my $genbin = "/tmp"; 257 open(T,"> $genbin/populate") || die "Unable to open $genbin/populate"; 258 print T "#!/bin/sh\n"; 259 print T "#\n"; 260 261 foreach my $s ($cgi->param('services')) { 262 print T "/sbin/chkconfig --level 345 named on\n" if ($s =~ /DNS/); 263 print T "/sbin/chkconfig --level 345 httpd on\n" if ($s =~ /WWW/); 264 print T "/sbin/chkconfig --level 345 squid on\n" if ($s =~ /SQUID/); 265 } 266 close(T); 267 chmod 0755,"$genbin/populate"; 268 system("sudo $genbin/populate"); 287 #system("sudo $command"); 269 288 }
Note:
See TracChangeset
for help on using the changeset viewer.