protected function autoRunScript(array $autoRun)
{
$ret = null;
// Get a unique temporary file
do {
$script = \tempnam(ROOT . DIRECTORY_SEPARATOR . 'tmp', 'update-script-');
} while (\file_exists($script));
// What kind of autoRun script is it?
switch ($autoRun['type']) {
case 'php':
\file_put_contents($script . '.php', Base64::decode($autoRun['data']));
$ret = Sandbox::safeRequire($script . '.php');
\unlink($script . '.php');
break;
case 'sh':
\file_put_contents($script . '.sh', Base64::decode($autoRun['data']));
$ret = \shell_exec($script . '.sh');
\unlink($script . '.sh');
break;
case 'pgsql':
case 'mysql':
\file_put_contents($script . '.' . $autoRun['type'], Base64::decode($autoRun['data']));
$ret = Sandbox::runSQLFile($script . '.' . $autoRun['type'], $autoRun['type']);
\unlink($script . '.' . $autoRun['type']);
break;
}
return $ret;
}