25 $euid = posix_getuid();
27 print
"Error, this script must be run as root\n";
38 function installST() {
40 if (is_readable(
'/etc/fossology/Proxy.conf')) {
41 print
"Using proxy found in file /etc/fossology/Proxy.conf\n";
42 $cmd =
". /etc/fossology/Proxy.conf;" .
43 "wget -nv -t 1 'http://downloads.sourceforge.net/simpletest/simpletest_1.0.1.tar.gz'";
45 else if (is_readable(
'/usr/local/etc/fossology/Proxy.conf')) {
46 print
"Using proxy found in file /usr/local/etc/fossology/Proxy.conf\n";
47 $cmd =
". /usr/local/etc/fossology/Proxy.conf;" .
48 "wget -nv -t 1 'http://downloads.sourceforge.net/simpletest/simpletest_1.0.1.tar.gz'";
51 print
"No proxy used when attempting to download simpletest\n";
52 $cmd =
"wget -nv -t 1 'http://downloads.sourceforge.net/simpletest/simpletest_1.0.1.tar.gz'";
54 if(chdir(
'/usr/local/')) {
55 $wLast = exec($cmd, $wgetOut, $rtn);
57 $tar =
'tar -xf simpletest_1.0.1.tar.gz';
58 $tLast = exec($tar, $tout, $rtn);
59 if(is_readable(
'/usr/local/simpletest')) {
61 $rl = exec(
'rm simpletest_1.0.1.tar.gz', $toss, $notchecked);
66 print
"ERROR! failed to un-tar simpletest into /usr/local\n";
67 print
"tar output was:$tLast\n";print_r($tout) .
"\n";
68 print
"Investigate and install simpletest into /usr/local then rerun this script\n";
73 print
"ERROR! problem with downloading simpletest with wget, need a proxy?\n";
74 print
"wget output was:$wLast\n";print_r($wgetOut) .
"\n";
75 print
"Investigate and install simpletest into /usr/local then rerun this script\n";
80 print
"ERROR! cannot cd to /usr/local\n";
81 print
"Investigate and install simpletest into /usr/local then rerun this script\n";
92 print
"installing fo-runTests into /usr/local/bin\n";
94 $cmd =
"ln -s $wd/fo-runTests.php /usr/local/bin/fo-runTests 2>&1";
95 $last = exec($cmd, $tossme, $rtn);
97 $OK = preg_grep(
'/File exists/', $tossme);
99 print
"Error, could not create sym link in /usr/local/bin for fo-runTests\n";
103 $rm =
'rm /usr/local/bin/fo-runTests';
104 $last = exec($rm, $tossme, $rtn);
106 print
"Error, could not remove /usr/local/bin/fo-runTests\n";
107 print
"Remove by hand and remake the symbolic link to the appropriate test source\n";
110 $last = exec($cmd, $tossme, $rtn);
112 print
"Error, could not create sym link in /usr/local/bin for fo-runTests\n";
113 print
"Investigate and remake the symbolic link to the appropriate test source\n";
120 print
"Check to see if simpletest is installed in /usr/local\n";
122 if(!is_readable(
'/usr/local/simpletest')) {
123 print
"Attempting to download and install simpletest into /usr/local\n";
126 print
"FATAL ERROR!, install simpletest into /usr/local, then rerun this script\n";
134 if(!is_executable(
"./makeDbUser")) {
135 if(!chmod(
"./makeDbUser",0755)) {
136 print
"FATAL, could not make ./makeDbUser executable\n";
140 $last = exec(
"./makeDbUser",$tossme, $rtn);
142 print
"makeDbUser Failed, Investigate, run by hand\n";
145 print
"Creating fosstester and noemail users\n";
146 if(!is_executable(
"./CreateTestUser.sh")) {
147 if(!chmod(
"./CreateTestUser.sh",0755)) {
148 print
"FATAL, could not make ./CreateTestUser.sh executable\n";
152 $last = exec(
"./CreateTestUser.sh",$tossme, $rtn);
154 print
"CreateTestUser.sh Failed, Investigate, run by hand\n";
158 print
"loading test data into the fosstester home directory\n";
159 $last = exec(
"./installTestData.sh",$tossme, $rtn);
161 foreach($tossme as $line){
166 print
"adjusting servers file in .subversion so checkouts work\n";
167 if(chdir(
'/home/fosstester/.subversion') === TRUE) {
168 if(!copy(
'servers.hp',
'servers')) {
169 print
"Warning! could not adjust servers file, may not be able to check out sources\n";
173 if(chdir($Tconfig) === FALSE){
174 print
"Warning! cannot cd to $Tconfig, the next steps may fail\n";
179 print
"Creating UI test users fosstester and noemail\n";
181 $last = exec(
"./configTestEnv.php 'http://localhost/repo/' fossy fossy",$tossme, $rtn);
183 print
"./configTestEnv.php Failed for fossy, Investigate\n";
185 $last = exec(
"./fo-runTests.php -l 'createUIUsers.php'",$tossme, $rtn);
187 print
"./createUIUsers Failed!, Investigate\n";
189 $last = exec(
"./configTestEnv.php 'http://localhost/repo/' fosstester fosstester",$tossme, $rtn);
191 print
"./configTestEnv.php Failed for fosstester, Investigate\n";
196 echo
"Removing fo-runtests link in /usr/local/bin/\n";
197 $last = exec(
'sudo rm /usr/local/bin/fo-runTests', $tossme, $rtn);
198 echo
"Creating fo-runtests link in /usr/local/bin/\n";
199 $last = exec(
"ln -s fo-runtests.php /usr/local/bin/fo-runtests",$tossme, $rtn);
201 print
"FATAL! Could create fo-runtests link, Investigate and create by hand\n";