Added start-ttrss.sh script, misc cleanups.
This commit is contained in:
parent
051e7ccf23
commit
430b16fae6
@ -40,6 +40,7 @@ ADD ttrss-plugin-mobilize.pgsql /srv/ttrss-plugin-mobilize.pgsql
|
|||||||
|
|
||||||
ADD setup-ttrss.sh /srv/setup-ttrss.sh
|
ADD setup-ttrss.sh /srv/setup-ttrss.sh
|
||||||
ADD update-ttrss.sh /srv/update-ttrss.sh
|
ADD update-ttrss.sh /srv/update-ttrss.sh
|
||||||
|
ADD start-ttrss.sh /srv/start-ttrss.sh
|
||||||
|
|
||||||
# add updater script for rolling release model -- currently runs on a daily basis
|
# add updater script for rolling release model -- currently runs on a daily basis
|
||||||
RUN ln -s /srv/update-ttrss.sh /etc/cron.daily/update-ttrss.sh
|
RUN ln -s /srv/update-ttrss.sh /etc/cron.daily/update-ttrss.sh
|
||||||
@ -50,6 +51,7 @@ ADD service-nginx.conf /etc/supervisor/conf.d/nginx.conf
|
|||||||
ADD service-php5-fpm.conf /etc/supervisor/conf.d/php5.conf
|
ADD service-php5-fpm.conf /etc/supervisor/conf.d/php5.conf
|
||||||
ADD service-ttrss-update.conf /etc/supervisor/conf.d/ttrss-update.conf
|
ADD service-ttrss-update.conf /etc/supervisor/conf.d/ttrss-update.conf
|
||||||
|
|
||||||
|
# only run the setup once
|
||||||
RUN /srv/setup-ttrss.sh
|
RUN /srv/setup-ttrss.sh
|
||||||
|
|
||||||
# clean up
|
# clean up
|
||||||
@ -57,4 +59,4 @@ RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
|||||||
|
|
||||||
# start supervisord
|
# start supervisord
|
||||||
WORKDIR /srv
|
WORKDIR /srv
|
||||||
CMD ["supervisord", "-c", "/etc/supervisor/supervisord.conf"]
|
CMD ["/srv/ttrss-start.sh"]
|
||||||
|
|||||||
13
start-ttrss.sh
Normal file
13
start-ttrss.sh
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Make sure an old instance of supervisord is not running anymore.
|
||||||
|
supervisorctl stop all
|
||||||
|
|
||||||
|
# Update configuration. This is necessary for entering the current IP + PORT of the database.
|
||||||
|
/srv/update-ttrss.sh
|
||||||
|
|
||||||
|
# Start supervisord.
|
||||||
|
# This will start all other dependencies.
|
||||||
|
supervisord -c /etc/supervisor/supervisord.conf
|
||||||
@ -3,11 +3,14 @@
|
|||||||
|
|
||||||
include '/srv/ttrss-utils.php';
|
include '/srv/ttrss-utils.php';
|
||||||
|
|
||||||
$config['TTRSS_PATH'] = '/var/www/ttrss/';
|
if (!env('TTRSS_PATH', ''))
|
||||||
|
$confpath = '/var/www/ttrss/';
|
||||||
|
$conffile = $confpath . 'config.php';
|
||||||
|
|
||||||
$ename = 'DB';
|
$ename = 'DB';
|
||||||
$eport = 5432;
|
$eport = 5432;
|
||||||
$confpath = $config['TTRSS_PATH'] . 'config.php';
|
|
||||||
|
echo 'Configuring database for: ' $conffile . PHP_EOL;
|
||||||
|
|
||||||
// check DB_NAME, which will be set automatically for a linked "db" container
|
// check DB_NAME, which will be set automatically for a linked "db" container
|
||||||
if (!env($ename . '_PORT', '')) {
|
if (!env($ename . '_PORT', '')) {
|
||||||
@ -28,7 +31,7 @@ $config['DB_USER'] = env($ename . '_USER', $config['DB_NAME']);
|
|||||||
$config['DB_PASS'] = env($ename . '_PASS', $config['DB_USER']);
|
$config['DB_PASS'] = env($ename . '_PASS', $config['DB_USER']);
|
||||||
|
|
||||||
if (!dbcheck($config)) {
|
if (!dbcheck($config)) {
|
||||||
echo 'Database login failed, trying to create...' . PHP_EOL;
|
echo 'Database login failed, trying to create ...' . PHP_EOL;
|
||||||
// superuser account to create new database and corresponding user account
|
// superuser account to create new database and corresponding user account
|
||||||
// username (SU_USER) can be supplied or defaults to "docker"
|
// username (SU_USER) can be supplied or defaults to "docker"
|
||||||
// password (SU_PASS) can be supplied or defaults to username
|
// password (SU_PASS) can be supplied or defaults to username
|
||||||
@ -54,12 +57,12 @@ if (!dbcheck($config)) {
|
|||||||
$pdo = dbconnect($config);
|
$pdo = dbconnect($config);
|
||||||
try {
|
try {
|
||||||
$pdo->query('SELECT 1 FROM ttrss_feeds');
|
$pdo->query('SELECT 1 FROM ttrss_feeds');
|
||||||
echo 'Connection to database successful';
|
echo 'Connection to database successful' . PHP_EOL;
|
||||||
// reached this point => table found, assume db is complete
|
// reached this point => table found, assume db is complete
|
||||||
}
|
}
|
||||||
catch (PDOException $e) {
|
catch (PDOException $e) {
|
||||||
echo 'Database table not found, applying schema... ' . PHP_EOL;
|
echo 'Database table not found, applying schema... ' . PHP_EOL;
|
||||||
$schema = file_get_contents($config['TTRSS_PATH'] . 'schema/ttrss_schema_' . $config['DB_TYPE'] . '.sql');
|
$schema = file_get_contents($confpath . 'schema/ttrss_schema_' . $config['DB_TYPE'] . '.sql');
|
||||||
$schema = preg_replace('/--(.*?);/', '', $schema);
|
$schema = preg_replace('/--(.*?);/', '', $schema);
|
||||||
$schema = preg_replace('/[\r\n]/', ' ', $schema);
|
$schema = preg_replace('/[\r\n]/', ' ', $schema);
|
||||||
$schema = trim($schema, ' ;');
|
$schema = trim($schema, ' ;');
|
||||||
@ -69,8 +72,8 @@ catch (PDOException $e) {
|
|||||||
unset($pdo);
|
unset($pdo);
|
||||||
}
|
}
|
||||||
|
|
||||||
$contents = file_get_contents($confpath);
|
$contents = file_get_contents($conffile);
|
||||||
foreach ($config as $name => $value) {
|
foreach ($config as $name => $value) {
|
||||||
$contents = preg_replace('/(define\s*\(\'' . $name . '\',\s*)(.*)(\);)/', '$1"' . $value . '"$3', $contents);
|
$contents = preg_replace('/(define\s*\(\'' . $name . '\',\s*)(.*)(\);)/', '$1"' . $value . '"$3', $contents);
|
||||||
}
|
}
|
||||||
file_put_contents($confpath, $contents);
|
file_put_contents($conffile, $contents);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user