-
Notifications
You must be signed in to change notification settings - Fork 3
/
install_libs.cgi
72 lines (56 loc) · 1.71 KB
/
install_libs.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
#!/usr/bin/perl
require './tomcat-lib.pl';
use File::Basename;
use File::Path 'rmtree';
sub inst_error{
print "<b>$main::whatfailed : $_[0]</b> <p>\n";
&ui_print_footer("", $text{'index_return'});
exit;
}
if($ENV{'CONTENT_TYPE'} =~ /boundary=(.*)$/) {
&ReadParseMime();
}else {
&ReadParse();
$no_upload = 1;
}
$| = 1;
&ui_print_header(undef, $text{'libs_install_title'}, "");
my $lib_file = process_file_source();
my @suffixlist = ('\.zip', '\.jar');
($lib_name,$path,$lib_suffix) = fileparse($lib_file,@suffixlist);
my $unzip_dir = '';
my @lib_jars;
#Check if its a .zip or .jar
print "Source: $lib_file<br>";
if($lib_suffix eq ".zip"){
$unzip_dir = unzip_me($lib_file);
#make a list of extension jars
opendir(DIR, $unzip_dir) or die $!;
@lib_jars = grep { $_ = $unzip_dir.'/'.$_ ; -f && /\.jar$/ } readdir(DIR);
closedir(DIR);
}elsif($lib_suffix eq ".jar"){
push(@lib_jars, $lib_file);
}else{
&error("Error: Unsupported file type $lib_suffix");
&ui_print_footer("", $text{'index_return'});
}
print "<hr> Installing $lib_name files...<br>";
my $catalina_home = get_catalina_home();
#move jars to Tomcat lib and save list of installed jars to lib file
open(my $fh, '>', "$module_config_directory/lib_$lib_name.list") or die "open:$!";
foreach $j (@lib_jars) {
#move jars to Tomcat lib
if(!move("$j", "$catalina_home/lib/")){
&error("Error: Can't move file: $!");
}
my $j_name = basename($j);
&set_ownership_permissions('tomcat','tomcat', 0444, "$catalina_home/lib/$j_name");
print "$catalina_home/lib/$j_name<br>";
print $fh "$j_name=$catalina_home/lib/$j_name\n";
}
close $fh;
print "<hr>Done.<br>";
if($unzip_dir ne ''){
&rmtree($unzip_dir); #remove temp dir
}
&ui_print_footer("", $text{'index_return'});