27 function _modFossConf($sysConfPath, $repoPath)
29 if(!file_exists($sysConfPath .
'/fossology.conf'))
31 echo
"ERROR! can't find fossology.conf at:\n$sysConfPath/fossology.conf\n";
35 $fossConf = file_get_contents($sysConfPath .
'/fossology.conf');
36 if($fossConf === FALSE)
38 echo
"ERROR! could not read\n$sysConfPath/fossology.conf\n";
41 $pat =
'!/srv/fossology/repository!';
42 $testConf = preg_replace($pat, $repoPath, $fossConf);
43 $stat = file_put_contents(
"$sysConfPath/fossology.conf",$testConf);
46 echo
"ERROR! could not write\n$sysConfPath/fossology.conf\n";
64 function createTestDB($name)
68 return(
"Error, no DB name supplied\n");
74 $TESTROOT = dirname($path);
75 $_ENV[
'TESTROOT'] = $TESTROOT;
76 putenv(
"TESTROOT=$TESTROOT");
78 if(chdir($TESTROOT .
'/db') === FALSE)
80 return(
"FATAL! could no cd to $TESTROOT/db\n");
82 $cmd =
"sudo ./ftdbcreate.sh $name 2>&1";
83 exec($cmd, $cmdOut, $cmdRtn);
86 $err =
"Error could not create Data Base $name\n";
101 function RestoreFile($filename)
110 $lastCp = system(
"sudo cp $SYSCONFDIR/orig.$filename " .
111 "$SYSCONFDIR/$filename", $rtn);
112 if($lastCp === FALSE)
117 $lasRm = exec(
"sudo rm $SYSCONFDIR/orig.$filename", $rmOut, $rmRtn);
120 echo
"Trouble removing $SYSCONFDIR/orig.$filename, please " .
121 "investigate and remove by hand\n";
137 function SetRepo($sysConfPath,$repoPath)
139 if(empty($repoPath) || empty($sysConfPath))
143 return _modFossConf($sysConfPath,$repoPath);
157 function TestDBInit($path=NULL, $dbName)
161 $path = __DIR__ .
'/../../www/ui/core-schema.dat';
163 if (!file_exists($path))
165 return(
"FAILED: Schema data file ($path) not found.\n");
169 return(
"Error!, no catalog supplied\n");
175 $sysc = getenv(
'SYSCONFDIR');
176 $fossInit = __DIR__ .
'/../../../install/fossinit.php';
178 $cmd=
"$fossInit -d $dbName -f $path";
179 $last = exec($cmd, $upOut, $upRtn);
184 return(implode(
"\n", $upOut) .
"\n");