#!/usr/bin/perl require './tomcat-lib.pl'; require 'java-lib.pl'; require 'jru-lib.pl'; require '../webmin/webmin-lib.pl'; #for OS detection foreign_require('software', 'software-lib.pl'); foreign_require('apache', 'apache-lib.pl'); $www_user = 'www-data'; sub sort_version { my @A = split(/\./, $a); my @B = split(/\./, $b); # a sort subroutine, expect $a and $b for(my $i=0; $i < 3; $i++){ if ($A[$i] < $B[$i]) { return -1 } elsif ($A[$i] > $B[$i]) { return 1 } } return 0; } sub sort_version_des { my @A = split(/\./, $a); my @B = split(/\./, $b); # a sort subroutine, expect $a and $b for(my $i=0; $i < 3; $i++){ if ($A[$i] < $B[$i]) { return 1 } elsif ($A[$i] > $B[$i]) { return -1 } } return 0; } sub add_tomcat_user{ #check if tomcat user exists if(read_file_contents('/etc/passwd') !~ /\ntomcat:/){ #add tomcat user local $out = &backquote_command('useradd -m tomcat', 0); }elsif(! -d '/home/tomcat'){ &make_dir("/home/tomcat", 0755, 1); &set_ownership_permissions('tomcat','tomcat', undef, '/home/tomcat'); } } sub get_tomcat_major_versions(){ my @majors = ('8', '7','6', '9'); return @majors; } sub major_tomcat_versions{ my $major = $_[0]; #Tomcat major version 6,7,8 my $tmpfile = download_file("http://archive.apache.org/dist/tomcat/tomcat-$major/", 1); if(! -f $tmpfile){ error($error); } my @latest_versions; open(my $fh, '<', $tmpfile) or die "open:$!"; while(my $line = <$fh>){ if($line =~ /v[0-9\.]+\/<\/a>/){ push(@latest_versions, $1); } } close $fh; return sort sort_version @latest_versions; } sub download_and_install{ my $tomcat_ver; my $major; #download tomcat archive if($in{'source'} == 100){ $tomcat_ver = $in{'source_archive'}; $major = substr($tomcat_ver, 0,1); $in{'url'} = "http://archive.apache.org/dist/tomcat/tomcat-$major/v$tomcat_ver/bin/apache-tomcat-$tomcat_ver.tar.gz"; $in{'source'} = 2; } my $tmpfile = process_file_source(); if($tmpfile =~ /.*apache-tomcat-([0-9\.]+).tar.gz$/i){ $tomcat_ver = $1; }else{ &error("Failed to match Tomcat version from archive"); } $major = substr($tomcat_ver, 0,1); #extract tomcat archive print "
Extracting to /home/tomcat/apache-tomcat-$tomcat_ver/ ...
"; exec_cmd("tar -x --overwrite -f \"$tmpfile\" -C/home/tomcat/"); print "Done
"; #folder is created after tomcat is started, but we need it now &make_dir("/home/tomcat/apache-tomcat-$tomcat_ver/conf/Catalina/localhost/", 0755, 1); open(my $fh, '>', "/home/tomcat/apache-tomcat-$tomcat_ver/conf/Catalina/localhost/manager.xml") or die "open:$!"; print $fh < EOF close $fh; #&set_ownership_permissions('tomcat','tomcat', undef, "/home/tomcat/apache-tomcat-$tomcat_ver/"); &execute_command("chown -R tomcat:tomcat /home/tomcat/apache-tomcat-$tomcat_ver"); return $tomcat_ver; } sub setup_catalina_env{ my $tomcat_ver = $_[0]; my %os_env; print "
Setting CATALINA environment..."; read_env_file('/etc/environment', \%os_env); $os_env{'CATALINA_HOME'} = "/home/tomcat/apache-tomcat-$tomcat_ver/"; $os_env{'CATALINA_BASE'} = "/home/tomcat/apache-tomcat-$tomcat_ver/"; write_env_file('/etc/environment', \%os_env, 0); open(my $fh, '>>', "/home/tomcat/apache-tomcat-$tomcat_ver/bin/setenv.sh") or die "open:$!"; print $fh "CATALINA_PID=\"/home/tomcat/apache-tomcat-$tomcat_ver/temp/tomcat.pid\""; close $fh; } sub setup_tomcat_users{ my $tomcat_ver = $_[0]; my @pw_chars = ("A".."Z", "a".."z", "0".."9", "_", "-"); my $manager_pass; my $admin_pass; $manager_pass .= $pw_chars[rand @pw_chars] for 1..32; $admin_pass .= $pw_chars[rand @pw_chars] for 1..32; #Save tomcat-users.xml open(my $fh, '>', "/home/tomcat/apache-tomcat-$tomcat_ver/conf/tomcat-users.xml") or die "open:$!"; print $fh < EOF close $fh; print "
Setting Tomcat users..."; } sub setup_tomcat_service{ my $tomcat_ver = $_[0]; copy_source_dest("$module_root_directory/tomcat.service", '/etc/systemd/system/tomcat.service'); my $ln = 0; $lref = read_file_lines('/etc/systemd/system/tomcat.service'); foreach $line (@$lref){ chomp $line; if($line =~ /\$TOMCAT_VER/){ #if its a section start $line =~ s/\$TOMCAT_VER/$tomcat_ver/; @{$lref}[$ln] = $line; }elsif($line =~ /\$CATALINA_HOME/){ $line =~ s/\$CATALINA_HOME/\/home\/tomcat\/apache-tomcat-$tomcat_ver/; @{$lref}[$ln] = $line; } $ln=$ln+1; } &flush_file_lines('/etc/systemd/system/tomcat.service'); &set_ownership_permissions('root','root', 0555, "/etc/systemd/system/tomcat.service"); &backquote_command("systemctl daemon-reload", undef, \$cmd_out, \$cmd_err, 0, 0); print "
Setting Tomcat service ..."; } sub install_tomcat_from_archive{ add_tomcat_user(); my $tomcat_ver = download_and_install(); setup_catalina_env($tomcat_ver); setup_tomcat_users($tomcat_ver); setup_tomcat_service($tomcat_ver); } sub get_apache_proxy_file(){ my $proxy_file; if( ( $osinfo{'real_os_type'} =~ /centos/i) or #CentOS ($osinfo{'real_os_type'} =~ /fedora/i) ){ #Fedora if( ! -d '/etc/httpd/'){ return 0; } $proxy_file = '/etc/httpd/conf.d/includes/tomcat.conf'; }elsif( ($osinfo{'real_os_type'} =~ /ubuntu/i) or ($osinfo{'real_os_type'} =~ /debian/i) ){ #ubuntu or debian if( ! -d '/etc/apache2/'){ return 0; } $proxy_file = '/etc/apache2/conf-available/tomcat.conf'; } return $proxy_file; } sub setup_default_apache_proxy(){ my $proxy_file = get_apache_proxy_file(); if(-f $proxy_file){ return 0; } open(my $fh, '>', $proxy_file) or die "open:$!"; if( ($osinfo{'real_os_type'} =~ /centos/i) or #CentOS ($osinfo{'real_os_type'} =~ /fedora/i) ){ #Fedora &exec_cmd('setsebool httpd_can_network_connect 1'); print $fh "LoadModule proxy_module modules/mod_proxy.so\n"; print $fh "LoadModule proxy_http_module modules/mod_proxy_http.so\n"; print $fh "LoadModule rewrite_module modules/mod_rewrite.so\n"; }elsif( $osinfo{'os_type'} =~ /debian/i){ #ubuntu or debian print $fh "LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so\n"; print $fh "LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so\n"; print $fh "LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so\n"; } print $fh "ProxyRequests Off\n"; print $fh "ProxyPreserveHost On\n"; print $fh " \n"; print $fh " Order allow,deny\n"; print $fh " Allow from all\n"; print $fh " \n"; print $fh "ProxyPass / http://localhost:8080/\n"; print $fh "ProxyPassReverse / http://localhost:8080/\n"; close $fh; print "Added proxy configuration / -> 8080 in $proxy_file\n"; } sub select_jasper_version{ print "$text{'jru_desc4'}

\n"; print < function update_versions(){ var checkBox = document.getElementsByName("show_beta")[0]; if (checkBox.checked == true){ get_pjax_content('/jri_publisher/setup.cgi?mode=select_jasper_version&show_beta=1'); }else{ get_pjax_content('/jri_publisher/setup.cgi?mode=select_jasper_version'); } } EOF print &ui_form_start("setup.cgi", "form-data"); print ui_hidden('mode', 'install_jasper_reports'); print &ui_table_start($text{'base_options'}, undef, 2); my $beta_enabled = 0; if($in{'show_beta'}){ $beta_enabled = 1; } my %jr_vers = &get_jasper_reports_versions($beta_enabled); my @jr_opts = ( ); foreach my $v (sort sort_version_des keys %jr_vers) { if($v =~ /([0-9\-\.a-z]+) BETA$/){ push(@jr_opts, [ $jr_vers{$v}, $1 ]); #drop BETA from version label }else{ push(@jr_opts, [ $jr_vers{$v}, $v ]); } } print &ui_table_row($text{'base_installsource'}, &ui_radio_table("source", 100, [ [100, $text{'jru_release'}, &ui_select("jr_ver", undef, \@jr_opts,1, 0).'
'. &ui_checkbox("show_beta", 1, $text{'jru_show_beta'}, $beta_enabled, 'onclick="update_versions()"')], [ 0, $text{'source_local'}, &ui_textbox("file", undef, 40)." ". &file_chooser_button("file", 0) ], [ 1, $text{'source_uploaded'}, &ui_upload("upload", 40) ], [ 2, $text{'source_ftp'},&ui_textbox("url", undef, 40) ] ])); print &ui_table_end(); print &ui_form_end([ [ "", $text{'base_installok'} ] ]); } sub select_tomcat_archive{ print "$text{'base_desc1'}

\n"; print &ui_form_start("setup.cgi", "form-data"); print ui_hidden('mode', 'tomcat_install'); print &ui_table_start($text{'base_options'}, undef, 2); my @tmver = sort sort_version_des &get_tomcat_major_versions(); my $sel_tmver = $in{'tmver'} || $tmver[0]; my @tm_opts = ( ); foreach my $v (@tmver) { push(@tm_opts, [ $v, $v ]); } print < function update_select(){ var majorSel = document.getElementById('base_major'); var major = majorSel.options[majorSel.selectedIndex].value; get_pjax_content('/jri_publisher/setup.cgi?mode=tomcat_install_form&tmver='+major); } EOF print &ui_table_row($text{'base_major'}, &ui_select("base_major", $sel_tmver, \@tm_opts, 1, 0, undef, undef, 'id="base_major" onchange="update_select()"')); my @tver = sort sort_version_des &major_tomcat_versions($sel_tmver); my @tver_opts = ( ); foreach my $v (@tver) { push(@tver_opts, [ $v, $v ]); } print &ui_table_row($text{'base_installsource'}, &ui_radio_table("source", 100, [ [ 100, $text{'source_archive'}, &ui_select("source_archive", undef, \@tver_opts,1, 0)], [ 0, $text{'source_local'}, &ui_textbox("file", undef, 40)." ". &file_chooser_button("file", 0) ], [ 1, $text{'source_uploaded'}, &ui_upload("upload", 40) ], [ 2, $text{'source_ftp'},&ui_textbox("url", undef, 40) ] ])); print &ui_table_end(); print &ui_form_end([ [ "", $text{'base_installok'} ] ]); } sub parse_jr_versions{ my $base_url = $_[0]; my %latest_versions; my $tmpfile = download_file($base_url, 1); if(! $tmpfile){ return %latest_versions; } open(my $fh, '<', $tmpfile) or die "open:$!"; while(my $line = <$fh>){ if($line =~ /[0-9\.]+(\-beta)?\/<\/a>/){ $latest_versions{$1} = $1.'@download'; } } close $fh; return %latest_versions; } sub parse_jr_gh_versions{ my $base_url = 'https://github.com/daust/JasperReportsIntegration'; my %latest_versions; my @tags = (); my $tmpfile = download_file($base_url.'/tags', 1); if(! $tmpfile){ return %latest_versions; } open(my $fh, '<', $tmpfile) or die "open:$!"; while(my $line = <$fh>){ # https://github.com/daust/JasperReportsIntegration/releases/tag/v2.10.1 if($line =~ /\/daust\/JasperReportsIntegration\/releases\/tag\/(v[0-9\.]+)/){ push(@tags, $1); } } close $fh; foreach my $tag (@tags) { my $tmpfile = download_file($base_url.'/releases/expanded_assets/'.$tag, 1); if(! $tmpfile){ return %latest_versions; } open(my $fh, '<', $tmpfile) or die "open:$!"; while(my $line = <$fh>){ # https://github.com/daust/JasperReportsIntegration/releases/download/v2.10.1/jri-2.10.1-jasper-6.20.0.zip if($line =~ /){ if($line =~ /oc\.jasper\.config\.home'.get_catalina_home().'/jasper_reports'; last; } $lnum++; } flush_file_lines($webxml); } sub install_jasper_reports(){ my $catalina_home = get_catalina_home(); my $jasper_home = $catalina_home.'/jasper_reports'; print "

Installing Jasper Reports $jr_ver

"; if($in{'source'} == 100){ #get Jasper version my @jr_ver_site = split(/@/, $in{'jr_ver'}); my $jr_ver = $jr_ver_site[0]; my $jr_site = $jr_ver_site[1]; my $beta_release = 0; if($jr_ver =~ /([0-9\-\.a-z]+) BETA$/){ $jr_ver = $1; $beta_release = 1; } $in{'url'} = get_jasper_archive_url($jr_ver, $beta_release, $jr_site); $in{'source'} = 2; } my $tmpfile = process_file_source(); my $unzip_dir = unzip_me($tmpfile); #github releases are in a subfolder my $subdir = substr(file_basename($tmpfile), 0, -4); #take filename, and drop .zip if(-d $unzip_dir.'/'.$subdir){ $unzip_dir = $unzip_dir.'/'.$subdir; } my $war_name = 'JasperReportsIntegration.war'; if( -f $unzip_dir.'/webapp/JasperReportsIntegration.war'){ #before v.2.6.1 $war_name = 'JasperReportsIntegration.war'; }elsif(-f $unzip_dir.'/webapp/jri.war'){ # from v.2.6.1 $war_name = 'jri.war'; }else{ die("Error: No war file found"); } print "Installing $war_name
"; &rename_file($unzip_dir.'/webapp/'.$war_name, $catalina_home.'/webapps/JasperReportsIntegration.war'); #make the jasper home &make_dir($jasper_home, 0750, 0); &rename_file($unzip_dir.'/conf', $jasper_home.'/conf'); &rename_file($unzip_dir.'/reports', $jasper_home.'/reports'); &rename_file($unzip_dir.'/logs', $jasper_home.'/logs'); &make_dir($jasper_home.'/schedules', 0750, 0); #TODO: Configure your database access print 'Warning: Skipping configuration of conf/application.properties
'; #set configuration directory print 'shell: setConfigDir.sh
'; $tmpfile = &transname('script.sh'); open(my $fh, '>', $tmpfile) or die "open:$!"; print $fh "cd $unzip_dir/bin\n"; print $fh "chmod +x encryptPasswords.sh\n"; #print $fh "sh ./encryptPasswords.sh ${$jasper_home}/conf/application.properties\n"; if(-f $unzip_dir.'/bin/setConfigDir.sh'){ print $fh "chmod +x setConfigDir.sh\n"; print $fh "sh ./setConfigDir.sh $catalina_home/webapps/JasperReportsIntegration.war $jasper_home\n"; } print $fh "chown -R tomcat:tomcat ${jasper_home}\n"; close $fh; exec_cmd('bash '.$tmpfile); print "Adding OC_JASPER_CONFIG_HOME to Tomcat setenv.sh
"; open(my $fh, '>>', $catalina_home.'/bin/setenv.sh') or die "open:$!"; print $fh "\nOC_JASPER_CONFIG_HOME=\"${jasper_home}\""; close $fh; tomcat_service_ctl('restart'); print "Done
"; } sub install_gen_jri_report(){ ©_source_dest($module_root_directory.'/gen_jri_report.sh', '/usr/local/bin'); &set_ownership_permissions('root', 'root', 0755, '/usr/local/bin/gen_jri_report.sh'); print 'Installed in /usr/local/bin/gen_jri_report.sh'; } sub check_jdbc_pg_exists(){ my $catalina_home = get_catalina_home(); opendir(DIR, $catalina_home.'/lib') or die $!; my @jars = grep { /^postgresql\-[0-9\.]+\.jar$/ # pg jar && -f "$catalina_home/lib/$_" # and is a file } readdir(DIR); closedir(DIR); if(@jars){ return $catalina_home.'/lib/'.$jars[0]; }else{ return $catalina_home.'/lib/'; } } sub check_jdbc_mysql_exists(){ my $catalina_home = get_catalina_home(); opendir(DIR, $catalina_home.'/lib') or die $!; my @jars = grep { /^mysql-connector-j\-[0-9\.]+\.jar$/ # pg jar && -f "$catalina_home/lib/$_" # and is a file } readdir(DIR); closedir(DIR); if(@jars){ return $catalina_home.'/lib/'.$jars[0]; }else{ return $catalina_home.'/lib/'; } } sub check_jdbc_mssql_exists(){ my $catalina_home = get_catalina_home(); opendir(DIR, $catalina_home.'/lib') or die $!; my @jars = grep { /^mssql-jdbc\-[0-9\.]+\.jre[0-9]+\.jar$/ # mssql jar && -f "$catalina_home/lib/$_" # and is a file } readdir(DIR); closedir(DIR); if(@jars){ return $catalina_home.'/lib/'.$jars[0]; }else{ return $catalina_home.'/lib/'; } } sub jri_add_datasource{ my $ds = $_[0]; my $ds_name = $_[1]; open(my $fh, '>>', get_catalina_home().'/jasper_reports/conf/application.properties') or die "open:$!"; print $fh "[datasource:$ds]\n"; print $fh "type=jndi\n"; print $fh "name=$ds_name\n"; close $fh } sub install_jri_pg(){ #download JDBC versions page my $tmpfile = download_file('https://jdbc.postgresql.org/download', 1); if(!$tmpfile){ die('Error: Failed to get JDBC PG page'); } #find latest $jdbc_pg_ver = ''; open(my $fh, '<', $tmpfile) or die "open:$!"; while(my $line = <$fh>){ if($line =~ /"; $tmpfile = download_file('https://jdbc.postgresql.org/download/postgresql-'.$jdbc_pg_ver.'.jar'); if(!$tmpfile){ die('Error: Failed to get JDBC PG jar'); } my $jar_filepath = get_catalina_home().'/lib/'.file_basename($tmpfile); &rename_file($tmpfile, $jar_filepath); print "Moving jar to ".$jar_filepath."
"; jri_add_pg_resource('jdbc/postgres', 'jdbc:postgresql://localhost:5432/xxx', 'xxx', 'xxx'); jri_add_datasource('postgres', 'postgres'); print "Done
"; } sub install_jri_mysql(){ #download JDBC versions page my $tmpfile = &transname('mysql.html'); exec_cmd('wget -O'.$tmpfile.' "https://dev.mysql.com/downloads/connector/j/"'); if(!$tmpfile){ die('Error: Failed to get JDBC MySQL page'); } #find latest $jdbc_mysql_ver = ''; open(my $fh, '<', $tmpfile) or die "open:$!"; while(my $line = <$fh>){ if($line =~ /

Connector\/J[ \t]+([0-9\.]+)[ \t]/){ $jdbc_mysql_ver = $1; last; } } close $fh; if(!$jdbc_mysql_ver){ die('Error: Failed to parse JDBC MySQL version'); } print "Downloading JDBC MySQL ver. ".$jdbc_mysql_ver."
"; $tmpfile = &transname('mysql-connector-java-'.$jdbc_mysql_ver.'.zip'); exec_cmd('wget -O'.$tmpfile.' https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-j-'.$jdbc_mysql_ver.'.zip'); if(!$tmpfile){ die('Error: Failed to get JDBC MySQL zip'); } my $unzip_dir = unzip_me($tmpfile); my $jar_filepath = get_catalina_home().'/lib/mysql-connector-j-'.$jdbc_mysql_ver.'.jar'; &rename_file($unzip_dir.'/mysql-connector-j-'.$jdbc_mysql_ver.'/mysql-connector-j-'.$jdbc_mysql_ver.'.jar', $jar_filepath); print "Moving jar to ".$jar_filepath."
"; jri_add_mysql_resource('jdbc/MySQL', 'jdbc:mysql://localhost:3306/xxx', 'xxx', 'xxx'); jri_add_datasource('MySQL', 'MySQL'); print "Done
"; } sub install_jri_mssql(){ #download JDBC versions page my $tmpfile = download_file('https://docs.microsoft.com/en-us/sql/connect/jdbc/download-microsoft-jdbc-driver-for-sql-server?view=sql-server-ver15', 1); if(!$tmpfile){ die('Error: Failed to get JDBC MySQL page'); } #find latest $jdbc_mssql_ver = ''; $jdbc_mssql_url = 'https://go.microsoft.com/fwlink/?linkid=2137600'; open(my $fh, '<', $tmpfile) or die "open:$!"; while(my $line = <$fh>){ if($line =~ /Download Microsoft JDBC Driver ([0-9\.]+)/){ $jdbc_mssql_ver = $1; if($line =~ /"(https:\/\/go\.microsoft\.com\/fwlink\/\?linkid=[0-9]+)"/){ $jdbc_mssql_url = $1; last; } } } close $fh; if(!$jdbc_mssql_url){ die('Error: Failed to parse JDBC MySQL version'); } print "Downloading JDBC MySQL ver. ".$jdbc_mssql_ver."
"; $tmpfile = download_file($jdbc_mssql_url); if(!$tmpfile){ die('Error: Failed to get JDBC MySQL zip'); } my $unzip_dir = unzip_me($tmpfile); #find which java we have my %jv = get_java_version(); my $jdk_major = $jv{'major'}; my $sqljdbc_dir = $unzip_dir.'/sqljdbc_'.$jdbc_mssql_ver.'/enu/'; opendir(DIR, $sqljdbc_dir) or die $!; my @jars = grep { /^mssql\-jdbc\-[0-9\.]+\.jre$jdk_major\.jar/ && -f "$sqljdbc_dir/$_" } readdir(DIR); closedir(DIR); if(!@jars){ # take all jars opendir(DIR, $sqljdbc_dir) or die $!; @jars = grep { /^mssql\-jdbc\-[0-9\.]+\.jre[0-9]+\.jar/ && -f "$sqljdbc_dir/$_" } readdir(DIR); closedir(DIR); if(!@jars){ die('Error: Failed to get JDBC MySQL jar for JDK '.$jv{'major'}); }else{ # sort in reverse to get latest jar @jars = sort @jars; } } my $jar_filepath = get_catalina_home().'/lib/'.$jars[0]; &rename_file($sqljdbc_dir.'/'.$jars[0], $jar_filepath); print "Moving jar to ".$jar_filepath."
"; jri_add_mssql_resource('jdbc/MSSQL', 'jdbc:sqlserver://localhost:1433;databaseName=xxx', 'xxx', 'xxx'); jri_add_datasource('MSSQL', 'MSSQL'); print "Done
"; } sub install_email_template(){ my $tmp_dir = get_email_tmpl_dir(); if(! -d $tmp_dir){ &make_dir($tmp_dir, 0755, 1); &set_ownership_permissions('tomcat','tomcat', undef, $tmp_dir); } &rename_file($module_root_directory.'/email_template.html', $tmp_dir.'/email_template.html'); print "Done
"; } sub install_html_app(){ my $app_dir = $module_root_directory.'/app'; &unlink_file('/var/www/html'); &rename_file($app_dir, '/var/www/html'); &exec_cmd("chown -R $www_user:$www_user /var/www/html"); opendir(DIR, '/var/www/html/portal') or die $!; my @portal_files = grep { -f '/var/www/html/portal/'.$_ } readdir(DIR); closedir(DIR); if (! -d '/etc/webmin/authentic-theme/'){ &make_dir('/etc/webmin/authentic-theme/', 0755, 1); } foreach my $f (@portal_files){ ©_source_dest('/var/www/html/portal/'.$f, '/etc/webmin/authentic-theme/'.$f); } my $hname = get_system_hostname(); my $ln=0; my $html_file = '/var/www/html/index.html'; $lref = &read_file_lines($html_file); foreach my $line (@$lref){ chomp($line); if($line =~ /xyzIP/){ $line =~ s/xyzIP/$hname/g; @{$lref}[$ln] = $line; } $ln++; } flush_file_lines($html_file); print "Done
"; } sub setup_checks{ #Check for commands if (!&has_command('java')) { print '

