Using cli scripts & allowing config changes

This commit is contained in:
Dennis Schwerdel 2017-02-23 15:25:53 +01:00
parent b48681e37c
commit a3014a0fdb
4 changed files with 36 additions and 54 deletions

View File

@ -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" ]

22
set_config.php Normal file
View File

@ -0,0 +1,22 @@
<?php
$config = include("/app/data/config.php");
$config["default_user"] = "admin";
$config["base_url"] = "https://".getenv('APP_DOMAIN')."/p";
$config["db"] = array (
"type" => "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", "<?php return $config_str;");
?>

View File

@ -1,14 +0,0 @@
<?PHP
include_once('/app/code/app/SQL/install.sql.mysql.php');
$c = new PDO("mysql:dbname=".getenv('MYSQL_DATABASE').";host=".getenv('MYSQL_HOST').";port=".getenv('MYSQL_PORT'), getenv('MYSQL_USERNAME'), getenv('MYSQL_PASSWORD'));
$sql = sprintf(SQL_CREATE_TABLES, 'admin_', 'Uncategorized');
$stm = $c->prepare($sql);
$stm->execute();
$sql = sprintf(SQL_INSERT_FEEDS, 'admin_');
$stm = $c->prepare($sql);
$stm->execute();

View File

@ -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 <<EOF
<?php
return array (
'language' => '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 <<EOF
<?php
return array (
'salt' => '${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}"