From a3014a0fdb19f17ef161beacdc156ed63c17ccbf Mon Sep 17 00:00:00 2001 From: Dennis Schwerdel Date: Thu, 23 Feb 2017 15:25:53 +0100 Subject: [PATCH] Using cli scripts & allowing config changes --- Dockerfile | 2 +- set_config.php | 22 +++++++++++++++++++++ setup_db.php | 14 -------------- start.sh | 52 +++++++++++++------------------------------------- 4 files changed, 36 insertions(+), 54 deletions(-) create mode 100644 set_config.php delete mode 100644 setup_db.php diff --git a/Dockerfile b/Dockerfile index 3f20ebc..efa88b6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -43,6 +43,6 @@ RUN rm -rf /var/lib/php \ && ln -s /run/php /var/lib/php ADD start.sh /app/code/start.sh -ADD setup_db.php /app/code/setup_db.php +ADD set_config.php /app/code/set_config.php CMD [ "/app/code/start.sh" ] diff --git a/set_config.php b/set_config.php new file mode 100644 index 0000000..93ac067 --- /dev/null +++ b/set_config.php @@ -0,0 +1,22 @@ + "mysql", + "host" => getenv('MYSQL_HOST'), + "user" => getenv('MYSQL_USERNAME'), + "password" => getenv('MYSQL_PASSWORD'), + "base" => getenv('MYSQL_DATABASE'), + "prefix" => "", + "pdo_options" => + array ( + ) + ); + + $config_str = var_export($config, TRUE); + file_put_contents("/app/data/config.php", " diff --git a/setup_db.php b/setup_db.php deleted file mode 100644 index 2171520..0000000 --- a/setup_db.php +++ /dev/null @@ -1,14 +0,0 @@ -prepare($sql); -$stm->execute(); - -$sql = sprintf(SQL_INSERT_FEEDS, 'admin_'); -$stm = $c->prepare($sql); -$stm->execute(); - diff --git a/start.sh b/start.sh index 7b0d6db..3f1f452 100755 --- a/start.sh +++ b/start.sh @@ -7,20 +7,13 @@ mkdir -p /run/php/sessions if ! [ -f /app/data/.installed ]; then echo "Fresh installation, setting up..." rsync -a /app/code/data-orig/ /app/data/ - dd if=/dev/urandom bs=1 count=1024 2>/dev/null | sha1sum | awk '{ print $1 }' > /app/data/.salt - mkdir -p /app/data/users/admin - cat > /app/data/users/admin/config.php < 'en', - 'passwordHash' => '\$2a\$09\$lO5xTAsfRCG1rSssJgHtTeiweXj2VwGN/JfuexIMpsQWzKoFVoklm', - 'apiPasswordHash' => '', -); -?> -EOF - touch /app/data/users/admin/log.txt - rm /app/data/do-install.txt - php /app/code/setup_db.php + php cli/do-install.php \ + --environment production --default_user admin \ + --db-type mysql --db-host "${MYSQL_HOST}:${MYSQL_PORT}" \ + --db-user "${MYSQL_USERNAME}" --db-password "${MYSQL_PASSWORD}" \ + --db-base "${MYSQL_DATABASE}" + php cli/create-user.php --user admin --password password --language en + php cli/actualize-user.php --user admin touch /app/data/.installed echo "Done." fi @@ -32,34 +25,15 @@ for f in $(ls /app/code/extensions-orig); do fi done -echo "Creating config file" -SALT=$(cat /app/data/.salt) -cat > /app/data/config.php < '${SALT}', - 'base_url' => 'https://${APP_DOMAIN}/p', - 'title' => 'FreshRSS', - 'default_user' => 'admin', - 'auth_type' => 'form', - 'db' => - array ( - 'type' => 'mysql', - 'host' => '${MYSQL_HOST}', - 'user' => '${MYSQL_USERNAME}', - 'password' => '${MYSQL_PASSWORD}', - 'base' => '${MYSQL_DATABASE}', - 'prefix' => '', - 'pdo_options' => - array ( - ), - ), - 'pubsubhubbub_enabled' => true, -); -EOF +echo "Creating config file" +php set_config.php + + +echo "Setting permissions" chown -R www-data.www-data /run/php /app/data + echo "Starting apache" APACHE_CONFDIR="" source /etc/apache2/envvars rm -f "${APACHE_PID_FILE}"