Warning: Java is not found. Install it manually or from the '. "Java tab

"; } my @pinfo = software::package_info('haveged', undef, ); if(!@pinfo){ if( $osinfo{'real_os_type'} =~ /centos/i){ #CentOS @pinfo = software::package_info('epel-release', undef, ); if(!@pinfo){ print "

Warning: haveged needs epel-release. Install it manually or ". "click here to have it downloaded and installed.

"; } } print "

Warning: haveged package is not installed. Install it manually or ". "click here to have it downloaded and installed.

"; } my $tomcat_ver = installed_tomcat_version(); if(!$tomcat_ver){ print "

Apache Tomcat is not found. Click here to install Tomcat from Apache site.

"; } my @pkg_deps; if( ( $osinfo{'real_os_type'} =~ /centos/i) or #CentOS ($osinfo{'real_os_type'} =~ /fedora/i) ){ #Fedora @pkg_deps = ('httpd', 'unzip', 'wget', 'mutt', 'zip'); }elsif( ($osinfo{'real_os_type'} =~ /ubuntu/i) or ($osinfo{'real_os_type'} =~ /debian/i) ){ #ubuntu or debian @pkg_deps = ('apache2', 'unzip', 'wget', 'mutt', 'zip'); } my @pkg_missing; foreach my $pkg (@pkg_deps){ my @pinfo = software::package_info($pkg); if(!@pinfo){ push(@pkg_missing, $pkg); } } if(@pkg_missing){ my $url_pkg_list = ''; foreach my $pkg (@pkg_missing){ $url_pkg_list .= '&u='.&urlize($pkg); } my $pkg_list = join(', ', @pkg_missing); print "

