Handle hostnames with upper-case letters
[webmin.git] / fsdump / index.cgi
1 #!/usr/local/bin/perl
2 # index.cgi
3 # Display a list of scheduled dumps
4
5 require './fsdump-lib.pl';
6 &ui_print_header(undef, $text{'index_title'}, "", "intro", 1, 1);
7
8 @fslist = &supported_filesystems();
9 if (!@fslist && !$supports_tar) {
10         print "<p>",&text('index_ecommands', "<tt>dump</tt>"),"<p>\n";
11         &ui_print_footer("/", $text{'index'});
12         exit;
13         }
14
15 print &ui_subheading($text{'index_jobs'});
16 @alldumps = &list_dumps();
17 @dumps = grep { &can_edit_dir($_) } @alldumps;
18 &foreign_require("cron", "cron-lib.pl");
19 if (@dumps) {
20         ($nontar) = grep { $_->{'fs'} ne 'tar' } @dumps;
21         print &ui_form_start("delete_dumps.cgi", "post");
22         @links = ( &select_all_link("d"),
23                    &select_invert_link("d") );
24         print &ui_links_row(\@links);
25         @tds = ( "width=5" );
26         print &ui_columns_start([
27                 "",
28                 $text{'dump_dir'},
29                 $text{'dump_fs'},
30                 $nontar ? ( $text{'dump_level'} ) : ( ),
31                 $text{'dump_dest'},
32                 $text{'dump_sched'},
33                 $text{'dump_when'},
34                 $text{'index_action'} ], 100, 0, \@tds);
35         foreach $d (@dumps) {
36                 local @cols;
37                 @dirs = &dump_directories($d);
38                 $dirs = join("<br>", map { &html_escape($_) } @dirs);
39                 if ($access{'edit'}) {
40                         push(@cols, "<a href='edit_dump.cgi?id=$d->{'id'}'>".
41                                     "<tt>$dirs</tt></a>");
42                         }
43                 else {
44                         push(@cols, "<tt>$dirs</tt>");
45                         }
46                 push(@cols, uc($d->{'fs'}));
47                 push(@cols, &html_escape($d->{'level'})) if ($nontar);
48                 push(@cols, "<tt>".&dump_dest($d)."</tt>");
49                 push(@cols, $d->{'enabled'} ? $text{'yes'} : $text{'no'});
50                 $using_strftime++ if ($d->{'file'} =~ /%/ ||
51                                       $d->{'hfile'} =~ /%/);
52                 if ($d->{'follow'}) {
53                         $f = &get_dump($d->{'follow'});
54                         push(@cols, &text('index_follow',
55                                           "<tt>$f->{'dir'}</tt>"));
56                         }
57                 else {
58                         push(@cols, &cron::when_text($d, 1));
59                         }
60                 push(@cols, "<a href='backup.cgi?id=$d->{'id'}'>".
61                             "$text{'index_now'}</a>");
62                 print &ui_checked_columns_row(\@cols, \@tds, "d", $d->{'id'});
63                 }
64         print &ui_columns_end();
65         print &ui_links_row(\@links);
66         print &ui_form_end([ [ "delete", $text{'index_delete'} ] ]);
67         }
68 elsif (!@alldumps) {
69         print "<b>$text{'index_none'}</b><p>\n";
70         }
71 else {
72         print "<b>$text{'index_none2'}</b><p>\n";
73         }
74 if ($using_strftime && !$config{'date_subs'}) {
75         print "<font color=#ff0000><b>$text{'index_nostrftime'}",
76               "</b></font><p>\n";
77         }
78
79 # Form to add
80 print "<form action=edit_dump.cgi>\n";
81 print "<input type=submit value='$text{'index_add'}'>\n";
82 print "<input name=dir size=20> ",&file_chooser_button("dir"),"\n";
83 if ($supports_tar && !$config{'always_tar'}) {
84         print &ui_checkbox("forcetar", 1, $text{'index_forcetar'}, 0),"\n";
85         }
86 print "</form>\n";
87
88 if ($access{'restore'}) {
89         # Display restore button
90         print &ui_hr();
91         print &ui_buttons_start();
92
93         @fstypes = ( );
94         push(@fstypes, &supported_filesystems()) if (!$config{'always_tar'});
95         push(@fstypes, "tar") if ($supports_tar);
96         if (@fstypes > 1) {
97                 print &ui_buttons_row("restore_form.cgi",
98                                       $text{'index_restore'},
99                                       $text{'index_restoremsg'},
100                                       undef,
101                                       &ui_select("fs", undef,
102                                         [ map { [ $_, uc($_) ] } @fstypes ]));
103                 }
104         else {
105                 print &ui_buttons_row("restore_form.cgi",
106                                       $text{'index_restore2'},
107                                       $text{'index_restoremsg'},
108                                       &ui_hidden("fs", $fstypes[0]));
109                 }
110
111         print &ui_buttons_end();
112         }
113
114 # Display running backup jobs list, if any
115 &foreign_require("proc", "proc-lib.pl");
116 @procs = &proc::list_processes();
117 @running = grep { &can_edit_dir($_) } &running_dumps(\@procs);
118 if (@running) {
119         print &ui_hr();
120         print &ui_subheading($text{'index_running'});
121         print &ui_columns_start([ $text{'dump_dir'},
122                                   $text{'dump_dest'},
123                                   $text{'index_start'},
124                                   $text{'index_status'},
125                                   $text{'index_action'} ], 100);
126         foreach $d (@running) {
127                 @dirs = &dump_directories($d);
128                 $dirs = join("<br>", map { &html_escape($_) } @dirs);
129                 local @cols;
130                 push(@cols, "<tt>$dirs</tt>");
131                 push(@cols, "<tt>".&dump_dest($d)."</tt>");
132                 push(@cols, &make_date($d->{'status'}->{'start'}));
133                 push(@cols, $text{'index_status_'.$d->{'status'}->{'status'}});
134                 local $action;
135                 if ($d->{'status'}->{'status'} eq 'running' ||
136                     $d->{'status'}->{'status'} eq 'tape') {
137                         $action .= "<a href='kill.cgi?id=$d->{'id'}&pid=$d->{'pid'}'>$text{'index_kill'}</a>\n";
138                         }
139                 if ($d->{'status'}->{'status'} eq 'tape') {
140                         $action .= "&nbsp;|&nbsp;\n";
141                         $action .= "<a href='newtape.cgi?id=$d->{'id'}&pid=$d->{'pid'}'>$text{'index_newtape'}</a>\n";
142                         }
143                 if ($d->{'status'}->{'status'} eq 'complete' ||
144                     $d->{'status'}->{'status'} eq 'failed' ||
145                     $d->{'status'}->{'status'} eq 'verifyfailed') {
146                         $action .= $text{'index_noaction'};
147                         }
148                 push(@cols, $action);
149                 print &ui_columns_row(\@cols);
150                 }
151         print &ui_columns_end();
152         }
153
154 &ui_print_footer("/", $text{'index'});
155