Changeset 1223


Ignore:
Timestamp:
Mar 3, 2007, 9:19:16 AM (12 years ago)
Author:
bruno
Message:

Much more advanced version

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/stable/mondo-web/mondo-web.pl

    r1222 r1223  
    2929#print Dumper($cfgfile);
    3030
     31my $command="";
     32
    3133# Fake it for now
    3234my %media = (
    33         "CD" => "CD-R",
     35        "CDR" => "CD-R",
    3436        "CDRW" => "CD-RW",
    3537        "DVD" => "DVD+/-R/RW",
     
    4244my @media = sort keys %media;
    4345my %options = (
    44         'FLOPPY' => 'Boot floppy production',
     46        'NOFLOPPY' => 'No Boot floppy production',
     47        'NOBOOTABLE' => 'Create Non-Bootable media',
    4548        'AUTO', => 'Auto Restore Mode',
    4649        'NFSEXCL' => 'Exclude Network File Systems',
     
    6770);
    6871my @comp = sort keys %comp;
    69 my %compsize = (
     72my %ratio = (
    7073        0 => '0',
    7174        1 => '1',
     
    7982        9 => '9',
    8083);
    81 my @compsize = sort {$a <=> $b} keys %compsize;
     84my @ratio = sort {$a <=> $b} keys %ratio;
    8285my %boot = (
    83         'LILO' => "LILO (ELILO for ia64)",
     86        'LILO' => "LILO",
    8487        'GRUB' => "GRUB",
     88        'ELILO' => "ELILO (ia64)",
     89        'RAW' => "RAW",
    8590        'NATIVE' => "Autodetected",
    8691);
     
    125130            -labels=>\%comp);
    126131    print "</TD><TD WIDTH=300>\n";
    127     print "Compression ratio: ",$cgi->popup_menu(-name=>'compsize',
    128             -values=>\@compsize,
     132    print "Compression ratio: ",$cgi->popup_menu(-name=>'compratio',
     133            -values=>\@ratio,
    129134            -default=>6,
    130             -labels=>\%compsize);
     135            -labels=>\%ratio);
    131136    print "</TD></TR></TABLE>\n";
    132137    print $cgi->hr;
     
    136141    print $cgi->checkbox_group(-name=>'options',
    137142            -values=>\@options,
    138             -defaults=>['NFSEXCL'],
     143            -defaults=>['NFSEXCL', 'NOFLOPPY'],
    139144            -linebreak=>'true',
    140145            -labels=>\%options);
     
    181186                -maxlenght=>150);
    182187    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>";
    183194    print "</TD></TR>\n";
    184195    print "<TR><TD>\n";
     
    188199            -linebreak=>'true',
    189200            -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);
    190207    print "</TD><TD>\n";
    191208    print "Excluded directories:\n";
     
    218235    print $cgi->end_form;
    219236} 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 {
    235240    }
    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/);
    238250    }
    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>";
    249281    print "Please wait till it's done ...";
    250282    print $cgi->end_form;
     
    253285    # Now doing the job ...
    254286    #
    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");
    269288    }
Note: See TracChangeset for help on using the changeset viewer.