Warning: Missing package dependencies - $pkg_list - are not installed. Install them manually or ". "click here to have them installed.

"; } my $proxy_file = get_apache_proxy_file(); if(! -f $proxy_file){ print "

Apache default proxy is not configured. ". "click here

"; } if($tomcat_ver){ my $catalina_home = get_catalina_home(); if(! -f $catalina_home.'/webapps/JasperReportsIntegration.war'){ print "

JasperReportsIntegration is not installed. To select version and install, ". "click here

"; } if(! -f check_jdbc_pg_exists()){ print "

JRI PG support is not installed. To install it ". "click here

"; } if(! -f check_jdbc_mysql_exists()){ print "

JRI MySQL support is not installed. To install it ". "click here

"; } if(! -f check_jdbc_mssql_exists()){ print "

JRI MSSQL support is not installed. To install it ". "click here

"; } } if(! -f '/usr/local/bin/gen_jri_report.sh'){ print "

JRI report script is not installed. To install it ". "click here

"; } if(! -d get_email_tmpl_dir()){ print "

JRI email template is not installed. To install it ". "click here

"; } if( -d $module_root_directory.'/app'){ print "

HTML App is not installed. To install it ". "click here

"; } print '

If you don\'t see any warning above, you can complete setup from '. "here

"; } #Remove all setup files sub setup_cleanup{ my $file = $module_root_directory.'/setup.cgi'; print "Completing Installation
"; &unlink_file($file); my @mods = ('proxy', 'proxy_http'); foreach my $mod (@mods){ my $err = &apache::add_configured_apache_module($mod); #if($err){ # print "Warning:Apache:$mod:$err
"; #} } &apache::restart_apache(); update_oc_jasper_config_home(); print &js_redirect("index.cgi"); } &ui_print_header(undef, $text{'setup_title'}, ""); print "  Set Up Wizard "; print "

 

