15 function guessSysconfdir()
17 $rcfile =
"fossology.rc";
18 $varfile = dirname(__DIR__).
'/variable.list';
19 $sysconfdir = getenv(
'SYSCONFDIR');
20 if ((
false===$sysconfdir) && file_exists($rcfile))
22 $sysconfdir = file_get_contents($rcfile);
24 if ((
false===$sysconfdir) && file_exists($varfile))
26 $ini_array = parse_ini_file($varfile);
27 if($ini_array!==
false && array_key_exists(
'SYSCONFDIR', $ini_array))
29 $sysconfdir = $ini_array[
'SYSCONFDIR'];
32 if (
false===$sysconfdir)
34 $text = _(
"FATAL! System Configuration Error, no SYSCONFDIR.");
60 if (empty($sysconfdir))
62 $sysconfdir = guessSysconfdir();
63 echo
"assuming SYSCONFDIR=$sysconfdir\n";
66 $sysconfdir =
trim($sysconfdir);
67 $GLOBALS[
'SYSCONFDIR'] = $sysconfdir;
70 $ConfFile =
"{$sysconfdir}/fossology.conf";
71 if (!file_exists($ConfFile))
73 $text = _(
"FATAL! Missing configuration file: $ConfFile");
77 $SysConf = parse_ini_file($ConfFile,
true);
78 if ($SysConf ===
false)
80 $text = _(
"FATAL! Invalid configuration file: $ConfFile");
89 foreach($SysConf[
'DIRECTORIES'] as $var=>$assign)
91 $toeval =
"\$$var = \"$assign\";";
95 $SysConf[
'DIRECTORIES'][$var] = ${$var};
96 $GLOBALS[$var] = ${$var};
101 $text = _(
"FATAL! System initialization failure: MODDIR not defined in $SysConf");
107 require_once(
"$MODDIR/lib/php/common.php");
108 require_once(
"$MODDIR/lib/php/Plugin/FO_Plugin.php");
123 return trim(shell_exec(
'bash -c ' .
124 escapeshellarg(
'fossstdin=' . escapeshellarg($default) .
125 ';read -t ' . ((
int)$seconds) .
' fossstdin;echo "$fossstdin"')));
char * trim(char *ptext)
Trimming whitespace.
bootstrap($sysconfdir="")
Determine SYSCONFDIR, parse fossology.conf.
readlineTimeout($seconds, $default)
Using bash's read command, read input from STDIN.