49 $euid = posix_getuid();
51 print
"Error, this script must be run as root\n";
57 $f = exec(
'cat /etc/issue', $dist, $dRtn);
58 $distros = explode(
' ', $dist[0]);
65 switch ($distros[0]) {
68 $debianVersion = $distros[2];
69 echo
"debian version is:$debianVersion\n";
72 $Debian =
new ConfigSys($distros[0], $debianVersion);
76 echo
"FATAL! could not process ini file for Debian $debianVersion system\n";
79 echo
"*** Configure fossology ***\n";
82 echo
"FATAL! Could not config fossology on {$distros[0]} version $debianVersion\n";
88 $rhVersion = $distros[6];
92 $RedHat =
new ConfigSys($redHat, $rhVersion);
96 echo
"FATAL! could not process ini file for RedHat $rhVersion system\n";
100 echo
"*** Configure fossology ***\n";
103 echo
"FATAL! Could not config fossology on $redHat version $rhVersion\n";
107 if(!
stop(
'iptables'))
109 echo
"Erorr! Could not stop Firewall, please stop by hand\n";
116 $rhVersion = $distros[2];
117 echo
"rh version is:$rhVersion\n";
120 $RedHat =
new ConfigSys($redHat, $rhVersion);
124 echo
"FATAL! could not process ini file for RedHat $rhVersion system\n";
128 echo
"*** Configure fossology ***\n";
131 echo
"FATAL! Could not config fossology on $redHat version $rhVersion\n";
135 if(!
stop(
'iptables'))
137 echo
"Erorr! Could not stop Firewall, please stop by hand\n";
144 $fedVersion = $distros[2];
147 $Fedora =
new ConfigSys($fedora, $fedVersion);
151 echo
"FATAL! could not process ini file for Fedora $fedVersion system\n";
155 echo
"*** Configure fossology ***\n";
158 echo
"FATAL! Could not config fossology on $fedora version $fedVersion\n";
161 $last = exec(
"systemctl stop iptables.service", $out, $rtn);
164 echo
"Erorr! Could not stop Firewall, please stop by hand\n";
170 $ubunVersion = $distros[1];
171 echo
"Ubuntu version is:$ubunVersion\n";
174 $Ubuntu =
new ConfigSys($distros[0], $ubunVersion);
178 echo
"FATAL! could not process ini file for Ubuntu $ubunVersion system\n";
182 echo
"*** Configure fossology ***\n";
185 echo
"FATAL! Could not config fossology on {$distros[0]} version $ubunVersion\n";
191 echo
"Fatal! unrecognized distribution! {$distros[0]}\n" ;
198 public $osVersion = 0;
199 private $fossVersion;
202 public $comment =
'';
205 function __construct($osFlavor, $osVersion)
209 throw new Exception(
"No Os Flavor supplied\n");
211 if(empty($osVersion))
213 throw new Exception(
"No Os Version Supplied\n");
216 $dataFile =
'../dataFiles/pkginstall/' . strtolower($osFlavor) .
'.ini';
217 $releases = parse_ini_file($dataFile, 1);
220 foreach($releases as $release => $values)
222 if($values[
'osversion'] == $osVersion)
225 $this->osFlavor = $values[
'osflavor'];
226 $this->osVersion = $values[
'osversion'];
227 $this->fossVersion = $values[
'fossversion'];
228 $this->osCodeName = $values[
'codename'];
230 switch (strtolower($this->osFlavor)) {
233 $this->deb = $values[
'deb'];
237 $this->yum = $values[
'yum'];
243 $this->comment = $values[
'comment'];
246 if($this->osVersion == 0)
248 throw new Exception(
"FATAL! no matching os flavor or version found\n");
261 echo
"Attributes of ConfigSys:\n";
262 echo
"\tosFlavor:$this->osFlavor\n";
263 echo
"\tosVersion:$this->osVersion\n";
264 echo
"\tfossVersion:$this->fossVersion\n";
265 echo
"\tosCodeName:$this->osCodeName\n";
266 echo
"\tdeb:$this->deb\n";
267 echo
"\tcomment:$this->comment\n";
268 echo
"\tyum:$this->yum\n";
284 if(!is_object($objRef))
292 switch ($objRef->osFlavor) {
295 $debApache =
"ln -s /usr/local/etc/fossology/conf/src-install-apache-example.conf /etc/apache2/sites-enabled/fossology.conf";
296 $last = exec($debApache, $out, $rtn);
300 echo
"Failed to config fossology!\nTranscript is:\n";
301 echo implode(
"\n",$out) .
"\n";
307 $initPostgres =
"service postgresql initdb";
308 $startPostgres =
"service postgresql start";
309 $restartPostgres =
"service postgresql restart";
310 $psqlFile =
"../dataFiles/pkginstall/redhat/6.x/pg_hba.conf";
312 echo
"** Initial postgresql **\n";
313 $last = exec($initPostgres, $out, $rtn);
316 echo
"Failed to initial postgresql!\nTranscript is:\n";
317 echo implode(
"\n",$out) .
"\n";
320 echo
"** Start postgresql **\n";
321 $last = exec($startPostgres, $out, $rtn);
324 echo
"Failed to start postgresql!\nTranscript is:\n";
325 echo implode(
"\n",$out) .
"\n";
328 echo
"** Configure pg_hba.conf **\n";
331 copyFiles($psqlFile,
"/var/lib/pgsql/data/");
335 echo
"Failure: Could not copy postgres config files\n";
337 $last = exec($restartPostgres, $out, $rtn);
340 echo
"Failed to restart postgresql!\nTranscript is:\n";
346 echo
"FATAL! Unrecongnized OS/Release, not one of Ubuntu, Debian, RedHat" .
371 throw new Exception(
'No file to copy', 0);
375 throw new Exception(
'No destination for copy', 0);
378 $login = posix_getlogin();
383 foreach($files as $file)
387 $baseFile = basename($file);
390 $to = $dest .
"/$baseFile";
398 if(!copy($file, $to))
400 throw new Exception(
"Could not copy $file to $to");
410 $baseFile = basename($files);
413 $to = $dest .
"/$baseFile";
421 if(!copy($files,$to))
423 throw new Exception(
"Could not copy $file to $to");
446 if(empty($osVersion))
455 echo
"debianConfig got os version 6.0!\n";
460 echo
"debianConfig got os version $osVersion!\n";
466 echo
"debianConfig got os version $osVersion!\n";
467 echo
"Old PHPunit installation with PEAR is deprecated, it is now done with composer.\n";
468 echo
"To install composer type:\n";
469 echo
"curl -sS https://getcomposer.org/installer | php && sudo mv composer.phar /usr/local/bin/composer\n ";
472 echo
"debianConfig got os version $osVersion!\n";
492 if(!is_object($objRef))
496 if(empty($objRef->yum))
498 echo
"FATAL, no yum install line to install\n";
502 if ($objRef->osFlavor ==
'RedHat')
504 $last = exec(
"yum -y install wget", $out, $rtn);
507 echo
"FATAL! install EPEL repo fail\n";
508 echo
"transcript is:\n";print_r($out) .
"\n";
511 $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);
514 echo
"FATAL! install EPEL repo fail\n";
515 echo
"transcript is:\n";print_r($out) .
"\n";
518 $last = exec(
"rpm -ivh epel-release-6-8.noarch.rpm", $out, $rtn);
521 echo
"FATAL! install EPEL repo fail\n";
522 echo
"transcript is:\n";print_r($out) .
"\n";
525 $last = exec(
"yum -y install php-phpunit-PHPUnit", $out, $rtn);
528 echo
"FATAL! install PHPUnit fail\n";
529 echo
"transcript is:\n";print_r($out) .
"\n";
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...
configFossology($objRef)
Config fossology.
stop($application)
stop the application Assumes application is restartable via /etc/init.d/<script>. The application pas...
configDebian($osType, $osVersion)
config a debian based system to install fossology.