1
1
#! /bin/bash
2
2
3
3
# Set custom webroot
4
- if [ ! -z " $WEBROOT " ]; then
4
+ if [ -n " $WEBROOT " ]; then
5
5
sed -i " s#root /var/www/html;#root ${WEBROOT} ;#g" /etc/nginx/sites-available/default.conf
6
6
else
7
7
WEBROOT=/var/www/html
8
8
fi
9
9
10
10
# Recreate nginx user with passed UID and GID
11
- if [ ! -z " $PUID " ]; then
11
+ if [ -n " $PUID " ]; then
12
12
if [ -z " $PGID " ]; then
13
13
PGID=${PUID}
14
14
fi
@@ -21,34 +21,46 @@ if [ ! -z "$PUID" ]; then
21
21
fi
22
22
23
23
# 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
+
25
33
if [[ " $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
27
35
fi
28
36
29
37
# Copy default index.html
30
38
if [ $( ls $WEBROOT /index.{php,htm,html} 2> /dev/null | wc -l) -eq 0 ]; then
31
39
cp -f /opt/spaceonfire/html/index.html $WEBROOT
32
40
fi
33
41
34
- if [ ! -z " $SOF_PRESET " ]; then
42
+ if [ -n " $SOF_PRESET " ]; then
35
43
/opt/spaceonfire/bin/select-preset.sh $SOF_PRESET
36
44
fi
37
45
46
+ if [ -n " $COMPOSER_VERSION " ]; then
47
+ /opt/spaceonfire/bin/select-composer.sh $COMPOSER_VERSION
48
+ fi
49
+
38
50
/opt/spaceonfire/bin/ssmtp-setup.php
39
51
40
52
# Set Nginx read timeout
41
53
if [[ -z " $NGINX_READ_TIMEOUT " ]] && [[ " $APPLICATION_ENV " != " production" ]]; then
42
54
NGINX_READ_TIMEOUT=9999
43
55
fi
44
56
45
- if [[ ! -z " $NGINX_READ_TIMEOUT " ]]; then
57
+ if [[ -n " $NGINX_READ_TIMEOUT " ]]; then
46
58
FastCgiParamsFile=" /etc/nginx/fastcgi_params"
47
59
if ! grep -q fastcgi_read_timeout " $FastCgiParamsFile " ; then
48
60
{
49
61
echo " "
50
62
echo " fastcgi_read_timeout $NGINX_READ_TIMEOUT ;"
51
- } >> $FastCgiParamsFile
63
+ } >> $FastCgiParamsFile
52
64
fi
53
65
fi
54
66
@@ -59,21 +71,21 @@ if [[ $lastlinephpconf == *"php_flag[display_errors]"* ]]; then
59
71
fi
60
72
61
73
# 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
64
76
else
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
66
78
fi
67
79
68
80
# Display Version Details or not
69
- if [[ " $HIDE_NGINX_HEADERS " == " 0" ]] ; then
81
+ if [[ " $HIDE_NGINX_HEADERS " == " 0" ]]; then
70
82
sed -i " s/server_tokens off;/server_tokens on;/g" /etc/nginx/nginx.conf
71
83
else
72
84
sed -i " s/expose_php = On/expose_php = Off/g" /usr/local/etc/php-fpm.conf
73
85
fi
74
86
75
87
# Pass real-ip to logs when behind ELB, etc
76
- if [[ " $REAL_IP_HEADER " == " 1" ]] ; then
88
+ if [[ " $REAL_IP_HEADER " == " 1" ]]; then
77
89
vhosts=(' /etc/nginx/sites-available/default.conf' ' /etc/nginx/sites-available/default-ssl.conf' )
78
90
for vhost in vhosts; do
79
91
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
85
97
fi
86
98
87
99
# 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
91
103
fi
92
104
93
105
# Increase the memory_limit
94
- if [ ! -z " $PHP_MEM_LIMIT " ]; then
106
+ if [ -n " $PHP_MEM_LIMIT " ]; then
95
107
sed -i " s/memory_limit = 128M/memory_limit = ${PHP_MEM_LIMIT} M/g" /usr/local/etc/php/conf.d/docker-vars.ini
96
108
fi
97
109
98
110
# Increase the post_max_size
99
- if [ ! -z " $PHP_POST_MAX_SIZE " ]; then
111
+ if [ -n " $PHP_POST_MAX_SIZE " ]; then
100
112
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
101
113
fi
102
114
103
115
# Increase the upload_max_filesize
104
- if [ ! -z " $PHP_UPLOAD_MAX_FILESIZE " ]; then
116
+ if [ -n " $PHP_UPLOAD_MAX_FILESIZE " ]; then
105
117
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
106
118
fi
107
119
108
120
# Enable xdebug only
109
121
if [ " $APPLICATION_ENV " != " production" ]; then
110
122
XdebugFile=' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini'
111
- if [[ " $ENABLE_XDEBUG " == " 1" ]] ; then
123
+ if [[ " $ENABLE_XDEBUG " == " 1" ]]; then
112
124
if [ -f $XdebugFile ]; then
113
125
echo " Xdebug enabled"
114
126
else
@@ -120,7 +132,7 @@ if [ "$APPLICATION_ENV" != "production" ]; then
120
132
if [ -f $XdebugFile ]; then
121
133
# Get default route ip if not set
122
134
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 }' )
124
136
fi
125
137
126
138
# See if file contains xdebug text.
@@ -129,15 +141,14 @@ if [ "$APPLICATION_ENV" != "production" ]; then
129
141
else
130
142
{
131
143
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"
136
146
echo " xdebug.idekey=${XDEBUG_IDEKEY:- docker} "
147
+ echo " xdebug.client_host=${XDEBUG_REMOTE_HOST} "
137
148
echo " xdebug.var_display_max_depth=-1"
138
149
echo " xdebug.var_display_max_children=-1"
139
150
echo " xdebug.var_display_max_data=-1"
140
- } > $XdebugFile
151
+ } > $XdebugFile
141
152
fi
142
153
fi
143
154
fi
@@ -150,12 +161,13 @@ if [ "$APPLICATION_ENV" != "production" ]; then
150
161
fi
151
162
152
163
# Run custom scripts
153
- if [[ " $RUN_SCRIPTS " == " 1" ]] ; then
164
+ if [[ " $RUN_SCRIPTS " == " 1" ]]; then
154
165
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
157
169
# 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
159
171
else
160
172
echo " Can't find script directory"
161
173
fi
0 commit comments