11#! /bin/bash
22
33# Set custom webroot
4- if [ ! -z " $WEBROOT " ]; then
4+ if [ -n " $WEBROOT " ]; then
55 sed -i " s#root /var/www/html;#root ${WEBROOT} ;#g" /etc/nginx/sites-available/default.conf
66else
77 WEBROOT=/var/www/html
88fi
99
1010# Recreate nginx user with passed UID and GID
11- if [ ! -z " $PUID " ]; then
11+ if [ -n " $PUID " ]; then
1212 if [ -z " $PGID " ]; then
1313 PGID=${PUID}
1414 fi
@@ -21,34 +21,46 @@ if [ ! -z "$PUID" ]; then
2121fi
2222
2323# Setup access rights for nginx group
24- setfacl -RL -m g:nginx:rwx $COMPOSER_HOME >> /dev/null 2>&1
24+ {
25+ setfacl -RLm g:nginx:rwx " $COMPOSER_HOME "
26+ setfacl -RLdm g:nginx:rwx " $COMPOSER_HOME "
27+ setfacl -RLm g:nginx:rwx /opt/spaceonfire/composer/v1
28+ setfacl -RLdm g:nginx:rwx /opt/spaceonfire/composer/v1
29+ setfacl -RLm g:nginx:rwx /opt/spaceonfire/composer/v2
30+ setfacl -RLdm g:nginx:rwx /opt/spaceonfire/composer/v2
31+ } >> /dev/null 2>&1
32+
2533if [[ " $SKIP_SETFACL " != " 1" ]]; then
26- setfacl -RL -m g:nginx:rwx /var/www/html/ >> /dev/null 2>&1
34+ setfacl -RLdm g:nginx:rwx /var/www/html/ >> /dev/null 2>&1
2735fi
2836
2937# Copy default index.html
3038if [ $( ls $WEBROOT /index.{php,htm,html} 2> /dev/null | wc -l) -eq 0 ]; then
3139 cp -f /opt/spaceonfire/html/index.html $WEBROOT
3240fi
3341
34- if [ ! -z " $SOF_PRESET " ]; then
42+ if [ -n " $SOF_PRESET " ]; then
3543 /opt/spaceonfire/bin/select-preset.sh $SOF_PRESET
3644fi
3745
46+ if [ -n " $COMPOSER_VERSION " ]; then
47+ /opt/spaceonfire/bin/select-composer.sh $COMPOSER_VERSION
48+ fi
49+
3850/opt/spaceonfire/bin/ssmtp-setup.php
3951
4052# Set Nginx read timeout
4153if [[ -z " $NGINX_READ_TIMEOUT " ]] && [[ " $APPLICATION_ENV " != " production" ]]; then
4254 NGINX_READ_TIMEOUT=9999
4355fi
4456
45- if [[ ! -z " $NGINX_READ_TIMEOUT " ]]; then
57+ if [[ -n " $NGINX_READ_TIMEOUT " ]]; then
4658 FastCgiParamsFile=" /etc/nginx/fastcgi_params"
4759 if ! grep -q fastcgi_read_timeout " $FastCgiParamsFile " ; then
4860 {
4961 echo " "
5062 echo " fastcgi_read_timeout $NGINX_READ_TIMEOUT ;"
51- } >> $FastCgiParamsFile
63+ } >> $FastCgiParamsFile
5264 fi
5365fi
5466
@@ -59,21 +71,21 @@ if [[ $lastlinephpconf == *"php_flag[display_errors]"* ]]; then
5971fi
6072
6173# Display PHP error's or not
62- if [[ " $ERRORS " != " 1" ]] ; then
63- echo " php_flag[display_errors] = off" >> /usr/local/etc/php-fpm.conf
74+ if [[ " $ERRORS " != " 1" ]]; then
75+ echo " php_flag[display_errors] = off" >> /usr/local/etc/php-fpm.conf
6476else
65- echo " php_flag[display_errors] = on" >> /usr/local/etc/php-fpm.conf
77+ echo " php_flag[display_errors] = on" >> /usr/local/etc/php-fpm.conf
6678fi
6779
6880# Display Version Details or not
69- if [[ " $HIDE_NGINX_HEADERS " == " 0" ]] ; then
81+ if [[ " $HIDE_NGINX_HEADERS " == " 0" ]]; then
7082 sed -i " s/server_tokens off;/server_tokens on;/g" /etc/nginx/nginx.conf
7183else
7284 sed -i " s/expose_php = On/expose_php = Off/g" /usr/local/etc/php-fpm.conf
7385fi
7486
7587# Pass real-ip to logs when behind ELB, etc
76- if [[ " $REAL_IP_HEADER " == " 1" ]] ; then
88+ if [[ " $REAL_IP_HEADER " == " 1" ]]; then
7789 vhosts=(' /etc/nginx/sites-available/default.conf' ' /etc/nginx/sites-available/default-ssl.conf' )
7890 for vhost in vhosts; do
7991 sed -i " s/#real_ip_header X-Forwarded-For;/real_ip_header X-Forwarded-For;/" $vhost
@@ -85,30 +97,30 @@ if [[ "$REAL_IP_HEADER" == "1" ]] ; then
8597fi
8698
8799# Display errors in docker logs
88- if [ ! -z " $PHP_ERRORS_STDERR " ]; then
89- echo " log_errors = On" >> /usr/local/etc/php/conf.d/docker-vars.ini
90- echo " error_log = /dev/stderr" >> /usr/local/etc/php/conf.d/docker-vars.ini
100+ if [ -n " $PHP_ERRORS_STDERR " ]; then
101+ echo " log_errors = On" >> /usr/local/etc/php/conf.d/docker-vars.ini
102+ echo " error_log = /dev/stderr" >> /usr/local/etc/php/conf.d/docker-vars.ini
91103fi
92104
93105# Increase the memory_limit
94- if [ ! -z " $PHP_MEM_LIMIT " ]; then
106+ if [ -n " $PHP_MEM_LIMIT " ]; then
95107 sed -i " s/memory_limit = 128M/memory_limit = ${PHP_MEM_LIMIT} M/g" /usr/local/etc/php/conf.d/docker-vars.ini
96108fi
97109
98110# Increase the post_max_size
99- if [ ! -z " $PHP_POST_MAX_SIZE " ]; then
111+ if [ -n " $PHP_POST_MAX_SIZE " ]; then
100112 sed -i " s/post_max_size = 100M/post_max_size = ${PHP_POST_MAX_SIZE} M/g" /usr/local/etc/php/conf.d/docker-vars.ini
101113fi
102114
103115# Increase the upload_max_filesize
104- if [ ! -z " $PHP_UPLOAD_MAX_FILESIZE " ]; then
116+ if [ -n " $PHP_UPLOAD_MAX_FILESIZE " ]; then
105117 sed -i " s/upload_max_filesize = 100M/upload_max_filesize= ${PHP_UPLOAD_MAX_FILESIZE} M/g" /usr/local/etc/php/conf.d/docker-vars.ini
106118fi
107119
108120# Enable xdebug only
109121if [ " $APPLICATION_ENV " != " production" ]; then
110122 XdebugFile=' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini'
111- if [[ " $ENABLE_XDEBUG " == " 1" ]] ; then
123+ if [[ " $ENABLE_XDEBUG " == " 1" ]]; then
112124 if [ -f $XdebugFile ]; then
113125 echo " Xdebug enabled"
114126 else
@@ -120,7 +132,7 @@ if [ "$APPLICATION_ENV" != "production" ]; then
120132 if [ -f $XdebugFile ]; then
121133 # Get default route ip if not set
122134 if [ -z " $XDEBUG_REMOTE_HOST " ]; then
123- XDEBUG_REMOTE_HOST=$( ip route| awk ' /default/ { print $3 }' )
135+ XDEBUG_REMOTE_HOST=$( ip route | awk ' /default/ { print $3 }' )
124136 fi
125137
126138 # See if file contains xdebug text.
@@ -129,15 +141,14 @@ if [ "$APPLICATION_ENV" != "production" ]; then
129141 else
130142 {
131143 echo " zend_extension=$( find /usr/local/lib/php/extensions/ -name xdebug.so) "
132- echo " xdebug.remote_enable=1"
133- echo " xdebug.remote_autostart=1"
134- echo " xdebug.remote_connect_back=0"
135- echo " xdebug.remote_host=${XDEBUG_REMOTE_HOST} "
144+ echo " xdebug.mode=debug"
145+ echo " xdebug.start_with_request=1"
136146 echo " xdebug.idekey=${XDEBUG_IDEKEY:- docker} "
147+ echo " xdebug.client_host=${XDEBUG_REMOTE_HOST} "
137148 echo " xdebug.var_display_max_depth=-1"
138149 echo " xdebug.var_display_max_children=-1"
139150 echo " xdebug.var_display_max_data=-1"
140- } > $XdebugFile
151+ } > $XdebugFile
141152 fi
142153 fi
143154 fi
@@ -150,12 +161,13 @@ if [ "$APPLICATION_ENV" != "production" ]; then
150161fi
151162
152163# Run custom scripts
153- if [[ " $RUN_SCRIPTS " == " 1" ]] ; then
164+ if [[ " $RUN_SCRIPTS " == " 1" ]]; then
154165 if [ -d " /var/www/html/scripts/" ]; then
155- # make scripts executable incase they aren't
156- chmod -Rf 750 /var/www/html/scripts/* ; sync;
166+ # make scripts executable in case they aren't
167+ chmod -Rf 750 /var/www/html/scripts/*
168+ sync
157169 # run scripts in number order
158- for i in /var/www/html/scripts/* ; do $i ; done
170+ for i in /var/www/html/scripts/* ; do $i ; done
159171 else
160172 echo " Can't find script directory"
161173 fi
0 commit comments