system: use singleton implementation everywhere

This commit is contained in:
Franco Fichtner 2023-02-07 15:42:31 +01:00
parent 0e286b3a34
commit 3e749e1132
2 changed files with 3 additions and 15 deletions

View File

@ -47,7 +47,7 @@ final class product
{
self::$data = json_decode(file_get_contents('/usr/local/opnsense/version/core'), true);
/* boot detection via exit_on_bootup() */
/* boot detection */
$bootflag = '/var/run/booting';
@touch($bootflag);
$fp = fopen($bootflag, 'r');

View File

@ -296,23 +296,11 @@ function unlock($cfglckkey = null)
function exit_on_bootup($callback = null, $arguments = [])
{
$bootflag = '/var/run/booting';
/* make sure file exists */
@touch($bootflag);
$fp = fopen($bootflag, 'r');
if (!$fp) {
/* log possible error and adjust exist code */
log_msg("exit_on_bootup(): error opening $bootflag", LOG_ERR);
exit(1);
}
if (!flock($fp, LOCK_SH | LOCK_NB)) {
if (product::getInstance()->booting()) {
if ($callback) {
call_user_func_array($callback, $arguments);
}
/* intentionally we exit here to avoid future cleverness WRT bootup handing */
/* intentionally we exit here to avoid future cleverness WRT bootup handling */
exit(0);
}