
| Current Path : /var/www/web-klick.de/dsh/50_dev2017/1300__perllib/DivBasicF/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : /var/www/web-klick.de/dsh/50_dev2017/1300__perllib/DivBasicF/AutoInstall.pm |
package DivBasicF::AutoInstall;
use strict;
use Cwd;
use File::Copy;
use DivBasicF::Recursive;
use File::Path;
use Data::Dumper;
sub new {
my $class = shift;
my $self = {};
my $o = shift;
if ($o) {
$self->{'GLOBALKEY'} = $DivBasicF::Global_Keys::global_keys->{$o};
$self->{'CIPHER'} = Crypt::Blowfish->new($self->{'GLOBALKEY'});
}
bless($self,$class);
return($self);
}
#*****************************************************************
sub install {
my $self = shift;
my $project1 = shift; # Name of the autotest Installation
my $apache = shift; # Apache-Konfiguration
my $htdocs = shift; # Frontend Location
my $deinstall = "";
my $project = "autotest";
if ($htdocs eq "___DEINSTALL___") {
$deinstall = $htdocs;
$htdocs = "";
}
if (!$apache or $apache eq "___DEINSTALL___") {
print "Parameters: <apache-config> \[<frontend>\]\n";
exit;
}
chdir("..");
chdir("..");
my $o; my $o1; my $o2; my @ee;
my $dir = Cwd::cwd(); # This makes it possible to rename the installation directory
$dir =~ s/\n//gs; # and magically get the right directory in the apache directories
$dir =~ s/^(.*)\/(.*)$/$2/;
if ($dir ne $project1) {
move("htdocs/$project1","htdocs/$dir");
move("cgi-bin/$project1","cgi-bin/$dir");
$project1 = $dir;
}
open(FFILE,"<".$apache); # Einlesen des Apache-Files
my $text = join("",<FFILE>);
close(FFILE);
$project1 =~ s/\.zip$//;
my $cgi_alias = $apache;
if (!$cgi_alias) {
$cgi_alias = Cwd::cwd();
$cgi_alias =~ s/^(.*)\/(.*)\/(.*)$/$1/s;
}
my $cgi_dir = $cgi_alias;
# Pfadberechnung aus den Angaben des Apache-Files:
if ($text =~ /DocumentRoot +(\S+)/) {
$htdocs = $1;
}
if ($text =~ /ScriptAlias +(\S+) +(\S+)/) {
$cgi_alias = $1;
$cgi_dir = $2;
}
my $servroot = "";
if ($text =~ /\n *ServerRoot +(\S+)/) {
$servroot = $1;
}
$htdocs =~ s/\"//g;
$cgi_alias =~ s/\"//g;
$cgi_dir =~ s/\"//g;
$servroot =~ s/\"//g;
$htdocs =~ s/\\/\//g;
$cgi_alias =~ s/\\/\//g;
$cgi_dir =~ s/\\/\//g;
$servroot =~ s/\\/\//g;
$htdocs =~ s/\/$//gs;
$cgi_alias =~ s/\/$//gs;
$cgi_dir =~ s/\/$//gs;
$servroot =~ s/\/$//gs;
$o = 0;
if ($cgi_dir !~ /^[A-Za-z]\:/ and $cgi_dir !~ /^[\\\/]/) {
$o = 1;
$cgi_dir = $servroot . "/" . $cgi_dir;
}
if ($htdocs !~ /^[A-Za-z]\:/ and $htdocs !~ /^[\\\/]/) {
$o = 1;
$htdocs = $servroot . "/" . $htdocs;
}
if ($o and !$servroot) {
print "This is a direct installation.\n".
"Both paths for htdocs and cgi-bin have to be absolute paths.\n\n".
"Installation cancelled.\n";
return(0);
}
$o = $ENV{'PATH'};
$o =~ s/([\:\;])([A-Za-z])\:/$1---$2---/g;
$o = [split(/[\:\;]/,$o)];
while ($deinstall ne "___DEINSTALL___") {
$o1 = shift(@$o);
last if (!$o1);
$o1 =~ s/\-\-\-([A-Za-z])\-\-\-/$1\:/;
$o1 =~ s/\\/\//gs;
if (-f "$o1/env_autotest.bat" or -f "$o1/env_autotest") {
print "There is yet an older AutoTest installation.\n".
"Its backend is found in $o1.\n\n".
"Please delete that installation firstly.\n\n".
"Installation cancelled.\n";
return(0);
}
}
$o = $ENV{'PERL5LIB'};
$o =~ s/([\:\;])([A-Za-z])\:/$1---$2---/g;
$o = [split(/[\:\;]/,$o)];
while ($deinstall ne "___DEINSTALL___") {
$o1 = shift(@$o);
last if (!$o1);
$o1 =~ s/\-\-\-([A-Za-z])\-\-\-/$1\:/;
$o1 =~ s/\\/\//gs;
if (-f "$o1/env_autotest.bat" or -f "$o1/env_autotest") {
print "In the Environment-Variable PERL5LIB there is found.\n".
"a link to an older version of AutoTest.\n\n".
"Please delete that installation firstly.\n\n".
"Installation cancelled.\n";
return(0);
}
}
$o2 = "";
foreach $o ( # Check whether certain packages are installed.
"Cwd",
# "CGI::Session",
"Digest::SHA1",
"Data::Dumper",
"File::Copy",
"File::Path",
) {
next if (!$o);
$o1 = 0;
eval("use $o; \$o1 = 1");
next if ($o1 == 1);
$o2 = $o2 . $o . "\n";
}
if ($o2 and $deinstall ne "___DEINSTALL___") {
print "The following Perl Module(s): \n\n" .
$o2 . "\n" .
"are not installed.\n\n\n" .
"Installation cancelled.\n\n" .
"Install the missing packages with: \n\n" .
"ppm install <package> or \n" .
"cpan install <package>\n\n" .
"depending on your perl distribution,\n" .
"and try again.\n\n";
return(0);
}
$htdocs =~ s/[\/\\]$//gs;
$cgi_alias =~ s/[\/\\]$//gs;
$cgi_dir =~ s/[\/\\]$//gs;
# $htdocs =~ s/^[A-Z]\://gs;
# $cgi_dir =~ s/^[A-Z]\://gs;
while ($htdocs =~ s/[\\\/][^\:\\\/]+[\\\/]\.\.//) { 1; }
while ($cgi_dir =~ s/[\\\/][^\:\\\/]+[\\\/]\.\.//) { 1; }
if (!(-d $cgi_dir)) {
print "ERROR. cgi_bin-path not found: $cgi_dir\n";
return(0);
}
if (!(-d $htdocs)) {
print "ERROR. htdocs-path not found: $htdocs\n";
return(0);
}
return("No cgi-bin found\n") if (!($cgi_dir));
if ($deinstall eq "___DEINSTALL___") {
rmtree("$cgi_dir/$project1");
rmtree("$htdocs/$project1");
return("$project1 deinstalled.");
}
my $cgi_path = "$cgi_alias/$project1/index.cgi"; # Changing the path of the cgi-bin
open(FFILE,"<htdocs/$project1/script/$project.js");
my $text = join("",<FFILE>); # ... in the build version
close(FFILE);
$text =~ s/\"([^\"]+?)index\.cgi\"/\"$cgi_path\"/;
open(FFILE,">htdocs/$project1/script/$project.js");
print FFILE $text;
close(FFILE);
open(FFILE,"<htdocs/$project1/class/$project/Application.js");
$text = join("",<FFILE>); # ... in the source version
close(FFILE);
$text =~ s/\"([^\"]+?)index\.cgi\"/\"$cgi_path\"/;
open(FFILE,">htdocs/$project1/class/$project/Application.js");
print FFILE $text;
close(FFILE);
#-----------------------------------------
# find perl executable:
my $perlpath = "";
$o = $ENV{'PATH'};
$o =~ s/([\:\;])([A-Za-z])\:/$1---$2---/g;
$o = [split(/[\:\;]/,$o)];
print Dumper($o); # <-- new
$o = $^X;
$o =~ s/[\\\/](perl|perl.exe)$//i;
$o = [$o];
print Dumper($o); sleep 3;
print "\n\nSearching for a Perl executable:\n\n";
while (0 == 0) {
$o1 = shift(@$o);
$o1 =~ s/\-\-\-([A-Za-z])\-\-\-/$1\:/;
$perlpath = $o1 . "/perl";
$perlpath = $o1 . "\\perl" if ($o1 =~ /\\/);
$perlpath =~ s/ /\\ /g;
last if (`$perlpath -e \"print 1\"` =~ /1/);
$perlpath = "";
}
if (!$perlpath) { print "No Perl found!\n\n"; exit; }
print "\n\nPerl executable found: $perlpath\n\n";
open(FFILE,"<cgi-bin/$project1/index.cgi");
$o1 = join("",<FFILE>);
close(FFILE);
$o1 =~ s/^\#(.*?)\n//s;
$o1 = "\#\!" . $perlpath . " -w\n" . $o1;
open(FFILE,">cgi-bin/$project1/index.cgi");
print FFILE $o1;
close(FFILE);
#-----------------------------------------
# ... warum hier deinstall??
# my $cgi_rel = $deinstall || `chdir ..;pwd`; # computing the directory path from the cgi-bin
my $cgi_rel = Cwd::cwd(); # computing the directory path from the cgi-bin
$cgi_rel =~ s/^[A-Z]\://gs;
$cgi_rel =~ s/\n//gs;
$cgi_rel =~ s/^(.*)[\\\/](.*)$/$1/;
$dir = $cgi_dir;
while (0 == 0) {
# print "CCC $cgi_rel -- $cgi_dir -- $dir\n";
last if ($dir !~ /^[\\\/](.*?)[\\\/]/);
$text = $1;
last if ($cgi_rel !~ s/^[\\\/]$text([\\\/])/$1/);
$dir =~ s/^[\\\/]$text([\\\/])/$1/;
}
$cgi_rel = ".." . $cgi_rel;
while ($dir =~ s/^(.*)([\\\/])(.*)$/$1/) {
$cgi_rel = ".." . $2 . $cgi_rel;
}
# $cgi_rel =~ s/^(.*)([\\\/])(.*?)[\\\/][\\\/]/$1$2/;
# $cgi_rel =~ s/([\\\/])[\\\/]/$1/;
open(FFILE,"<cgi-bin/$project1/DivBasicF/AutoSettings.pm");
$text = join("",<FFILE>); # ... changing the AutoSettings
close(FFILE);
$text =~ s/(\"C\")([^\n]*)\"(.*)\"/$1$2\"$cgi_dir\/$project1\"/;
$text =~ s/(\"R\")([^\n]*)\"(.*)\"/$1$2\"$cgi_rel\"/;
$text =~ s/(\"E\")([^\n]*)\"(.*)\"/$1$2\"$cgi_path\"/;
open(FFILE,">cgi-bin/$project1/DivBasicF/AutoSettings.pm");
print FFILE $text;
close(FFILE);
return("Software package $project1 yet exists in $cgi_dir,\n" .
"delete it with deinstall before new installation") if (-d "$cgi_dir/$project1");
return("Software package $project1 yet exists in $htdocs,\n" .
"delete it with deinstall before new installation") if (-d "$htdocs/$project1");
# system("cp cgi-bin/$project1/DivBasicF/perl_caller ../perl_caller");
# system("chmod a+rwx ../perl_caller"); # Creating the helper scripts p, ot and ox
# in /usr/local/bin
# open(FFILE,">ot");
# print FFILE <<"TEXT_ENDE";
##!/bin/sh
#export PERL5LIB=$cgi_dir/$project1:\$PERL5LIB
#perl -e "use DivBasicF::AutoServer; print DivBasicF::AutoServer->new()->client('\$1','\$2','\$3','\$4','\$5','\$6','\$7','\$8','\$9')"
#TEXT_ENDE
# close(FFILE);
open(FFILE,">ot");
print FFILE <<'TEXT_ENDE';
#!/usr/bin/python3 -B
import sys
import re
import os
sys.path.append(".")
sys.argv[1] = re.sub(r"^r$", r"run", sys.argv[1]);
sys.argv[1] = re.sub(r"^c$", r"proceed", sys.argv[1]);
sys.argv[1] = re.sub(r"^m$", r"manual", sys.argv[1]);
sys.argv[1] = re.sub(r"^d$", r"report", sys.argv[1]);
text = """
import ---ITEM---
item = ---ITEM---.cls()
item.---FKT---(pars)
"""
if os.path.isfile(sys.argv[-1]) and re.search(r"\.py$",sys.argv[-1]):
pass
elif os.path.isfile(sys.argv[-1]+"_.py"):
sys.argv[-1] = sys.argv[-1] + "_.py"
elif os.path.isfile(sys.argv[-1]+".py"):
sys.argv[-1] = sys.argv[-1] + ".py"
elif os.path.isfile(sys.argv[-1]+"/item.py"):
sys.argv[-1] = re.sub("//","/",sys.argv[-1]+"/item.py")
else:
# special for directory method
sys.argv.append("item.py")
sys.argv[-1] = re.sub(r"//",r"/",sys.argv[-1])
sys.argv[-1] = re.sub(r".py$",r"",sys.argv[-1])
testcase = sys.argv.pop()
testcase = re.sub("\.py$","", testcase)
testcase = re.sub(r"[\\\/]",r".",testcase)
pars = sys.argv[2:]
fehlermeldung = "==================================\n"
while (0 == 0):
text1 = re.sub("---ITEM---", testcase, text)
text1 = re.sub("---FKT---", sys.argv[1],text1)
try:
if testcase == "item":
text1 = "---"
exec(text1)
except Exception as e:
fehlermeldung = fehlermeldung + "Current Directory: " + os.getcwd() + "\n"
fehlermeldung = fehlermeldung + "Test item: " + testcase + "\n"
fehlermeldung = fehlermeldung + str(e) + "\n==================================\n"
m = re.sub(r"^(.*)[\\\/](.*)$",r"\2",os.getcwd())
testcase = m + "." + testcase
if re.search(r"[\\\/].",os.getcwd()):
os.chdir("..")
continue
else:
print(fehlermeldung)
break
TEXT_ENDE
close(FFILE);
system("chmod a+rwx ot");
open(FFILE,">op");
print FFILE <<'TEXXT_ENDE' .
#!/usr/bin/perl
use Data::Dumper;
use Cwd;
TEXXT_ENDE
"push(\@INC,\"$cgi_dir/$project1\")\;\n" . <<'TEXXT_ENDE';
my $command = shift;
my @pars = @ARGV;
if (!@pars) { @pars = (); }
$command =~ s/^r$/run/;
$command =~ s/^c$/proceed/;
$command =~ s/^m$/manual/;
$command =~ s/^d$/report/;
$text = <<'TEXT_ENDE';
eval("use ---ITEM---::item");
eval("use ---ITEM---");
$item = ---ITEM---->new();
TEXT_ENDE
Cwd::cwd() =~ /^(.*)[\\\/](.*)$/;
$o = $pars[-1];
$o =~ s/[\\\/]+$//;
$o =~ s/\./\//g;
$o =~ s/\:\:/\//g;
if (-d $o ) {
if (-f $o . "/item.pm") {
$pars[-1] = $o . "/item.pm";
}
}
elsif (-f $o or -f ($o.".pm") ) {
1;
}
elsif (-f "item.pm") {
push(@pars,"item.pm");
}
$pars[-1] =~ s/[\\\/]+/\//;
$pars[-1] =~ s/\/?item.pm$//;
$pars[-1] =~ s/\.pm$//;
# print Dumper(@pars); exit;
my $testcase = pop(@pars);
$testcase =~ s/[\\\/]+/\:\:/g;
my $fehlermeldung = "==================================\n";
my $item;
while (0 == 0) {
$item = "";
$text1 = $text;
$text1 =~ s/---ITEM---/$testcase/g;
$main::___TESTCASE___ = $testcase;
# print($text1);
eval($text1);
if ($item) {
$item->$command(@pars);
exit;
}
$fehlermeldung = $fehlermeldung . "Current directory: " . Cwd::cwd() . "\n";
$fehlermeldung = $fehlermeldung . "Test item: " . $testcase . "\n";
$fehlermeldung = $fehlermeldung . $@ . "\n==================================\n";
if (Cwd::cwd() =~ /^(.+)[\\\/](.*)$/) {
$testcase = $2 . "::" . $testcase;
$testcase =~ s/\:\:$//;
# print "TESTCASE: $testcase\n";
chdir("..");
} else {
print $fehlermeldung;
exit;
}
}
TEXXT_ENDE
close(FFILE);
system("chmod a+rwx op");
open(FFILE,">ox");
print FFILE <<"TEXT_ENDE";
#!/bin/sh
export PERL5LIB=$cgi_dir/$project1:\$PERL5LIB
perl -e "use DivBasicF::AutoTest; print DivBasicF::AutoTest->new()->server('\$1','\$2','\$3','\$4','\$5','\$6','\$7','\$8','\$9')"
TEXT_ENDE
#perl_caller DivBasicF::AutoServer::server \$1 \$2 \$3 \$4 \$5 \$6 \$7 \$8 \$9
close(FFILE);
system("chmod a+rwx ox");
open(FFILE,">or");
print FFILE <<"TEXT_ENDE";
#!/bin/sh
export PERL5LIB=$cgi_dir/$project1:\$PERL5LIB
perl -e "use DivBasicF::AutoReport; print DivBasicF::AutoReport->new()->report_xls('\$1','\$2','\$3','\$4','\$5','\$6','\$7','\$8','\$9')"
TEXT_ENDE
#perl_caller DivBasicF::AutoServer::server \$1 \$2 \$3 \$4 \$5 \$6 \$7 \$8 \$9
close(FFILE);
system("chmod a+rwx or");
open(FFILE,">oa");
print FFILE <<"TEXT_ENDE";
#!/bin/sh
export PERL5LIB=$cgi_dir/$project1:\$PERL5LIB
perl -e "use DivBasicF::CSV; print DivBasicF::CSV->new()->convert('\$1','\$2','\$3','\$4','\$5','\$6','\$7','\$8','\$9')"
TEXT_ENDE
close(FFILE);
system("chmod a+rwx oa");
open(FFILE,">_ce");
print FFILE "\#\!/bin/bash\nPERL5LIB1=\$PERL5LIB\nPERL5LIB=$cgi_dir/$project1:\$PERL5LIB\n" . <<'TEXT_ENDE';
kto=`pwd`
source _cx $1
ukto=`pwd`
if [ "$kto" == "$ukto" ]; then
PERL5LIB=$PERL5LIB1
return
fi
joe `ls *.kto`
source _cx ..
source _cx c $1 2 > /dev/null
PERL5LIB=$PERL5LIB1
TEXT_ENDE
close(FFILE);
system("chmod a+rwx _ce");
open(FFILE,">_cx");
print FFILE "\#\!/bin/bash\nPERL5LIB2=\$PERL5LIB\nexport PERL5LIB=$cgi_dir/$project1:\$PERL5LIB\n" . <<'TEXT_ENDE';
if [ "$1" == "c" ]; then
perl -e "use DivBasicF::IfTFiBu1; print DivBasicF::IfTFiBu1->new()->clearkto('$2','$3').\"\\n\""
PERL5LIB=$PERL5LIB2
return
fi
if [ "$1" == ".." ]; then
ukto=`pwd`
cd ..
perl -e "use DivBasicF::IfTFiBu1; print DivBasicF::IfTFiBu1->new()->shell77('$ukto').\"\\n\""
# rm $ukto/*.kto
# rmdir $ukto/* 2> /dev/null
PERL5LIB=$PERL5LIB2
return
fi
if [ "$1" == "" ]; then
ukto=`pwd`
cd ..
perl -e "use DivBasicF::IfTFiBu1; print DivBasicF::IfTFiBu1->new()->shell77('$ukto').\"\\n\""
cd $ukto
PERL5LIB=$PERL5LIB2
return
fi
perl -e "use DivBasicF::IfTFiBu1; print DivBasicF::IfTFiBu1->new()->shell77('$1','$2','$3','$4','$5','$6','$7','$8','$9','${10}','${11}','${12}','${13}','${14}','${15}','${16}','${17}','${18}','${19}').\"\\n\""
cd `perl -e "use DivBasicF::IfTFiBu1; print DivBasicF::IfTFiBu1->new()->shell79('$1','$2','$3','$4','$5').\"\\n\""`
PERL5LIB=$PERL5LIB2
TEXT_ENDE
close(FFILE);
system("chmod a+rwx _cx");
open(FFILE,">env_autotest");
print FFILE "export PATH=$cgi_dir/$project1:\$PATH\n";
close(FFILE);
system("chmod a+rwx env_autotest");
$o1 = $cgi_dir;
$o1 =~ s/\//\\/g;
open(FFILE,">ot.bat");
print FFILE <<"TEXT_ENDE";
\@echo off
python3 -B $cgi_dir/$project1/ot \%1 \%2 \%3 \%4 \%5 \%6 \%7 \%8 \%9
TEXT_ENDE
#perl -e "use DivBasicF::AutoServer; DivBasicF::AutoServer->new()->client('\%1','\%2','\%3','\%4','\%5','\%6','\%7','\%8','\%9')"
close(FFILE);
system("chmod a+rwx ot.bat");
open(FFILE,">ox.bat");
print FFILE <<"TEXT_ENDE";
\@echo off
perl -e "use DivBasicF::AutoTest; print DivBasicF::AutoTest->new()->server('\%1','\%2','\%3','\%4','\%5','\%6','\%7','\%8','\%9')"
TEXT_ENDE
close(FFILE);
system("chmod a+rwx ox.bat");
open(FFILE,">or.bat");
print FFILE <<"TEXT_ENDE";
\@echo off
perl -e "use DivBasicF::AutoReport; print DivBasicF::AutoReport->new()->report_xls('\%1','\%2','\%3','\%4','\%5','\%6','\%7','\%8','\%9')"
TEXT_ENDE
close(FFILE);
system("chmod a+rwx or.bat");
open(FFILE,">oa.bat");
print FFILE <<"TEXT_ENDE";
\@echo off
perl -e "use DivBasicF::CSV; use Data::Dumper; print DivBasicF::CSV->new()->convert('\%1','\%2','\%3','\%4','\%5','\%6','\%7','\%8','\%9'))"
TEXT_ENDE
close(FFILE);
system("chmod a+rwx oa.bat");
open(FFILE,">_ce.bat");
print FFILE "\#\!/bin/bash\nexport PERL5LIB=$cgi_dir/$project1:\$PERL5LIB\n" . <<'TEXT_ENDE';
kto=`pwd`
source _cx $1
ukto=`pwd`
if [ "$kto" == "$ukto" ]; then
return
fi
joe `ls *.kto`
source _cx ..
source _cx c $1 2 > /dev/null
TEXT_ENDE
close(FFILE);
system("chmod a+rwx _ce.bat");
open(FFILE,">_cx.bat");
print FFILE "\#\!/bin/bash\nexport PERL5LIB=$cgi_dir/$project1:\$PERL5LIB\n" . <<'TEXT_ENDE';
if [ "$1" == "c" ]; then
perl -e "use DivBasicF::IfTFiBu1; print DivBasicF::IfTFiBu1->new()->clearkto('$2','$3').\"\\n\""
return
fi
if [ "$1" == ".." ]; then
ukto=`pwd`
cd ..
perl -e "use DivBasicF::IfTFiBu1; print DivBasicF::IfTFiBu1->new()->shell77('$ukto').\"\\n\""
# rm $ukto/*.kto
# rmdir $ukto/* 2> /dev/null
return
fi
if [ "$1" == "" ]; then
ukto=`pwd`
cd ..
perl -e "use DivBasicF::IfTFiBu1; print DivBasicF::IfTFiBu1->new()->shell77('$ukto').\"\\n\""
cd $ukto
return
fi
perl -e "use DivBasicF::IfTFiBu1; print DivBasicF::IfTFiBu1->new()->shell77('$1','$2','$3','$4','$5','$6','$7','$8','$9','${10}','${11}','${12}','${13}','${14}','${15}','${16}','${17}','${18}','${19}').\"\\n\""
cd `perl -e "use DivBasicF::IfTFiBu1; print DivBasicF::IfTFiBu1->new()->shell79('$1','$2','$3','$4','$5').\"\\n\""`
TEXT_ENDE
close(FFILE);
system("chmod a+rwx _cx.bat");
open(FFILE,">env_autotest.bat");
print FFILE "set PERL5LIB=$o1\\"."$project1;\%PERL5LIB\%\nset PATH=$o1\\"."$project1;\%PATH\%\n";
close(FFILE);
system("chmod a+rwx env_autotest.bat");
open(FFILE,">shell_autotest.bat");
print FFILE "set PERL5LIB=$o1\\"."$project1;\%PERL5LIB\%\nset PATH=$o1\\"."$project1;\%PATH\%\ncmd\n";
close(FFILE);
system("chmod a+rwx shell_autotest.bat");
foreach $o (1,2,3,4,5) {
open(FFILE,">oa$o");
print FFILE <<"TEXT_ENDE";
#!/bin/sh
export ADRFILE=\$ADRFILE$o
export PERL5LIB=$cgi_dir/$project1:\$PERL5LIB
perl -e "use DivBasicF::CSV; print DivBasicF::CSV->new()->convert('\$1','\$2','\$3','\$4','\$5','\$6','\$7','\$8','\$9')"
TEXT_ENDE
close(FFILE);
system("chmod a+rwx oa$o");
open(FFILE,">oa$o.bat");
print FFILE <<"TEXT_ENDE";
\@echo off
set ADRFILE0=\%ADRFILE\%
set ADRFILE=\%ADRFILE$o\%
perl -e "use DivBasicF::CSV; use Data::Dumper; print DivBasicF::CSV->new()->convert('\%1','\%2','\%3','\%4','\%5','\%6','\%7','\%8','\%9'))"
set ADRFILE=\%ADRFILE0\%
set ADRFILE0=
TEXT_ENDE
close(FFILE);
system("chmod a+rwx oa$o.bat");
}
#------------------ Check for binaries ------------------------
# zunaechst eine Liste aller Binary-Directories erstellen
chdir("cgi-bin/$project1");
my @auto_versions = ();
opendir(DDIR,".");
while (0 == 0) {
$o = readdir(DDIR);
last if (!$o);
next if (!(-d($o)));
next if ($o !~ /^auto\_/);
push(@auto_versions,$o);
}
closedir(DDIR);
# jetzt alle Directories durchgehen und proben, ob eines funktioniert
rmtree("auto");
open(FFILE,">check_for_binary.pl");
print FFILE <<'TEXT_ENDE';
eval("use DivBasicF::IfTProgramReader");
print "-" . eval("DivBasicF::IfTProgramReader::DELIVER()") . "-\n";
TEXT_ENDE
close(FFILE);
print "=================================\n\nCheck for supported systems:\n\n";
foreach $o (@auto_versions) {
print "$o --> ";
DivBasicF::Recursive::dircopy($o,"auto");
open(FFILE,">$o.txt"); print FFILE "auto\n"; close(FFILE);
$o1 = `perl check_for_binary.pl`;
last if ($o1 =~ /[123]/);
rmtree("auto");
print " NOT compatible...\n";
unlink("$o.txt");
}
unlink("check_for_binary.pl");
if (-d "auto") {
print "COMPATIBLE!\n\n";
} else {
@ee = ();
opendir(DDIR,"DivBasicF");
while (0 == 0) {
$o = readdir(DDIR);
last if (!$o);
next if ($o !~ /\.pm$/);
push(@ee,$o);
}
closedir(DDIR);
foreach $o (@ee) {
open(FFILE,"<DivBasicF/$o"); # alle pm Dateien werden durchgegangen,
$o1 = <FFILE>; # wenn eine verschluesselt ist, dann muss
close(FFILE); # die Installation abgebrochen werden,
if ($o1 =~ /use DivBasicF\:\:IfTProgramReader/) { # da kein Binary gefunden wurde
chdir("../.."); # fuer den IfTProgramReader
$o1 = `perl -v`;
$o1 =~ s/^(.*?)\((.*?)\) +built +for +(.*?)\n(.*)$/$2\_\_$3/si;
return("\nNo compatible binaries found for system auto_$o1\n\n" .
"Decryption necessary in $o. Installation cancelled.\n\n\n");
}
}
print "NO COMPATIBLE BINARY NECESSARY BECAUSE NO ENCRYPTION IS USED...\n\n";
}
chdir("../..");
#--------------------------------------------------------------------------------
DivBasicF::Recursive::dirmove("cgi-bin/$project1","$cgi_dir/$project1");
DivBasicF::Recursive::dirmove("htdocs/$project1","$htdocs/$project1") if ($htdocs);
#-------------- LINUX CALLER SCRIPTS -------------------------
move("ot","$cgi_dir/$project1");
system("chmod a+rwx $cgi_dir/$project1/ot");
move("op","$cgi_dir/$project1");
system("chmod a+rwx $cgi_dir/$project1/op");
move("ox","$cgi_dir/$project1");
system("chmod a+rwx $cgi_dir/$project1/ox");
move("or","$cgi_dir/$project1");
system("chmod a+rwx $cgi_dir/$project1/or");
move("oa","$cgi_dir/$project1");
system("chmod a+rwx $cgi_dir/$project1/oa");
move("_ce","$cgi_dir/$project1");
system("chmod a+rwx $cgi_dir/$project1/_ce");
move("_cx","$cgi_dir/$project1");
system("chmod a+rwx $cgi_dir/$project1/_cx");
move("env_autotest","$cgi_dir/$project1");
system("chmod a+rwx $cgi_dir/$project1/env_autotest");
#-------------- WINDOWS CALLER SCRIPTS -----------------------
move("ot.bat","$cgi_dir/$project1");
system("chmod a+rwx $cgi_dir/$project1/ot.bat");
move("ox.bat","$cgi_dir/$project1");
system("chmod a+rwx $cgi_dir/$project1/ox.bat");
move("or.bat","$cgi_dir/$project1");
system("chmod a+rwx $cgi_dir/$project1/or.bat");
move("oa.bat","$cgi_dir/$project1");
system("chmod a+rwx $cgi_dir/$project1/oa.bat");
move("_ce.bat","$cgi_dir/$project1");
system("chmod a+rwx $cgi_dir/$project1/_ce.bat");
move("_cx.bat","$cgi_dir/$project1");
system("chmod a+rwx $cgi_dir/$project1/_cx.bat");
move("env_autotest.bat","$cgi_dir/$project1");
system("chmod a+rwx $cgi_dir/$project1/env_autotest.bat");
move("shell_autotest.bat","$cgi_dir/$project1");
system("chmod a+rwx $cgi_dir/$project1/shell_autotest.bat");
copy("$cgi_dir/$project1/DivBasicF/perl_caller","$cgi_dir/$project1");
system("chmod a+rwx $cgi_dir/$project1/perl_caller");
#---------------------------------------------------------------
rmdir("cgi-bin");
rmdir("htdocs") if ($htdocs);
rmtree("htdocs") if ($htdocs);
# system("rm *");
chdir("..");
# rmdir($project1);
return("Software package $project1 successfully installed.");
}
#*****************************************************************
1;