Photowall_Docker/entrypoint.sh
2021-01-25 07:36:26 +01:00

31 lines
1.0 KiB
Bash
Executable File

#!/bin/sh
# generate revisor's password hash
PHW_REVIS_PWD_HASH=$(php -r "echo password_hash('${PHW_REVIS_PWD}', PASSWORD_DEFAULT);")
# generate globals.php from environment variables
cd /var/www/html
echo "<?php define('SQL_USER', '${PHW_SQL_USER}'); define('SQL_PASS', '${PHW_SQL_PASS}'); define('SQL_DB', '${PHW_SQL_DB}'); define('SQL_IP', '${PHW_SQL_IP}'); define('PHW_DB_GRANTED', ${PHW_DB_GRANTED}); define('HASHED_REVIS_PASSWORD', '${PHW_REVIS_PWD_HASH}'); define('DEBUG_MODE', ${PHW_DEBUG_MODE});" > globals.php
# create ARTWORKS directories
mkdir -p ARTWORKS/incoming
mkdir -p ARTWORKS/thumbnails
mkdir -p ARTWORKS/published
# change owner to www-data
chown -R www-data:www-data ARTWORKS
# initialize database
cat /database_init.php | php -d display_errors=on -d error_reporting=-1
# substitute server name
sed -i "s|_ServerName_|ServerName ${PHW_SERVER_NAME}|g" /etc/apache2/sites-available/000-default.conf
# remove index.html
rm -f /var/www/html/index.html
# start webserver
/usr/sbin/apache2ctl -D FOREGROUND