forked from webmin/webmin
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathindex.cgi
executable file
·88 lines (81 loc) · 2.58 KB
/
index.cgi
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
#!/usr/local/bin/perl
# index.cgi
# Display a list of known disks and partitions
require './fdisk-lib.pl';
&error_setup($text{'index_err'});
&check_fdisk();
# Work out which disks are accessible
@disks = &list_disks_partitions();
@disks = grep { $access{'view'} || &can_edit_disk($_->{'device'}) } @disks;
if (@disks == 1 && &can_edit_disk($disks[0]->{'device'})) {
# Just one .. go direct to it's page
&redirect("edit_disk.cgi?device=$disks[0]->{'device'}");
edit;
}
$pdesc = $has_parted ? $text{'index_parted'} : $text{'index_fdisk'};
&ui_print_header($pdesc, $module_info{'desc'}, "", undef, 1, 1, 0,
&help_search_link("fdisk", "man", "doc", "howto"));
$extwidth = 250;
# Check for critical commands
if ($has_parted) {
&has_command("parted") ||
&ui_print_endpage(&text('index_ecmd', '<tt>parted</tt>'));
}
else {
&has_command("fdisk") ||
&ui_print_endpage(&text('index_ecmd', '<tt>fdisk</tt>'));
}
# Show a table of just disks
@disks = sort { $a->{'device'} cmp $b->{'device'} } @disks;
if (@disks) {
($hasctrl) = grep { defined($d->{'scsiid'}) ||
defined($d->{'controller'}) ||
$d->{'raid'} } @disks;
print &ui_columns_start([ $text{'index_dname'},
$text{'index_dsize'},
$text{'index_dmodel'},
$text{'index_dparts'},
$hasctrl ? ( $text{'index_dctrl'} ) : ( ),
$text{'index_dacts'} ]);
foreach $d (@disks) {
$ed = &can_edit_disk($d->{'device'});
$smart = &supports_smart($d);
@links = ( );
@ctrl = ( );
if (defined($d->{'scsiid'}) && defined($d->{'controller'})) {
push(@ctrl, &text('index_dscsi', $d->{'scsiid'},
$d->{'controller'}));
}
if ($d->{'raid'}) {
push(@ctrl, &text('index_draid', $d->{'raid'}));
}
if ($ed && &supports_hdparm($d)) {
# Display link to IDE params form
push(@links, "<a href='edit_hdparm.cgi?".
"disk=$d->{'index'}'>$text{'index_dhdparm'}</a>");
}
if (&supports_smart($d)) {
# Display link to smart module
push(@links, "<a href='../smart-status/index.cgi?".
"drive=$d->{'device'}:'>$text{'index_dsmart'}</a>");
}
if ($ed) {
push(@links, "<a href='blink.cgi?".
"disk=$d->{'index'}'>$text{'index_blink'}</a>");
}
print &ui_columns_row([
$ed ? &ui_link("edit_disk.cgi?device=$d->{'device'}",$d->{'desc'})
: $d->{'desc'},
$d->{'size'} ? &nice_size($d->{'size'}) : "",
$d->{'model'},
scalar(@{$d->{'parts'}}),
$hasctrl ? ( join(" ", @ctrl) ) : ( ),
&ui_links_row(\@links),
]);
}
print &ui_columns_end();
}
else {
print "<b>$text{'index_none2'}</b><p>\n";
}
&ui_print_footer("/", $text{'index'});