forked from webmin/webmin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathview_raid.cgi.bak
executable file
·131 lines (115 loc) · 3.91 KB
/
view_raid.cgi.bak
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/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'}'> \n";
}
else {
print "<input type=submit name=start ",
"value='$text{'view_start'}'> \n";
}
print "<input type=submit name=delete value='$text{'delete'}'> \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'});