seeddms-docker/sources/seeddms-entrypoint
2022-12-28 17:22:40 +01:00

52 lines
1.6 KiB
Bash
Executable File

#!/bin/sh
rm -rf /tmp/seed
if [ -n "$TZ" ]; then
echo $TZ > /etc/timezone
if ! tail /usr/local/etc/php/php.ini | grep date.timezone > /dev/null; then
echo "" >> /usr/local/etc/php/php.ini
echo "\ndate.timezone = $TZ" >> /usr/local/etc/php/php.ini
fi
fi
rm -f /etc/cron.d/seeddms
if [ -z "$CRON_SCHEDULER" ]; then
CRON_SCHEDULER="5 * * * *"
fi
echo "$CRON_SCHEDULER su -s /bin/bash -c '. /usr/local/bin/seeddms-settings.sh && /var/www/seeddms/seeddms/utils/seeddms-schedulercli --config /var/www/seeddms/conf/settings.xml --mode=run' www-data" >> /etc/cron.d/seeddms
if [ -n "$CRON_INDEX" ]; then
echo "$CRON_INDEX su -s /bin/bash -c /usr/local/bin/seeddms-generate-index.sh www-data" >> /etc/cron.d/seeddms
fi
if [ -n "$CRON_BACKUP" ]; then
echo "$CRON_BACKUP su -s /bin/bash -c /usr/local/bin/seeddms-generate-backup.sh www-data" >> /etc/cron.d/seeddms
fi
if [ -e /etc/cron.d/seeddms ]; then
crontab /etc/cron.d/seeddms
fi
if [ ! -f $PUBLIC_CERT ] && [ ! -f $PRIVATE_KEY ]; then
openssl req -nodes -new -x509 -keyout $PRIVATE_KEY -out $PUBLIC_CERT -subj "${PUBLIC_CERT_SUBJ}"
fi
if [ $FORCE_SSL -eq 1 ]; then
if ! grep "RewriteCond %{HTTPS}" $SEEDDMS_BASE/www/.htaccess > /dev/null; then
echo "RewriteCond %{HTTPS} !=on" >> $SEEDDMS_BASE/www/.htaccess
echo "RewriteRule ^/?(.*) https://%{SERVER_NAME}:${SSL_PORT:-443}/$1 [R,L]" >> $SEEDDMS_BASE/www/.htaccess
fi
fi
sed -ri -e 's!/etc/ssl/certs/ssl-cert-snakeoil.pem!${PUBLIC_CERT}!g' \
-e 's!/etc/ssl/private/ssl-cert-snakeoil.key!${PRIVATE_KEY}!g' /etc/apache2/sites-available/default-ssl.conf
rm -f /var/run/cron*
cron
. /usr/local/bin/docker-php-entrypoint