mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-22 13:12:41 +00:00
Add glue for dbconfig-common configuration
This commit is contained in:
parent
9687ce026e
commit
c2237532eb
4 changed files with 69 additions and 7 deletions
2
dist/debian/.gitignore
vendored
2
dist/debian/.gitignore
vendored
|
@ -6,6 +6,8 @@
|
|||
!copyright
|
||||
!lintian-overrides
|
||||
!rules
|
||||
!config.php
|
||||
!dbconfig-common.php
|
||||
|
||||
!source/
|
||||
source/*
|
||||
|
|
15
dist/debian/arsse.install
vendored
15
dist/debian/arsse.install
vendored
|
@ -8,10 +8,11 @@ UPGRADING usr/share/arsse/
|
|||
README.md usr/share/arsse/
|
||||
arsse.php usr/share/arsse/
|
||||
|
||||
dist/debian/bin/arsse usr/bin/
|
||||
manual usr/share/doc/arsse/
|
||||
dist/man/* usr/share/man/
|
||||
dist/nginx etc/arsse/
|
||||
dist/apache etc/arsse/
|
||||
dist/config.php etc/arsse
|
||||
config.defaults.php etc/arsse/
|
||||
config.defaults.php etc/arsse/
|
||||
manual usr/share/doc/arsse/
|
||||
dist/man/* usr/share/man/
|
||||
dist/nginx etc/arsse/
|
||||
dist/apache etc/arsse/
|
||||
dist/debian/config.php etc/arsse/
|
||||
dist/debian/dbconfig-cmmon.php usr/share/arsse/
|
||||
dist/debian/bin/arsse usr/bin/
|
||||
|
|
15
dist/debian/config.php
vendored
Normal file
15
dist/debian/config.php
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
/***
|
||||
Please refer to config.defaults.php or the manual at /usr/share/doc/arsse/
|
||||
for possible configuration parameters.
|
||||
|
||||
The last line includes database auto-configuration information which
|
||||
Debian may have created during installation; any database-related
|
||||
configuration defined in this file will override anything defined in the
|
||||
included file.
|
||||
***/
|
||||
|
||||
return [
|
||||
'dbAutoUpdate' => true,
|
||||
]
|
||||
+ (@include "/usr/share/arsse/dbconfig-common.php");
|
44
dist/debian/dbconfig-common.php
vendored
Normal file
44
dist/debian/dbconfig-common.php
vendored
Normal file
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
# This script transforms Debian's dbconfig-common's PHP-format include files
|
||||
# into a form usable by The Arsse. This is necessary because The Arsse
|
||||
# supports defining configuration parameters for all supported database types
|
||||
# at once, using separate keys for the different types
|
||||
|
||||
$dbconfpath = "/var/lib/arsse/dbconfig.inc"; // path defined in postinst script
|
||||
|
||||
if (file_exists($dbconfpath)) {
|
||||
require_once "/var/lib/arsse/dbconfig.inc";
|
||||
$dbtype = $dbtype ?? "";
|
||||
// the returned configuration depends on the $dbtype
|
||||
if ($dbtype === "sqlite3") {
|
||||
$conf = ['dbDriver' => "sqlite3"];
|
||||
if (strlen((string) $basepath) && strlen((string) $dbname)) {
|
||||
$conf['dbSQLite3File'] = "$basepath/$dbname";
|
||||
}
|
||||
} elseif ($dbtype === "pgsql") {
|
||||
$conf = [
|
||||
'dbDriver' => "postgresql",
|
||||
'dbPostgreSQLHost' => $dbserver ?? "",
|
||||
'dbPostgreSQLUser' => $dbuser ?? "arsse",
|
||||
'dbPostgreSQLPass' => $dbpass ?? "",
|
||||
'dbPostgreSQLPort' => $dbport ?? 5432,
|
||||
'dbPostgreSQLDb' => $dbname ?? "arsse",
|
||||
];
|
||||
} elseif ($dbtype === "mysql") {
|
||||
$conf = [
|
||||
'dbDriver' => "mysql",
|
||||
'dbMySQLHost' => $dbserver ?? "",
|
||||
'dbMySQLUser' => $dbuser ?? "arsse",
|
||||
'dbMySQLPass' => $dbpass ?? "",
|
||||
'dbMySQLPort' => $dbport ?? 3306,
|
||||
'dbMySQLDb' => $dbname ?? "arsse",
|
||||
];
|
||||
} else {
|
||||
throw new \Exception("Debian dbconfig-common configuration file $dbconfpath is invalid");
|
||||
}
|
||||
return $conf;
|
||||
} else {
|
||||
// if not configuration file exists simply return an empty array
|
||||
return [];
|
||||
}
|
Loading…
Reference in a new issue