Delete .bak files
authorJamie Cameron <jcameron@webmin.com>
Wed, 11 Mar 2009 21:18:30 +0000 (21:18 +0000)
committerJamie Cameron <jcameron@webmin.com>
Wed, 11 Mar 2009 21:18:30 +0000 (21:18 +0000)
raid/raid-lib.pl.bak [deleted file]
raid/view_raid.cgi.bak [deleted file]

diff --git a/raid/raid-lib.pl.bak b/raid/raid-lib.pl.bak
deleted file mode 100644 (file)
index ca36fa3..0000000
+++ /dev/null
@@ -1,198 +0,0 @@
-# raid-lib.pl
-# Functions for managing RAID
-
-do '../web-lib.pl';
-&init_config();
-
-%container = ( 'raiddev', 1,
-              'device', 1 );
-
-# get_raidtab()
-# Parse the raid config file into a list of devices
-sub get_raidtab
-{
-local ($raiddev, $device, %mdstat);
-return \@get_raidtab_cache if (defined(@get_raidtab_cache));
-
-# Read the mdstat file
-open(MDSTAT, $config{'mdstat'});
-while(<MDSTAT>) {
-       if (/^(md\d+)\s*:\s+(\S+)\s+(\S+)\s+(.*)\s+(\d+)\s+blocks.*resync=(\d+)/) {
-               $mdstat{"/dev/$1"} = [ $2, $3, $4, $5, $6 ];
-               }
-       elsif (/^(md\d+)\s*:\s+(\S+)\s+(\S+)\s+(.*)\s+(\d+)\s+blocks/) {
-               $mdstat{"/dev/$1"} = [ $2, $3, $4, $5 ];
-               }
-       elsif (/^(md\d+)\s*:\s+(\S+)\s+(\S+)\s+(.*)/) {
-               $mdstat{"/dev/$1"} = [ $2, $3, $4 ];
-               $_ = <MDSTAT>;
-               if (/\s+(\d+)\s+blocks.*resync=(\d+)/) {
-                       $mdstat{"/dev/$1"}->[3] = $1;
-                       $mdstat{"/dev/$1"}->[4] = $2;
-                       }
-               elsif (/\s+(\d+)\s+blocks/) {
-                       $mdstat{"/dev/$1"}->[3] = $1;
-                       }
-               }
-       }
-close(MDSTAT);
-
-# Read the raidtab file
-local $lnum = 0;
-open(RAID, $config{'raidtab'});
-while(<RAID>) {
-       s/\r|\n//g;
-       s/#.*$//;
-       if (/^\s*(\S+)\s+(\S+)/) {
-               local $dir = { 'name' => lc($1),
-                              'value' => $2,
-                              'line' => $lnum,
-                              'eline' => $lnum };
-               if ($dir->{'name'} =~ /^(raid|spare|parity|failed)-disk$/) {
-                       push(@{$device->{'members'}}, $dir);
-                       $device->{'eline'} = $lnum;
-                       $raiddev->{'eline'} = $lnum;
-                       }
-               elsif ($dir->{'name'} eq 'raiddev') {
-                       $dir->{'index'} = scalar(@get_raidtab_cache);
-                       push(@get_raidtab_cache, $dir);
-                       }
-               else {
-                       push(@{$raiddev->{'members'}}, $dir);
-                       $raiddev->{'eline'} = $lnum;
-                       }
-               if ($dir->{'name'} eq 'device') {
-                       $device = $dir;
-                       }
-               elsif ($dir->{'name'} eq 'raiddev') {
-                       $raiddev = $dir;
-                       local $m = $mdstat{$dir->{'value'}};
-                       $dir->{'active'} = $m->[0] eq 'active';
-                       $dir->{'level'} = $m->[1] =~ /raid(\d+)/ ? $1 : $m->[1];
-                       $dir->{'devices'} = [ map { /(\S+)\[\d+\]/; "/dev/$1" }
-                                                 split(/\s+/, $m->[2]) ];
-                       $dir->{'size'} = $m->[3];
-                       $dir->{'resync'} = $m->[4];
-                       $dir->{'recovery'} = $m->[5];
-                       }
-               }
-       $lnum++;
-       }
-close(RAID);
-return \@get_raidtab_cache;
-}
-
-# create_raid(&raid)
-# Create a new raid set
-sub create_raid
-{
-$lref = &read_file_lines($config{'raidtab'});
-$_[0]->{'line'} = @$lref;
-push(@$lref, &directive_lines($_[0]));
-$_[0]->{'eline'} = @$lref - 1;
-&flush_file_lines();
-}
-
-# delete_raid(&raid)
-# Delete a raid set from the config file
-sub delete_raid
-{
-$lref = &read_file_lines($config{'raidtab'});
-splice(@$lref, $_[0]->{'line'}, $_[0]->{'eline'} - $_[0]->{'line'} + 1);
-&flush_file_lines();
-}
-
-# make_raid(&raid, force)
-# Call mkraid to make a raid set
-sub make_raid
-{
-local $f = $_[1] ? "--really-force" : "";
-local $out = &backquote_logged("mkraid $f $_[0]->{'value'} 2>&1 </dev/null");
-return $? ? &text($out =~ /force/i ? 'eforce' : 'emkraid', "<pre>$out</pre>")
-         : undef;
-}
-
-# activate_raid(&raid)
-# Activate a raid set
-sub activate_raid
-{
-local $out = &backquote_logged("raidstart $_[0]->{'value'} 2>&1");
-&error(&text('eraidstart', "<tt>$out</tt>")) if ($?);
-}
-
-# activate_raid(&raid)
-# Deactivate a raid set
-sub deactivate_raid
-{
-local $out = &backquote_logged("raidstop $_[0]->{'value'} 2>&1");
-&error(&text('eraidstop', "<tt>$out</tt>")) if ($?);
-}
-
-# directive_lines(&directive, indent)
-sub directive_lines
-{
-local @rv = ( "$_[1]$_[0]->{'name'}\t$_[0]->{'value'}" );
-foreach $m (@{$_[0]->{'members'}}) {
-       push(@rv, &directive_lines($m, $_[1]."\t"));
-       }
-return @rv;
-}
-
-# find(name, &array)
-sub find
-{
-local($c, @rv);
-foreach $c (@{$_[1]}) {
-       if ($c->{'name'} eq $_[0]) {
-               push(@rv, $c);
-               }
-       }
-return @rv ? wantarray ? @rv : $rv[0]
-           : wantarray ? () : undef;
-}
-
-# find_value(name, &array)
-sub find_value
-{
-local(@v);
-@v = &find($_[0], $_[1]);
-if (!@v) { return undef; }
-elsif (wantarray) { return map { $_->{'value'} } @v; }
-else { return $v[0]->{'value'}; }
-}
-
-# device_status(device)
-# Returns an array of  directory, type, mounted
-sub device_status
-{
-@mounted = &foreign_call("mount", "list_mounted") if (!@mounted);
-@mounts = &foreign_call("mount", "list_mounts") if (!@mounts);
-local $label = `e2label $_[0] 2>/dev/null`;
-chop($label);
-
-local ($mounted) = grep { &same_file($_->[1], $_[0]) ||
-                         $_->[1] eq "LABEL=$label" } @mounted;
-local ($mount) = grep { &same_file($_->[1], $_[0]) ||
-                       $_->[1] eq "LABEL=$label" } @mounts;
-if ($mounted) { return ($mounted->[0], $mounted->[2], 1,
-                       &indexof($mount, @mounts),
-                       &indexof($mounted, @mounted)); }
-elsif ($mount) { return ($mount->[0], $mount->[2], 0,
-                        &indexof($mount, @mounts)); }
-if (!defined(@physical_volumes)) {
-       @physical_volumes = ();
-       foreach $vg (&foreign_call("lvm", "list_volume_groups")) {
-               push(@physical_volumes,
-                       &foreign_call("lvm", "list_physical_volumes",
-                                            $vg->{'name'}));
-               }
-       }
-foreach $pv (@physical_volumes) {
-       return ( $pv->{'vg'}, "lvm", 1)
-               if ($pv->{'device'} eq $_[0]);
-       }
-return ();
-}
-
-1;
-
diff --git a/raid/view_raid.cgi.bak b/raid/view_raid.cgi.bak
deleted file mode 100755 (executable)
index 8190930..0000000
+++ /dev/null
@@ -1,131 +0,0 @@
-#!/usr/local/bin/perl
-# view_raid.cgi
-# Display information about a raid device
-
-require './raid-lib.pl';
-&foreign_require("mount", "mount-lib.pl");
-&foreign_require("lvm", "lvm-lib.pl");
-&ReadParse();
-
-&header($text{'view_title'}, "");
-$conf = &get_raidtab();
-$raid = $conf->[$in{'idx'}];
-print "<hr>\n";
-
-print "<form action=save_raid.cgi>\n";
-print "<input type=hidden name=idx value='$in{'idx'}'>\n";
-print "<table border>\n";
-print "<tr $tb> <td><b>$text{'view_header'}</b></td> </tr>\n";
-print "<tr $cb> <td><table>\n";
-
-print "<tr> <td><b>$text{'view_device'}</b></td>\n";
-print "<td><tt>$raid->{'value'}</tt></td> </tr>\n";
-
-$lvl = &find_value('raid-level', $raid->{'members'});
-print "<tr> <td><b>$text{'view_level'}</b></td>\n";
-print "<td>",$lvl eq 'linear' ? $text{'linear'}
-                             : $text{"raid$lvl"},"</td> </tr>\n";
-
-@st = &device_status($raid->{'value'});
-print "<tr> <td><b>$text{'view_status'}</b></td> <td>\n";
-print $st[1] eq 'lvm' ? &text('view_lvm', "<tt>$st[0]</tt>") :
-      $st[2] ? &text('view_mounted', "<tt>$st[0]</tt>") :
-      @st ? &text('view_mount', "<tt>$st[0]</tt>") :
-      $raid->{'active'} ? $text{'view_active'} :
-                         $text{'view_inactive'};
-print "</td> </tr>\n";
-
-if ($raid->{'size'}) {
-       print "<tr> <td><b>$text{'view_size'}</b></td>\n";
-       print "<td>$raid->{'size'} blocks</td> </tr>\n";
-       }
-if ($raid->{'resync'}) {
-       print "<tr> <td><b>$text{'view_resync'}</b></td>\n";
-       print "<td>$raid->{'resync'} \%</td> </tr>\n";
-       }
-
-$super = &find_value('persistent-superblock', $raid->{'members'});
-print "<tr> <td><b>$text{'view_super'}</b></td>\n";
-print "<td>",$super ? $text{'yes'} : $text{'no'},"</td> </tr>\n";
-
-if ($lvl eq '5') {
-       $parity = &find_value('parity-algorithm', $raid->{'members'});
-       print "<tr> <td><b>$text{'view_parity'}</b></td>\n";
-       print "<td>",$parity ? $parity : $text{'default'},"</td> </tr>\n";
-       }
-
-$chunk = &find_value('chunk-size', $raid->{'members'});
-print "<tr> <td><b>$text{'view_chunk'}</b></td>\n";
-print "<td>$chunk kB</td> </tr>\n";
-
-# Display partitions in RAID
-print "<tr> <td valign=top><b>$text{'view_disks'}</b></td> <td>\n";
-foreach $d (&find('device', $raid->{'members'})) {
-       if (&find('raid-disk', $d->{'members'}) ||
-            &find('parity-disk', $d->{'members'})) {
-               local $name = &mount::device_name($d->{'value'});
-               print $name,"\n";
-               if (&indexof($d->{'value'}, @{$raid->{'devices'}}) < 0 &&
-                   $raid->{'active'}) {
-                       print "<font color=#ff0000>$text{'view_down'}</font>\n";
-                       }
-               print "<br>\n";
-               }
-       }
-print "</td> </tr>\n";
-
-# Display spare partitions
-foreach $d (&find('device', $raid->{'members'})) {
-       if (&find('spare-disk', $d->{'members'})) {
-               if ($d->{'value'} =~ /(h|s)d(\S+)(\d+)$/) {
-                       $sp .= &text('select_part', $1 eq 'h' ? 'IDE' : 'SCSI',
-                                   uc($2), "$3")."<br>\n";
-                       }
-               else {
-                       $sp .= $d->{'value'}."<br>\n";
-                       }
-               }
-       }
-if ($sp) {
-       print "<tr> <td valign=top><b>$text{'view_spares'}</b></td> <td>\n";
-       print $sp,"</td> </tr>\n";
-       }
-
-print "</table></td></tr></table>\n";
-
-if ($st[2]) {
-       print "<br><b>$text{'view_cannot'}</b> <p>\n";
-       }
-else {
-       if ($raid->{'active'}) {
-               print "<input type=submit name=stop ",
-                     "value='$text{'view_stop'}'>&nbsp;\n";
-               }
-       else {
-               print "<input type=submit name=start ",
-                     "value='$text{'view_start'}'>&nbsp;\n";
-               }
-       print "<input type=submit name=delete value='$text{'delete'}'>&nbsp;\n";
-       if ($raid->{'active'}) {
-               # Show buttons for creating filesystems
-               &foreign_require("fdisk", "fdisk-lib.pl");
-               print "<p><hr>\n";
-               print "<table width=100%><tr>\n";
-               print "<td><input type=submit name=mkfs ",
-                     "value='$text{'view_mkfs2'}'>\n";
-               print "<select name=fs>\n";
-               foreach $f (&fdisk::supported_filesystems()) {
-                       printf "<option value=%s %s>%s (%s)\n",
-                               $f, $stat[1] eq $f ? "selected" : "",
-                               $fdisk::text{"fs_$f"}, $f;
-                       }
-               print "</select></td>\n";
-               print "<td>$text{'view_mkfsdesc'}</td>\n";
-               print "</tr></table>\n";
-               }
-       }
-print "</form>\n";
-
-print "<hr>\n";
-&footer("", $text{'index_return'});
-