"; if($ENV{'CONTENT_TYPE'} =~ /boundary=(.*)$/) { &ReadParseMime(); }else { &ReadParse(); $no_upload = 1; } %osinfo = &detect_operating_system(); if( ( $osinfo{'real_os_type'} =~ /centos/i) or #CentOS ($osinfo{'real_os_type'} =~ /fedora/i) or #Fedora ($osinfo{'real_os_type'} =~ /scientific/i) ){ $www_user = 'apache'; } my $mode = $in{'mode'} || "checks"; if($mode eq "checks"){ setup_checks(); &ui_print_footer('', $text{'index_return'}); exit 0; }elsif($mode eq "cleanup"){ setup_cleanup(); &ui_print_footer('', $text{'index_return'}); exit 0; }elsif($mode eq "tomcat_install_form"){ select_tomcat_archive(); }elsif($mode eq "select_jasper_version"){ select_jasper_version(); }elsif($mode eq "tomcat_install"){ install_tomcat_from_archive(); }elsif($mode eq "setup_apache_proxy"){ setup_default_apache_proxy(); }elsif($mode eq "install_jasper_reports"){ install_jasper_reports(); }elsif($mode eq "install_gen_jri_report"){ install_gen_jri_report(); }elsif($mode eq "install_jri_pg"){ install_jri_pg(); }elsif($mode eq "install_jri_mysql"){ install_jri_mysql(); }elsif($mode eq "install_jri_mssql"){ install_jri_mssql(); }elsif($mode eq "install_email_template"){ install_email_template(); }elsif($mode eq "install_html_app"){ install_html_app(); }else{ print "Error: Invalid setup mode\n"; } &ui_print_footer('setup.cgi', $text{'setup_title'});