26 function guessSysconfdir()
28 $rcfile =
"fossology.rc";
29 $varfile = dirname(__DIR__).
'/variable.list';
30 $sysconfdir = getenv(
'SYSCONFDIR');
31 if ((
false===$sysconfdir) && file_exists($rcfile))
33 $sysconfdir = file_get_contents($rcfile);
35 if ((
false===$sysconfdir) && file_exists($varfile))
37 $ini_array = parse_ini_file($varfile);
38 if($ini_array!==
false && array_key_exists(
'SYSCONFDIR', $ini_array))
40 $sysconfdir = $ini_array[
'SYSCONFDIR'];
43 if (
false===$sysconfdir)
45 $text = _(
"FATAL! System Configuration Error, no SYSCONFDIR.");
71 if (empty($sysconfdir))
73 $sysconfdir = guessSysconfdir();
74 echo
"assuming SYSCONFDIR=$sysconfdir\n";
77 $sysconfdir =
trim($sysconfdir);
78 $GLOBALS[
'SYSCONFDIR'] = $sysconfdir;
81 $ConfFile =
"{$sysconfdir}/fossology.conf";
82 if (!file_exists($ConfFile))
84 $text = _(
"FATAL! Missing configuration file: $ConfFile");
88 $SysConf = parse_ini_file($ConfFile,
true);
89 if ($SysConf ===
false)
91 $text = _(
"FATAL! Invalid configuration file: $ConfFile");
100 foreach($SysConf[
'DIRECTORIES'] as $var=>$assign)
102 $toeval =
"\$$var = \"$assign\";";
106 $SysConf[
'DIRECTORIES'][$var] = ${$var};
107 $GLOBALS[$var] = ${$var};
112 $text = _(
"FATAL! System initialization failure: MODDIR not defined in $SysConf");
118 require_once(
"$MODDIR/lib/php/common.php");
119 require_once(
"$MODDIR/lib/php/Plugin/FO_Plugin.php");
134 return trim(shell_exec(
'bash -c ' .
135 escapeshellarg(
'fossstdin=' . escapeshellarg($default) .
136 ';read -t ' . ((
int)$seconds) .
' fossstdin;echo "$fossstdin"')));
bootstrap($sysconfdir="")
Determine SYSCONFDIR, parse fossology.conf.
readlineTimeout($seconds, $default)
Using bash's read command, read input from STDIN.
char * trim(char *ptext)
Trimming whitespace.