Commit c78c9ced authored by Franco Fichtner's avatar Franco Fichtner

config: weave new migrations into convert_config(); closes #1156

parent 15214186
...@@ -38,9 +38,6 @@ fi ...@@ -38,9 +38,6 @@ fi
echo "Flush Phalcon volt templates" echo "Flush Phalcon volt templates"
rm -f /usr/local/opnsense/mvc/app/cache/*.php 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" echo "Reloading GUI configuration"
/usr/local/etc/rc.php_ini_setup /usr/local/etc/rc.php_ini_setup
if pgrep -q php-cgi; then if pgrep -q php-cgi; then
......
...@@ -40,12 +40,11 @@ $g = array( ...@@ -40,12 +40,11 @@ $g = array(
"dhcpd_chroot_path" => "/var/dhcpd", "dhcpd_chroot_path" => "/var/dhcpd",
"unbound_chroot_path" => "/var/unbound", "unbound_chroot_path" => "/var/unbound",
"product_name" => "OPNsense", "product_name" => "OPNsense",
"product_website" => "https://opnsense.org", "product_website" => "https://opnsense.org/",
"product_email" => "project@opnsense.org", "product_email" => "project@opnsense.org",
"product_copyright_owner" => "Deciso B.V.", "product_copyright_owner" => "Deciso B.V.",
"product_copyright_years" => "2014-2016", "product_copyright_years" => "2014-2016",
"product_copyright_url" => "https://www.deciso.com/", "product_copyright_url" => "https://www.deciso.com/",
"latest_config" => "11.2",
); );
require_once("xmlparse.inc"); require_once("xmlparse.inc");
...@@ -118,39 +117,45 @@ function parse_config() ...@@ -118,39 +117,45 @@ function parse_config()
* null * null
******/ ******/
/* convert configuration, if necessary */ /* 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'])) { if (!isset($config['revision'])) {
/* force a revision tag for proper handling in config history */ /* force a revision tag for proper handling in config history */
write_config('Factory configuration', false); write_config('Factory configuration', false);
} }
if ($config['version'] == $g['latest_config']) { if ($config['version'] !== $latest_config) {
/* already at latest version */ $prev_version = $config['version'];
return; /* 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 if ($prev_version != $config['version']) {
$prev_version = $config['version']; write_config(sprintf('Upgraded config version level from %s to %s', $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();
} }
$config['version'] = sprintf('%.1f', $next / 10);
} }
if ($prev_version != $config['version']) { /* chain the new migration into this function call */
write_config(sprintf('Upgraded config version level from %s to %s', $prev_version, $config['version'])); $mvc_migration = '/usr/local/opnsense/mvc/script/run_migrations.php';
if ($verbose) {
passthru($mvc_migration);
} else {
mwexecf($mvc_migraton);
} }
} }
/****f* config/write_config /****f* config/write_config
* NAME * NAME
* write_config - Backup and write the firewall configuration. * write_config - Backup and write the firewall configuration.
......
...@@ -96,7 +96,7 @@ if ($setup_installer) { ...@@ -96,7 +96,7 @@ if ($setup_installer) {
echo "Loading configuration..."; echo "Loading configuration...";
global $config; global $config;
$config = parse_config(); $config = parse_config();
convert_config(); convert_config(true);
echo "done.\n"; echo "done.\n";
/* /*
......
...@@ -37,3 +37,4 @@ require_once 'system.inc'; ...@@ -37,3 +37,4 @@ require_once 'system.inc';
system_firmware_configure(); system_firmware_configure();
system_console_configure(); system_console_configure();
convert_config(true);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment