mirror of
https://github.com/x86dev/docker-ttrss
synced 2025-12-13 01:46:00 +00:00
Now based on Alpine Linux and s6 as supervisor, resulting in a much smaller Docker image. See README.md for details and other additions.
This commit is contained in:
49
root/srv/ttrss-configure-plugin-mobilize.php
Normal file
49
root/srv/ttrss-configure-plugin-mobilize.php
Normal file
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
include '/srv/ttrss-utils.php';
|
||||
|
||||
$ename = 'DB';
|
||||
$eport = 5432;
|
||||
$confpath = '/var/www/ttrss/config.php';
|
||||
|
||||
// check DB_NAME, which will be set automatically for a linked "db" container
|
||||
if (!env($ename . '_PORT', '')) {
|
||||
error('The env ' . $ename .'_PORT does not exist. Make sure to run with "--link mypostgresinstance:' . $ename . '"');
|
||||
}
|
||||
|
||||
$config = array();
|
||||
$config['DB_TYPE'] = 'pgsql';
|
||||
$config['DB_HOST'] = env($ename . '_PORT_' . $eport . '_TCP_ADDR');
|
||||
$config['DB_PORT'] = env($ename . '_PORT_' . $eport . '_TCP_PORT');
|
||||
|
||||
// database credentials for this instance
|
||||
// database name (DB_NAME) can be supplied or detaults to "ttrss"
|
||||
// database user (DB_USER) can be supplied or defaults to database name
|
||||
// database pass (DB_PASS) can be supplied or defaults to database user
|
||||
$config['DB_NAME'] = env($ename . '_NAME', 'ttrss');
|
||||
$config['DB_USER'] = env($ename . '_USER', $config['DB_NAME']);
|
||||
$config['DB_PASS'] = env($ename . '_PASS', $config['DB_USER']);
|
||||
|
||||
$pdo = dbconnect($config);
|
||||
try {
|
||||
$pdo->query('SELECT 1 FROM plugin_mobilize_feeds');
|
||||
// reached this point => table found, assume db is complete
|
||||
}
|
||||
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 = preg_replace('/--(.*?);/', '', $schema);
|
||||
$schema = preg_replace('/[\r\n]/', ' ', $schema);
|
||||
$schema = trim($schema, ' ;');
|
||||
foreach (explode(';', $schema) as $stm) {
|
||||
$pdo->exec($stm);
|
||||
}
|
||||
unset($pdo);
|
||||
}
|
||||
|
||||
$contents = file_get_contents($confpath);
|
||||
foreach ($config as $name => $value) {
|
||||
$contents = preg_replace('/(define\s*\(\'' . $name . '\',\s*)(.*)(\);)/', '$1"' . $value . '"$3', $contents);
|
||||
}
|
||||
file_put_contents($confpath, $contents);
|
||||
Reference in New Issue
Block a user