Coin version 0.7.0, improve upgrade path

This commit is contained in:
Cyril 2019-10-14 15:33:06 +02:00
parent 4852f06ed4
commit 0d3f4969cf
5 changed files with 38 additions and 8 deletions

View file

@ -24,5 +24,5 @@
# This copyright notice MUST APPEAR in all copies of the script! # This copyright notice MUST APPEAR in all copies of the script!
################################################################# #################################################################
define("BAIKAL_VERSION", "0.6.0"); define("BAIKAL_VERSION", "0.7.0");
define("BAIKAL_HOMEPAGE", "http://sabre.io/baikal/"); define("BAIKAL_HOMEPAGE", "http://sabre.io/baikal/");

View file

@ -38,6 +38,17 @@ class Database extends \Flake\Core\Controller {
function execute() { function execute() {
$this->oModel = new \Baikal\Model\Config\System(PROJECT_PATH_CONFIG . "system.yaml"); $this->oModel = new \Baikal\Model\Config\System(PROJECT_PATH_CONFIG . "system.yaml");
if (file_exists(PROJECT_PATH_SPECIFIC . "config.system.php")) {
require_once(PROJECT_PATH_SPECIFIC . "config.system.php");
$this->oModel->set('PROJECT_SQLITE_FILE',PROJECT_SQLITE_FILE);
$this->oModel->set('PROJECT_DB_MYSQL',PROJECT_DB_MYSQL);
$this->oModel->set('PROJECT_DB_MYSQL_HOST',PROJECT_DB_MYSQL_HOST);
$this->oModel->set('PROJECT_DB_MYSQL_DBNAME',PROJECT_DB_MYSQL_DBNAME);
$this->oModel->set('PROJECT_DB_MYSQL_USERNAME',PROJECT_DB_MYSQL_USERNAME);
$this->oModel->set('PROJECT_DB_MYSQL_PASSWORD',PROJECT_DB_MYSQL_PASSWORD);
$this->oModel->set('BAIKAL_ENCRYPTION_KEY',BAIKAL_ENCRYPTION_KEY);
}
$this->oForm = $this->oModel->formForThisModelInstance([ $this->oForm = $this->oModel->formForThisModelInstance([
"close" => false, "close" => false,
"hook.validation" => [$this, "validateConnection"], "hook.validation" => [$this, "validateConnection"],
@ -48,6 +59,7 @@ class Database extends \Flake\Core\Controller {
$this->oForm->execute(); $this->oForm->execute();
if ($this->oForm->persisted()) { if ($this->oForm->persisted()) {
unlink(PROJECT_PATH_SPECIFIC . "config.system.php");
touch(PROJECT_PATH_SPECIFIC . '/INSTALL_DISABLED'); touch(PROJECT_PATH_SPECIFIC . '/INSTALL_DISABLED');
} }
} }

View file

@ -47,6 +47,16 @@ class Initialize extends \Flake\Core\Controller {
$this->oModel = new \Baikal\Model\Config\Standard(PROJECT_PATH_CONFIG . "config.yaml"); $this->oModel = new \Baikal\Model\Config\Standard(PROJECT_PATH_CONFIG . "config.yaml");
// If we come from pre-0.7.0, we need to get the values from the config.php and config.system.php files
if (file_exists(PROJECT_PATH_SPECIFIC . "config.php")) {
require_once(PROJECT_PATH_SPECIFIC . "config.php");
$this->oModel->set('PROJECT_TIMEZONE', PROJECT_TIMEZONE);
$this->oModel->set('BAIKAL_CARD_ENABLED', BAIKAL_CARD_ENABLED);
$this->oModel->set('BAIKAL_CAL_ENABLED', BAIKAL_CAL_ENABLED);
$this->oModel->set('BAIKAL_INVITE_FROM', BAIKAL_INVITE_FROM);
$this->oModel->set('BAIKAL_DAV_AUTH_TYPE', BAIKAL_DAV_AUTH_TYPE);
}
$this->oForm = $this->oModel->formForThisModelInstance([ $this->oForm = $this->oModel->formForThisModelInstance([
"close" => false "close" => false
]); ]);
@ -56,6 +66,14 @@ class Initialize extends \Flake\Core\Controller {
if ($this->oForm->persisted()) { if ($this->oForm->persisted()) {
// If we come from pre-0.7.0, we need to remove the INSTALL_DISABLED file so we go to the next step
if (file_exists(PROJECT_PATH_SPECIFIC . '/INSTALL_DISABLED')) {
unlink(PROJECT_PATH_SPECIFIC . '/INSTALL_DISABLED');
}
if (file_exists(PROJECT_PATH_SPECIFIC . "config.php")) {
unlink(PROJECT_PATH_SPECIFIC . "config.php");
}
# Creating system config, and initializing BAIKAL_ENCRYPTION_KEY # Creating system config, and initializing BAIKAL_ENCRYPTION_KEY
$oSystemConfig = new \Baikal\Model\Config\System(PROJECT_PATH_CONFIG . "system.yaml"); $oSystemConfig = new \Baikal\Model\Config\System(PROJECT_PATH_CONFIG . "system.yaml");
$oSystemConfig->set("BAIKAL_ENCRYPTION_KEY", md5(microtime() . rand())); $oSystemConfig->set("BAIKAL_ENCRYPTION_KEY", md5(microtime() . rand()));

View file

@ -525,24 +525,24 @@ SQL
protected function updateConfiguredVersion($sVersionTo) { protected function updateConfiguredVersion($sVersionTo) {
# Create new settings # Create new settings
$oConfig = new \Baikal\Model\Config\Standard(PROJECT_PATH_SPECIFIC . "config.php"); $oConfig = new \Baikal\Model\Config\Standard(PROJECT_PATH_CONFIG . "config.yaml");
$oConfig->persist(); $oConfig->persist();
# Update BAIKAL_CONFIGURED_VERSION # Update BAIKAL_CONFIGURED_VERSION
$oConfig = new \Baikal\Model\Config\System(PROJECT_PATH_SPECIFIC . "config.system.php"); $oConfig = new \Baikal\Model\Config\System(PROJECT_PATH_CONFIG . "system.yaml");
$oConfig->set("BAIKAL_CONFIGURED_VERSION", $sVersionTo); $oConfig->set("BAIKAL_CONFIGURED_VERSION", $sVersionTo);
$oConfig->persist(); $oConfig->persist();
} }
protected function assertConfigWritable() { protected function assertConfigWritable() {
# Parsing the config also makes sure that it is not malformed # Parsing the config also makes sure that it is not malformed
$oConfig = new \Baikal\Model\Config\Standard(PROJECT_PATH_SPECIFIC . "config.php"); $oConfig = new \Baikal\Model\Config\Standard(PROJECT_PATH_CONFIG . "config.yaml");
if ($oConfig->writable() === false) { if ($oConfig->writable() === false) {
throw new \Exception(PROJECT_PATH_SPECIFIC . "config.php is not writable"); throw new \Exception(PROJECT_PATH_CONFIG . "config.yaml is not writable");
} }
$oConfig = new \Baikal\Model\Config\System(PROJECT_PATH_SPECIFIC . "config.system.php"); $oConfig = new \Baikal\Model\Config\System(PROJECT_PATH_CONFIG . "system.yaml");
if ($oConfig->writable() === false) { if ($oConfig->writable() === false) {
throw new \Exception(PROJECT_PATH_SPECIFIC . "config.system.php is not writable"); throw new \Exception(PROJECT_PATH_CONFIG . "system.yaml is not writable");
} }
} }
} }

View file

@ -6,4 +6,4 @@ parameters:
PROJECT_DB_MYSQL_USERNAME: 'baikal' PROJECT_DB_MYSQL_USERNAME: 'baikal'
PROJECT_DB_MYSQL_PASSWORD: 'baikal' PROJECT_DB_MYSQL_PASSWORD: 'baikal'
BAIKAL_ENCRYPTION_KEY: '5d3f0fa0192e3058ea70f1bb20924add' BAIKAL_ENCRYPTION_KEY: '5d3f0fa0192e3058ea70f1bb20924add'
BAIKAL_CONFIGURED_VERSION: '0.6.0' BAIKAL_CONFIGURED_VERSION: '0.7.0'