1
0
mirror of https://github.com/x86dev/docker-ttrss synced 2025-12-13 01:46:00 +00:00

Added MySql option

This commit is contained in:
Thomas Ziegler
2017-05-28 21:33:05 +02:00
parent 10b77321bc
commit 04858d609d
6 changed files with 36 additions and 5 deletions

View File

@@ -10,6 +10,11 @@ $conffile = $confpath . 'config.php';
$ename = 'DB';
$eport = 5432;
$db_type = env('DB_TYPE','pgsql');
if ($db_type == 'mysql'){
$eport = 3306;
}
echo 'Configuring database for: ' . $conffile . PHP_EOL;
// check DB_NAME, which will be set automatically for a linked "db" container
@@ -18,7 +23,7 @@ if (!env($ename . '_PORT', '')) {
}
$config = array();
$config['DB_TYPE'] = 'pgsql';
$config['DB_TYPE'] = $db_type;
$config['DB_HOST'] = env($ename . '_PORT_' . $eport . '_TCP_ADDR');
$config['DB_PORT'] = env($ename . '_PORT_' . $eport . '_TCP_PORT');

View File

@@ -5,6 +5,11 @@ include '/srv/ttrss-utils.php';
$ename = 'DB';
$eport = 5432;
$db_type = env('DB_TYPE','pgsql');
if ($db_type == 'mysql'){
$eport = 3306;
}
$confpath = '/var/www/ttrss/config.php';
// check DB_NAME, which will be set automatically for a linked "db" container
@@ -13,7 +18,7 @@ if (!env($ename . '_PORT', '')) {
}
$config = array();
$config['DB_TYPE'] = 'pgsql';
$config['DB_TYPE'] = $db_type;
$config['DB_HOST'] = env($ename . '_PORT_' . $eport . '_TCP_ADDR');
$config['DB_PORT'] = env($ename . '_PORT_' . $eport . '_TCP_PORT');
@@ -32,7 +37,7 @@ try {
}
catch (PDOException $e) {
echo 'Database table for mobilize plugin not found, applying schema... ' . PHP_EOL;
$schema = file_get_contents('/srv/ttrss-plugin-mobilize.pgsql');
$schema = file_get_contents('/srv/ttrss-plugin-mobilize.'.$db_type);
$schema = preg_replace('/--(.*?);/', '', $schema);
$schema = preg_replace('/[\r\n]/', ' ', $schema);
$schema = trim($schema, ' ;');

View File

@@ -0,0 +1,9 @@
CREATE TABLE plugin_mobilize_feeds ( id int NOT NULL, owner_uid int NOT NULL, mobilizer_id int NOT NULL, PRIMARY KEY (id,owner_uid) );
CREATE TABLE plugin_mobilize_mobilizers ( id int NOT NULL, description varchar(255) NOT NULL, url varchar(1000) NOT NULL, PRIMARY KEY (id) ) ;
INSERT INTO plugin_mobilize_mobilizers ( id, description, url) VALUES
(0, 'Readability', 'http://www.readability.com/m?url=%s'),
(1, 'Instapaper', 'http://www.instapaper.com/m?u=%s'),
(2, 'Google Mobilizer', 'http://www.google.com/gwt/x?u=%s'),
(3, 'Original Stripped', 'http://strip=%s'),
(4, 'Original', '%s');

View File

@@ -26,7 +26,12 @@ function dbconnect($config)
$dsn .= $d . '=' . $config['DB_' . $h] . ';';
}
}
$pdo = new \PDO($dsn);
echo($dsn);
if ($config['DB_TYPE'] == 'pgsql'){
$pdo = new \PDO($dsn);
} else {
$pdo = new \PDO($dsn, $config['DB_USER'], $config['DB_PASS']);
}
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
return $pdo;
}