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 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
|
||||
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-ttrss-update.conf /etc/supervisor/conf.d/ttrss-update.conf
|
||||
|
||||
# only run the setup once
|
||||
RUN /srv/setup-ttrss.sh
|
||||
|
||||
# clean up
|
||||
@ -57,4 +59,4 @@ RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||
|
||||
# start supervisord
|
||||
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';
|
||||
|
||||
$config['TTRSS_PATH'] = '/var/www/ttrss/';
|
||||
if (!env('TTRSS_PATH', ''))
|
||||
$confpath = '/var/www/ttrss/';
|
||||
$conffile = $confpath . 'config.php';
|
||||
|
||||
$ename = 'DB';
|
||||
$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
|
||||
if (!env($ename . '_PORT', '')) {
|
||||
@ -54,12 +57,12 @@ if (!dbcheck($config)) {
|
||||
$pdo = dbconnect($config);
|
||||
try {
|
||||
$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
|
||||
}
|
||||
catch (PDOException $e) {
|
||||
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('/[\r\n]/', ' ', $schema);
|
||||
$schema = trim($schema, ' ;');
|
||||
@ -69,8 +72,8 @@ catch (PDOException $e) {
|
||||
unset($pdo);
|
||||
}
|
||||
|
||||
$contents = file_get_contents($confpath);
|
||||
$contents = file_get_contents($conffile);
|
||||
foreach ($config as $name => $value) {
|
||||
$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