2 # Display all RAID devices
4 require './raid-lib.pl';
6 # Check if raid is installed
7 if (!-r $config{'mdstat'}) {
8 &error_exit(&text('index_emdstat', "<tt>$config{'mdstat'}</tt>"));
10 if (&has_command("mdadm")) {
11 # Using mdadm commands
13 $raid_ver = &get_mdadm_version();
15 elsif (&has_command('mkraid') && &has_command('raidstart')) {
16 # Using raid tools commands
17 $raid_mode = "raidtools";
20 &error_exit($text{'index_eprogs'});
22 &open_tempfile(MODE, ">$module_config_directory/mode");
23 &print_tempfile(MODE, $raid_mode,"\n");
24 &close_tempfile(MODE);
26 &ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1, 0,
27 &help_search_link("raid", "man", "doc"),
28 undef, undef, &text('index_'.$raid_mode, $raid_ver));
30 # Display configured raid devices
31 $conf = &get_raidtab();
33 print &ui_columns_start([ $text{'index_name'},
34 $text{'index_active'},
37 $text{'index_members'} ]);
39 $lvl = &find_value('raid-level', $c->{'members'});
41 foreach $d (&find('device', $c->{'members'})) {
42 if (&find('raid-disk', $d->{'members'}) ||
43 &find('parity-disk', $d->{'members'})) {
44 push(@mems, $d->{'value'});
47 print &ui_columns_row([
48 "<a href='view_raid.cgi?idx=$c->{'index'}'>".
49 &html_escape($c->{'value'})."</a>",
51 "<font color=#00aa00>$text{'yes'}</font>" :
52 "<font color=#ff0000>$text{'no'}</font>",
53 $lvl eq 'linear' ? $text{'linear'} : $text{'raid'.$lvl},
54 $c->{'size'} ? &nice_size($c->{'size'}*1024) : "",
55 &ui_links_row(\@mems),
58 print &ui_columns_end();
61 print "<p><b>$text{'index_none'}</b><p>\n";
65 # Form for mdadm monitoring options
66 if ($raid_mode eq "mdadm") {
67 $notif = &get_mdadm_notifications();
69 print &ui_form_start("save_mdadm.cgi", "post");
70 print &ui_table_start($text{'index_header'}, undef, 2, [ "width=30%" ]);
72 # Is monitoring enabled?
73 if (&get_mdadm_action()) {
74 print &ui_table_row($text{'index_monitor'},
75 &ui_yesno_radio("monitor", &get_mdadm_monitoring() ? 1 : 0));
78 # Notification address
79 print &ui_table_row($text{'index_mailaddr'},
80 &ui_opt_textbox("mailaddr", $notif->{'MAILADDR'}, 40,
81 $text{'index_mailaddrnone'}));
84 print &ui_table_row($text{'index_mailfrom'},
85 &ui_opt_textbox("mailfrom", $notif->{'MAILFROM'}, 40,
86 $text{'index_mailfromnone'}));
88 # Program to call for problems
89 print &ui_table_row($text{'index_program'},
90 &ui_opt_textbox("program", $notif->{'PROGRAM'}, 40,
91 $text{'index_programnone'}));
93 print &ui_table_end();
94 print &ui_form_end([ [ undef, $text{'save'} ] ]);
97 &ui_print_footer("/", $text{'index'});
101 print &ui_form_start("raid_form.cgi");
102 print &ui_submit($text{'index_add'});
103 local @levels = &get_raid_levels();
104 print &ui_select("level", "linear",
105 [ [ "linear", $text{'linear'} ],
106 map { [ $_, $text{'raid'.$_} ] } @levels ]),"\n";
107 print &ui_form_end();
112 &ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1, 0,
113 &help_search_link("raid", "man", "doc"));
114 print "<p><b>",@_,"</b><p>\n";
115 &ui_print_footer("/", $text{'index'});