docker/pixelfed/web/root/etc/cont-init.d/20-config
2020-01-31 16:10:38 -06:00

42 lines
1.6 KiB
Plaintext
Executable file

#!/usr/bin/with-contenv bash
# make our folders
mkdir -p \
/config/{nginx/site-confs,www,log/nginx,keys,log/php,php} \
/run \
/var/lib/nginx/tmp/client_body \
/var/tmp/nginx
# copy config files
[[ ! -f /config/nginx/nginx.conf ]] && \
cp /defaults/nginx.conf /config/nginx/nginx.conf
[[ ! -f /config/nginx/site-confs/default ]] && \
cp /defaults/default /config/nginx/site-confs/default
[[ $(find /config/www -type f | wc -l) -eq 0 ]] && \
cp /defaults/index.html /config/www/index.html
# create local php.ini if it doesn't exist, set local timezone
[[ ! -f /config/php/php-local.ini ]] && \
printf "; Edit this file to override php.ini directives and restart the container\\n\\ndate.timezone = %s\\n" "$TZ" > /config/php/php-local.ini
# copy user php-local.ini to image
cp /config/php/php-local.ini /etc/php7/conf.d/php-local.ini
#fix php-fpm log location
sed -i "s#;error_log = log/php7/error.log.*#error_log = /config/log/php/error.log#g" /etc/php7/php-fpm.conf
#fix php-fpm user
sed -i "s#user = nobody.*#user = abc#g" /etc/php7/php-fpm.d/www.conf
sed -i "s#group = nobody.*#group = abc#g" /etc/php7/php-fpm.d/www.conf
# create override for www.conf if it doesn't exist
[[ ! -f /config/php/www2.conf ]] && \
printf "; Edit this file to override www.conf and php-fpm.conf directives and restart the container\\n\\n; Pool name\\n[www]\\n\\n" > /config/php/www2.conf
# copy user www2.conf to image
cp /config/php/www2.conf /etc/php7/php-fpm.d/www2.conf
# permissions
chown -R abc:abc \
/config \
/var/lib/nginx \
/var/tmp/nginx
chmod -R g+w \
/config/{nginx,www}
chmod -R 644 /etc/logrotate.d