-
Notifications
You must be signed in to change notification settings - Fork 3
/
install_java.cgi
81 lines (63 loc) · 1.86 KB
/
install_java.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
#!/usr/bin/perl
require './tomcat-lib.pl';
require './java-lib.pl';
require '../webmin/webmin-lib.pl'; #require
foreign_require('software', 'software-lib.pl');
use File::Basename;
sub extract_java_archive{
my $jdk_archive = $_[0];
my $java_dir = '/usr/java';
if( ! -d $java_dir){
&make_dir($java_dir, 0755, 1);
}
$cmd_out='';
$cmd_err='';
print "<hr>Extracting $jdk_archive to $java_dir...<br>";
local $out = &execute_command("tar -x -v --overwrite -f \"$jdk_archive\" -C/usr/java", undef, \$cmd_out, \$cmd_err, 0, 0);
my $jdk_tar_first_line = ( split /\n/, $cmd_out )[0];
my $jdk_dir = $java_dir."/".(split /\//, $jdk_tar_first_line)[0];
if($cmd_err){
$cmd_err = s/\n/<br>/g;
&error("Error: tar: $cmd_err");
}else{
$cmd_out = s/\n/<br>/g;
print &html_escape($cmd_out);
}
&set_ownership_permissions('root','root', 0755, $jdk_dir);
exec_cmd("chown -R root:root $jdk_dir");
return $jdk_dir;
}
#$| = 1;
if ($ENV{REQUEST_METHOD} eq "POST") {
&ReadParse(\%getin, "GET");
&ReadParseMime(undef, \&read_parse_mime_callback, [ $getin{'id'} ]);
}
else {
&ReadParse();
$no_upload = 1;
}
&error_setup($text{'install_err'});
&ui_print_header(undef, $text{'java_title'}, "");
my $jdk_path = '';
if($in{'source'} == 200){
my $jdk_name = (split /=/, $in{'openjdk_ver'})[1];
my $openjdk_pkg = $jdk_name;
if($in{'openjdk_headless'} == 1){
$openjdk_pkg .= '-headless';
}
software::update_system_install($openjdk_pkg, undef);
$jdk_path = get_jdk_dir_by_name($jdk_name);
} else {
if ($in{'source'} == 100) {
my ($jdk_name, $url) = split /=/, $in{'jdk_ver'};
$in{'url'} = $url;
$in{'source'} = 2;
}
my $jdk_archive = process_file_source();
$jdk_path = extract_java_archive($jdk_archive);
}
if($in{'def_jdk'} == 1){
set_default_java($jdk_path);
}
print "<hr>Done<br>";
&ui_print_footer("", $text{'index_return'});