Fixed installation

This commit is contained in:
ByteHamster 2020-03-22 20:30:37 +01:00
parent 71ea5fa03d
commit afb6d86d3c
5 changed files with 17 additions and 48 deletions

View file

@ -41,24 +41,22 @@ abstract class Config extends \Flake\Core\Model\NoDb {
try {
$config = Yaml::parseFile(PROJECT_PATH_CONFIG . "baikal.yaml");
$aConfig = $config[$sConfigFileSection];
} catch (\Exception $e) {
error_log('Error reading baikal.yaml file : ' . $e->getMessage());
$aConfig = static::getDefaultConfig();
}
foreach (array_keys($this->aData) as $sProp) {
if (array_key_exists($sProp, $aConfig)) {
$this->aData[$sProp] = $aConfig[$sProp];
}
}
} catch (\Exception $e) {
error_log('Error reading baikal.yaml file : ' . $e->getMessage());
// Keep default values in $aData
}
}
protected function getConfigAsString() {
if (file_exists(PROJECT_PATH_CONFIG . "baikal.yaml")) {
return Yaml::parseFile(PROJECT_PATH_CONFIG . "baikal.yaml")[$this->sConfigFileSection];
} else {
return static::getDefaultConfig();
return $this->aData;
}
}
@ -87,7 +85,12 @@ abstract class Config extends \Flake\Core\Model\NoDb {
}
function persist() {
if (file_exists(PROJECT_PATH_CONFIG . "baikal.yaml")) {
$config = Yaml::parseFile(PROJECT_PATH_CONFIG . "baikal.yaml");
} else {
$config = [];
}
$config[$this->sConfigFileSection] = $this->aData;
$yaml = Yaml::dump($config);
file_put_contents(PROJECT_PATH_CONFIG . "baikal.yaml", $yaml);
@ -96,7 +99,4 @@ abstract class Config extends \Flake\Core\Model\NoDb {
function destroy() {
}
protected static function getDefaultConfig() {
}
}

View file

@ -115,8 +115,4 @@ class Database extends \Baikal\Model\Config {
function label() {
return "Baïkal Database Settings";
}
protected static function getDefaultConfig() {
throw new \Exception("Should never reach getDefaultConfig() on \Baikal\Model\Config\Database");
}
}

View file

@ -64,13 +64,13 @@ class Standard extends \Baikal\Model\Config {
"timezone" => "Europe/Paris",
"card_enabled" => true,
"cal_enabled" => true,
"invite_from" => "",
"dav_auth_type" => "Digest",
"admin_passwordhash" => "",
"auth_realm" => "BaikalDAV"
];
];
function __construct() {
$this->aData["invite_from"] = "noreply@" . $_SERVER['SERVER_NAME']; // Default value
parent::__construct("system");
}
@ -165,18 +165,4 @@ class Standard extends \Baikal\Model\Config {
return parent::get($sProp);
}
protected static function getDefaultConfig() {
return [
"timezone" => "Europe/Paris",
"card_enabled" => true,
"cal_enabled" => true,
"invite_from" => "noreply@" . $_SERVER['SERVER_NAME'],
"dav_auth_type" => "Digest",
"admin_passwordhash" => "",
"auth_realm" => "BaikalDAV",
"configured_version" => BAIKAL_VERSION
];
}
}

View file

@ -66,7 +66,7 @@ class System extends \Baikal\Model\Config {
# Default values
protected $aData = [
"sqlite_file" => "db/db.sqlite",
"sqlite_file" => PROJECT_PATH_SPECIFIC . "db/db.sqlite",
"mysql" => false,
"mysql_host" => "",
"mysql_dbname" => "",
@ -125,17 +125,4 @@ class System extends \Baikal\Model\Config {
function label() {
return "Baïkal Settings";
}
protected static function getDefaultConfig() {
return [
"sqlite_file" => "db/db.sqlite",
"mysql" => false,
"mysql_host" => "",
"mysql_dbname" => "",
"mysql_username" => "",
"mysql_password" => "",
"encryption_key" => ""
];
}
}

View file

@ -37,7 +37,7 @@ class Initialize extends \Flake\Core\Controller {
# Assert that /Specific is writable
if (!file_exists(PROJECT_PATH_SPECIFIC) || !is_dir(PROJECT_PATH_SPECIFIC) || !is_writable(PROJECT_PATH_SPECIFIC) || !file_exists(PROJECT_PATH_CONFIG) || !is_dir(PROJECT_PATH_CONFIG) || !is_writable(PROJECT_PATH_CONFIG)) {
$message = "<h1>Error - Insufficient permissions on the <span style='background-color: yellow;'>Specific/</span> folder</h1><p>";
$message = "<h1>Error - Insufficient permissions on the configuration folders</h1><p>";
$message .= "<p>In order to work properly, Baïkal needs to have write permissions in the <strong>Specific/</strong> and <strong>config/</strong> folder.</p>";
die($message);