38 $euid = posix_getuid();
40 print
"Error, this script must be run as root\n";
46 $f = exec(
'cat /etc/issue', $dist, $dRtn);
47 $distros = explode(
' ', $dist[0]);
54 switch ($distros[0]) {
57 $debianVersion = $distros[2];
58 echo
"debian version is:$debianVersion\n";
61 $Debian =
new ConfigSys($distros[0], $debianVersion);
65 echo
"FATAL! could not process ini file for Debian $debianVersion system\n";
68 echo
"*** Configure fossology ***\n";
71 echo
"FATAL! Could not config fossology on {$distros[0]} version $debianVersion\n";
77 $rhVersion = $distros[6];
81 $RedHat =
new ConfigSys($redHat, $rhVersion);
85 echo
"FATAL! could not process ini file for RedHat $rhVersion system\n";
89 echo
"*** Configure fossology ***\n";
92 echo
"FATAL! Could not config fossology on $redHat version $rhVersion\n";
98 echo
"Erorr! Could not stop Firewall, please stop by hand\n";
105 $rhVersion = $distros[2];
106 echo
"rh version is:$rhVersion\n";
109 $RedHat =
new ConfigSys($redHat, $rhVersion);
113 echo
"FATAL! could not process ini file for RedHat $rhVersion system\n";
117 echo
"*** Configure fossology ***\n";
120 echo
"FATAL! Could not config fossology on $redHat version $rhVersion\n";
124 if(!
stop(
'iptables'))
126 echo
"Erorr! Could not stop Firewall, please stop by hand\n";
133 $fedVersion = $distros[2];
136 $Fedora =
new ConfigSys($fedora, $fedVersion);
140 echo
"FATAL! could not process ini file for Fedora $fedVersion system\n";
144 echo
"*** Configure fossology ***\n";
147 echo
"FATAL! Could not config fossology on $fedora version $fedVersion\n";
150 $last = exec(
"systemctl stop iptables.service", $out, $rtn);
153 echo
"Erorr! Could not stop Firewall, please stop by hand\n";
159 $ubunVersion = $distros[1];
160 echo
"Ubuntu version is:$ubunVersion\n";
163 $Ubuntu =
new ConfigSys($distros[0], $ubunVersion);
167 echo
"FATAL! could not process ini file for Ubuntu $ubunVersion system\n";
171 echo
"*** Configure fossology ***\n";
174 echo
"FATAL! Could not config fossology on {$distros[0]} version $ubunVersion\n";
180 echo
"Fatal! unrecognized distribution! {$distros[0]}\n" ;
187 public $osVersion = 0;
188 private $fossVersion;
191 public $comment =
'';
194 function __construct($osFlavor, $osVersion)
198 throw new Exception(
"No Os Flavor supplied\n");
200 if(empty($osVersion))
202 throw new Exception(
"No Os Version Supplied\n");
205 $dataFile =
'../dataFiles/pkginstall/' . strtolower($osFlavor) .
'.ini';
206 $releases = parse_ini_file($dataFile, 1);
209 foreach($releases as $release => $values)
211 if($values[
'osversion'] == $osVersion)
214 $this->osFlavor = $values[
'osflavor'];
215 $this->osVersion = $values[
'osversion'];
216 $this->fossVersion = $values[
'fossversion'];
217 $this->osCodeName = $values[
'codename'];
219 switch (strtolower($this->osFlavor)) {
222 $this->deb = $values[
'deb'];
226 $this->yum = $values[
'yum'];
232 $this->comment = $values[
'comment'];
235 if($this->osVersion == 0)
237 throw new Exception(
"FATAL! no matching os flavor or version found\n");
250 echo
"Attributes of ConfigSys:\n";
251 echo
"\tosFlavor:$this->osFlavor\n";
252 echo
"\tosVersion:$this->osVersion\n";
253 echo
"\tfossVersion:$this->fossVersion\n";
254 echo
"\tosCodeName:$this->osCodeName\n";
255 echo
"\tdeb:$this->deb\n";
256 echo
"\tcomment:$this->comment\n";
257 echo
"\tyum:$this->yum\n";
273 if(!is_object($objRef))
281 switch ($objRef->osFlavor) {
284 $debApache =
"ln -s /usr/local/etc/fossology/conf/src-install-apache-example.conf /etc/apache2/sites-enabled/fossology.conf";
285 $last = exec($debApache, $out, $rtn);
289 echo
"Failed to config fossology!\nTranscript is:\n";
290 echo implode(
"\n",$out) .
"\n";
296 $initPostgres =
"service postgresql initdb";
297 $startPostgres =
"service postgresql start";
298 $restartPostgres =
"service postgresql restart";
299 $psqlFile =
"../dataFiles/pkginstall/redhat/6.x/pg_hba.conf";
301 echo
"** Initial postgresql **\n";
302 $last = exec($initPostgres, $out, $rtn);
305 echo
"Failed to initial postgresql!\nTranscript is:\n";
306 echo implode(
"\n",$out) .
"\n";
309 echo
"** Start postgresql **\n";
310 $last = exec($startPostgres, $out, $rtn);
313 echo
"Failed to start postgresql!\nTranscript is:\n";
314 echo implode(
"\n",$out) .
"\n";
317 echo
"** Configure pg_hba.conf **\n";
320 copyFiles($psqlFile,
"/var/lib/pgsql/data/");
324 echo
"Failure: Could not copy postgres config files\n";
326 $last = exec($restartPostgres, $out, $rtn);
329 echo
"Failed to restart postgresql!\nTranscript is:\n";
335 echo
"FATAL! Unrecongnized OS/Release, not one of Ubuntu, Debian, RedHat" .
360 throw new Exception(
'No file to copy', 0);
364 throw new Exception(
'No destination for copy', 0);
367 $login = posix_getlogin();
372 foreach($files as $file)
376 $baseFile = basename($file);
379 $to = $dest .
"/$baseFile";
387 if(!copy($file, $to))
389 throw new Exception(
"Could not copy $file to $to");
399 $baseFile = basename($files);
402 $to = $dest .
"/$baseFile";
410 if(!copy($files,$to))
412 throw new Exception(
"Could not copy $file to $to");
435 if(empty($osVersion))
444 echo
"debianConfig got os version 6.0!\n";
449 echo
"debianConfig got os version $osVersion!\n";
455 echo
"debianConfig got os version $osVersion!\n";
456 echo
"Old PHPunit installation with PEAR is deprecated, it is now done with composer.\n";
457 echo
"To install composer type:\n";
458 echo
"curl -sS https://getcomposer.org/installer | php && sudo mv composer.phar /usr/local/bin/composer\n ";
461 echo
"debianConfig got os version $osVersion!\n";
481 if(!is_object($objRef))
485 if(empty($objRef->yum))
487 echo
"FATAL, no yum install line to install\n";
491 if ($objRef->osFlavor ==
'RedHat')
493 $last = exec(
"yum -y install wget", $out, $rtn);
496 echo
"FATAL! install EPEL repo fail\n";
497 echo
"transcript is:\n";print_r($out) .
"\n";
500 $last = exec(
"wget -e http_proxy=http://lart.usa.hp.com:3128 http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm", $out, $rtn);
503 echo
"FATAL! install EPEL repo fail\n";
504 echo
"transcript is:\n";print_r($out) .
"\n";
507 $last = exec(
"rpm -ivh epel-release-6-8.noarch.rpm", $out, $rtn);
510 echo
"FATAL! install EPEL repo fail\n";
511 echo
"transcript is:\n";print_r($out) .
"\n";
514 $last = exec(
"yum -y install php-phpunit-PHPUnit", $out, $rtn);
517 echo
"FATAL! install PHPUnit fail\n";
518 echo
"transcript is:\n";print_r($out) .
"\n";
stop($application)
stop the application Assumes application is restartable via /etc/init.d/<script>. The application pas...
configYum($objRef)
config redhat based system to install fossology.
copyFiles($files, $dest)
copyFiles, copy one or more files to the destination, throws exception if file is not copied.
configDebian($osType, $osVersion)
config a debian based system to install fossology.
configFossology($objRef)
Config fossology.