Handle hostnames with upper-case letters
[webmin.git] / webmin / edit_upgrade.cgi
1 #!/usr/local/bin/perl
2 # edit_upgrade.cgi
3 # Display a form for upgrading all of webmin from a tarfile
4
5 require './webmin-lib.pl';
6 &ReadParse();
7 &ui_print_header(undef, $text{'upgrade_title'}, "");
8
9 if (&shared_root_directory()) {
10         &ui_print_endpage($text{'upgrade_eroot'});
11         }
12
13 # what kind of install was this?
14 $mode = &get_install_type();
15
16 # was the install to a target directory?
17 if (open(DIR, "$config_directory/install-dir")) {
18         chop($dir = <DIR>);
19         close(DIR);
20         }
21 if ($mode eq "solaris-pkg") {
22         $skip_upgrade = $text{'upgrade_esolaris'};
23         }
24 elsif ($mode eq "zip") {
25         $skip_upgrade = $text{'upgrade_ezip'};
26         }
27
28 # Show tabs
29 @tabs = map { [ $_, $text{'upgrade_tab'.$_}, "edit_upgrade.cgi?mode=$_" ] }
30             ( $skip_upgrade ? ( ) : ( "upgrade" ),
31               "grants", "update", "sched" );
32 print ui_tabs_start(\@tabs, "mode", $in{'mode'} || $tabs[0]->[0], 1);
33
34 if (!$skip_upgrade) {
35         # Display upgrade form
36         print ui_tabs_start_tab("mode", "upgrade");
37         print $text{"upgrade_desc$mode"},"<p>";
38
39         print ui_form_start("upgrade.cgi", "form-data");
40         print ui_hidden("mode", $mode);
41         print ui_hidden("dir", $dir);
42         print ui_table_start($text{'upgrade_title'}, undef, 1);
43         print "<tr $cb> <td nowrap>\n";
44         print "<input type=radio name=source value=0> $text{'upgrade_local'}\n";
45         print "<input name=file size=40>\n";
46         print file_chooser_button("file", 0),"<br>\n";
47         print "<input type=radio name=source value=1> $text{'upgrade_uploaded'}\n";
48         print "<input name=upload type=file size=30><br>\n";
49         print "<input type=radio name=source value=5> $text{'upgrade_url'}\n";
50         print "<input name=url size=40><br>\n";
51         if ($mode eq 'caldera') {
52                 print "<input type=radio name=source value=3 checked> $text{'upgrade_cup'}\n";
53                 }
54         elsif ($mode eq "gentoo") {
55                 print "<input type=radio name=source value=4 checked> $text{'upgrade_emerge'}\n";
56                 }
57         elsif ($mode ne "sun-pkg") {
58                 print "<input type=radio name=source value=2 checked> $text{'upgrade_ftp'}\n";
59                 }
60         print "<p>\n";
61         if (!$mode && !$dir) {
62                 # Checkbox to delete original directory
63                 print "<input type=checkbox name=delete value=1> ",
64                         "$text{'upgrade_delete'}<br>\n";
65                 }
66         if ((!$mode || $mode eq "rpm") && &foreign_check("proc")) {
67                 # Checkbox to check signature
68                 ($ec, $emsg) = &gnupg_setup();
69                 printf "<input type=checkbox name=sig value=1 %s> %s<br>\n",
70                         $ec ? "" : "checked", $text{'upgrade_sig'};
71                 }
72         if (!$mode) {
73                 # Checkbox to not install missing modules
74                 printf "<input type=checkbox name=only value=1 %s> %s<br>\n",
75                         -r "$root_directory/minimal-install" ? "checked" : "",
76                         $text{'upgrade_only'};
77                 }
78         printf "<input type=checkbox name=force value=1> %s<br>\n",
79                 $text{'upgrade_force'};
80         if ($main::session_id) {
81                 # Checkbox to disconnect other sessions
82                 printf "<input type=checkbox name=disc value=1> %s<br>\n",
83                         $text{'upgrade_disc'};
84                 }
85         print ui_table_end();
86         print "<input type=submit value=\"$text{'upgrade_ok'}\">\n";
87         print "</form>\n";
88         print ui_tabs_end_tab();
89         }
90
91 # Display new module grants form
92 print ui_tabs_start_tab("mode", "grants");
93 print "$text{'newmod_desc'}<p>\n";
94 print ui_form_start("save_newmod.cgi", "post");
95 print ui_table_start($text{'newmod_header'});
96
97 $newmod = &get_newmodule_users();
98 printf "<input type=radio name=newmod_def value=1 %s> %s<br>\n",
99         $newmod ? "" : "checked", $text{'newmod_def'};
100 printf "<input type=radio name=newmod_def value=0 %s> %s\n",
101         $newmod ? "checked" : "", $text{'newmod_users'};
102 printf "<input name=newmod size=30 value='%s'><br>\n",
103         join(" ", @$newmod);
104
105 print ui_table_end();
106 print "<input type=submit value='$text{'save'}'></form>\n";
107 print ui_tabs_end_tab();
108
109 # Display module update form
110 print ui_tabs_start_tab("mode", "update");
111 print "$text{'update_desc1'}<p>\n";
112 print ui_form_start("update.cgi", "post");
113 print ui_table_start($text{'update_header1'});
114 print "<tr $cb> <td nowrap>\n";
115
116 printf "<input type=radio name=source value=0 %s> %s<br>\n",
117         $config{'upsource'} ? "" : "checked", $text{'update_webmin'};
118 printf "<input type=radio name=source value=1 %s> %s<br>\n",
119         $config{'upsource'} ? "checked" : "", $text{'update_other'};
120 print "&nbsp;" x 4;
121 print &ui_textarea("other", join("\n", split(/\t+/, $config{'upsource'})),
122                    2, 50),"<br>\n";
123
124 printf "<input type=checkbox name=show value=1 %s> %s<br>\n",
125         $config{'upshow'} ? "checked" : "", $text{'update_show'};
126 printf "<input type=checkbox name=missing value=1 %s> %s<br>\n",
127         $config{'upmissing'} ? "checked" : "", $text{'update_missing'};
128 printf "<input type=checkbox name=third value=1 %s> %s<br>\n",
129         $config{'upthird'} ? "checked" : "", $text{'update_third'};
130 printf "<input type=checkbox name=checksig value=1 %s> %s<br>\n",
131         $config{'upchecksig'} ? 'checked' : '', $text{'update_checksig'};
132
133 print "<table>\n";
134 print "<tr> <td>$text{'update_user'}</td>\n";
135 print "<td>",&ui_textbox("upuser", $config{'upuser'}, 30),"</td> </tr>\n";
136 print "<tr> <td>$text{'update_pass'}</td>\n";
137 print "<td>",&ui_password("uppass", $config{'uppass'}, 30),"</td> </tr>\n";
138 print "</table>\n";
139
140 print ui_table_end();
141 print "<input type=submit value=\"$text{'update_ok'}\">\n";
142 print "</form>\n";
143 print ui_tabs_end_tab();
144
145 # Display scheduled update form
146 print ui_tabs_start_tab("mode", "sched");
147 print "$text{'update_desc2'}<p>\n";
148 print ui_form_start("update_sched.cgi", "post");
149 print ui_table_start($text{'update_header2'});
150 print "<tr $cb> <td nowrap>\n";
151 printf "<input type=checkbox name=enabled value=1 %s> %s<p>\n",
152         $config{'update'} ? 'checked' : '', $text{'update_enabled'};
153         
154 printf "<input type=radio name=source value=0 %s> %s<br>\n",
155         $config{'upsource'} ? "" : "checked", $text{'update_webmin'};
156 printf "<input type=radio name=source value=1 %s> %s<br>\n",
157         $config{'upsource'} ? "checked" : "", $text{'update_other'};
158 print "&nbsp;" x 4;
159 print &ui_textarea("other", join("\n", split(/\t+/, $config{'upsource'})),
160                    2, 50),"<br>\n";
161
162 if ($config{'cron_mode'} == 0) {
163         $upmins = sprintf "%2.2d", $config{'upmins'};
164         print &text('update_sched2',
165                     "<input name=hour size=2 value='$config{'uphour'}'>",
166                     "<input name=mins size=2 value='$upmins'>",
167                     "<input name=days size=3 value='$config{'updays'}'>"),"<br>\n";
168         }
169 else {
170         &foreign_require("cron", "cron-lib.pl");
171         @jobs = &cron::list_cron_jobs();
172         $job = &find_cron_job(\@jobs);
173         $job ||= { 'mins' => 0,
174                    'hours' => $config{'uphour'},
175                    'days' => "*/$config{'updays'}",
176                    'months' => '*',
177                    'weekdays' => '*' };
178         print "<br><table border=1>\n";
179         &cron::show_times_input($job, 1);
180         print "</table><br>\n";
181         }
182
183 printf "<input type=checkbox name=show value=1 %s> %s<br>\n",
184       $config{'upshow'} ? 'checked' : '', $text{'update_show'};
185 printf "<input type=checkbox name=missing value=1 %s> %s<br>\n",
186       $config{'upmissing'} ? 'checked' : '', $text{'update_missing'};
187 printf "<input type=checkbox name=third value=1 %s> %s<br>\n",
188         $config{'upthird'} ? "checked" : "", $text{'update_third'};
189 printf "<input type=checkbox name=quiet value=1 %s> %s<br>\n",
190       $config{'upquiet'} ? 'checked' : '', $text{'update_quiet'};
191 printf "<input type=checkbox name=checksig value=1 %s> %s<br>\n",
192       $config{'upchecksig'} ? 'checked' : '', $text{'update_checksig'};
193
194 print "<table>\n";
195 print "<tr> <td>$text{'update_email'}</td>\n";
196 print "<td>",&ui_textbox("email", $config{'upemail'}, 30),"</td> </tr>\n";
197 print "<tr> <td>$text{'update_user'}</td>\n";
198 print "<td>",&ui_textbox("upuser", $config{'upuser'}, 30),"</td> </tr>\n";
199 print "<tr> <td>$text{'update_pass'}</td>\n";
200 print "<td>",&ui_password("uppass", $config{'uppass'}, 30),"</td> </tr>\n";
201 print "</table>\n";
202
203 print ui_table_end();
204 print "<input type=submit value=\"$text{'update_apply'}\">\n";
205 print "</form>\n";
206 print ui_tabs_end_tab();
207
208 print &ui_tabs_end(1);
209
210 &ui_print_footer("", $text{'index_return'});
211