#!/usr/bin/perl require './tomcat-lib.pl'; use File::Basename; use File::Path 'rmtree'; sub inst_error{ print "$main::whatfailed : $_[0]

\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
"; if($lib_suffix eq ".zip"){ $unzip_dir = unzip_file($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 "


Installing $lib_name files...
"; 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
"; print $fh "$j_name=$catalina_home/lib/$j_name\n"; } close $fh; print "
Done.
"; if($unzip_dir ne ''){ &rmtree($unzip_dir); #remove temp dir } &ui_print_footer("", $text{'index_return'});