mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-13 00:07:26 +00:00
config: weave new migrations into convert_config(); closes #1156
This commit is contained in:
parent
152141866b
commit
c78c9ced21
@ -38,9 +38,6 @@ fi
|
||||
echo "Flush Phalcon volt templates"
|
||||
rm -f /usr/local/opnsense/mvc/app/cache/*.php
|
||||
|
||||
echo "Execute model migrations"
|
||||
/usr/local/opnsense/mvc/script/run_migrations.php
|
||||
|
||||
echo "Reloading GUI configuration"
|
||||
/usr/local/etc/rc.php_ini_setup
|
||||
if pgrep -q php-cgi; then
|
||||
|
||||
@ -40,12 +40,11 @@ $g = array(
|
||||
"dhcpd_chroot_path" => "/var/dhcpd",
|
||||
"unbound_chroot_path" => "/var/unbound",
|
||||
"product_name" => "OPNsense",
|
||||
"product_website" => "https://opnsense.org",
|
||||
"product_website" => "https://opnsense.org/",
|
||||
"product_email" => "project@opnsense.org",
|
||||
"product_copyright_owner" => "Deciso B.V.",
|
||||
"product_copyright_years" => "2014-2016",
|
||||
"product_copyright_url" => "https://www.deciso.com/",
|
||||
"latest_config" => "11.2",
|
||||
);
|
||||
|
||||
require_once("xmlparse.inc");
|
||||
@ -118,39 +117,45 @@ function parse_config()
|
||||
* null
|
||||
******/
|
||||
/* convert configuration, if necessary */
|
||||
function convert_config()
|
||||
function convert_config($verbose = false)
|
||||
{
|
||||
global $config, $g;
|
||||
global $config;
|
||||
|
||||
/* hardcode this, legacy migration path is now disabled */
|
||||
$latest_config = '11.2';
|
||||
|
||||
if (!isset($config['revision'])) {
|
||||
/* force a revision tag for proper handling in config history */
|
||||
write_config('Factory configuration', false);
|
||||
}
|
||||
|
||||
if ($config['version'] == $g['latest_config']) {
|
||||
/* already at latest version */
|
||||
return;
|
||||
if ($config['version'] !== $latest_config) {
|
||||
$prev_version = $config['version'];
|
||||
/* Loop and run upgrade_VER_to_VER() until we're at current version */
|
||||
while ($config['version'] < $latest_config) {
|
||||
$cur = $config['version'] * 10;
|
||||
$next = $cur + 1;
|
||||
$migration_function = sprintf('upgrade_%03d_to_%03d', $cur, $next);
|
||||
if (function_exists($migration_function)) {
|
||||
$migration_function();
|
||||
}
|
||||
$config['version'] = sprintf('%.1f', $next / 10);
|
||||
}
|
||||
|
||||
// Save off config version
|
||||
$prev_version = $config['version'];
|
||||
/* Loop and run upgrade_VER_to_VER() until we're at current version */
|
||||
while ($config['version'] < $g['latest_config']) {
|
||||
$cur = $config['version'] * 10;
|
||||
$next = $cur + 1;
|
||||
$migration_function = sprintf('upgrade_%03d_to_%03d', $cur, $next);
|
||||
if (function_exists($migration_function)) {
|
||||
$migration_function();
|
||||
if ($prev_version != $config['version']) {
|
||||
write_config(sprintf('Upgraded config version level from %s to %s', $prev_version, $config['version']));
|
||||
}
|
||||
$config['version'] = sprintf('%.1f', $next / 10);
|
||||
}
|
||||
|
||||
if ($prev_version != $config['version']) {
|
||||
write_config(sprintf('Upgraded config version level from %s to %s', $prev_version, $config['version']));
|
||||
/* chain the new migration into this function call */
|
||||
$mvc_migration = '/usr/local/opnsense/mvc/script/run_migrations.php';
|
||||
if ($verbose) {
|
||||
passthru($mvc_migration);
|
||||
} else {
|
||||
mwexecf($mvc_migraton);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/****f* config/write_config
|
||||
* NAME
|
||||
* write_config - Backup and write the firewall configuration.
|
||||
|
||||
@ -96,7 +96,7 @@ if ($setup_installer) {
|
||||
echo "Loading configuration...";
|
||||
global $config;
|
||||
$config = parse_config();
|
||||
convert_config();
|
||||
convert_config(true);
|
||||
echo "done.\n";
|
||||
|
||||
/*
|
||||
|
||||
@ -37,3 +37,4 @@ require_once 'system.inc';
|
||||
|
||||
system_firmware_configure();
|
||||
system_console_configure();
|
||||
convert_config(true);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user