127
127
128
128
129
129
if [ " ${to_install} " != " " ]; then
130
+ echo " ▶ Installing ${to_install} "
130
131
apt-get -qq install --yes ${to_install}
131
132
echo " ▶ Stopping nginx so that it can be configured as a S3 Gateway"
132
133
systemctl stop nginx
135
136
echo " ▶ Adding environment variables to NGINX configuration file: /etc/nginx/environment"
136
137
cat > " /etc/nginx/environment" << EOF
137
138
# Enables or disables directory listing for the S3 Gateway (true=enabled, false=disabled)
138
- ALLOW_DIRECTORY_LIST=${ALLOW_DIRECTORY_LIST}
139
+ ALLOW_DIRECTORY_LIST=${ALLOW_DIRECTORY_LIST:- ' false ' }
139
140
# Enables or disables directory listing for the S3 Gateway (true=enabled, false=disabled)
140
141
DIRECTORY_LISTING_PATH_PREFIX=${DIRECTORY_LISTING_PATH_PREFIX:- ' ' }
141
142
# AWS Authentication signature version (2=v2 authentication, 4=v4 authentication)
@@ -151,26 +152,27 @@ S3_SERVER_PROTO=${S3_SERVER_PROTO}
151
152
# S3 host to connect to
152
153
S3_SERVER=${S3_SERVER}
153
154
# The S3 host/path method - 'virtual', 'path' or 'default'
154
- S3_STYLE=${S3_STYLE}
155
+ S3_STYLE=${S3_STYLE:- ' default ' }
155
156
# Flag (true/false) enabling AWS signatures debug output (default: false)
156
- DEBUG=${DEBUG}
157
+ DEBUG=${DEBUG:- ' false ' }
157
158
# Cache size limit
158
- PROXY_CACHE_MAX_SIZE=${PROXY_CACHE_MAX_SIZE}
159
+ PROXY_CACHE_MAX_SIZE=${PROXY_CACHE_MAX_SIZE:- ' 10g ' }
159
160
# Cached data that are not accessed during the time get removed
160
- PROXY_CACHE_INACTIVE=${PROXY_CACHE_INACTIVE}
161
+ PROXY_CACHE_INACTIVE=${PROXY_CACHE_INACTIVE:- ' 60m ' }
161
162
# Proxy caching time for response code 200 and 302
162
- PROXY_CACHE_VALID_OK=${PROXY_CACHE_VALID_OK}
163
+ PROXY_CACHE_VALID_OK=${PROXY_CACHE_VALID_OK:- ' 1h ' }
163
164
# Proxy caching time for response code 404
164
- PROXY_CACHE_VALID_NOTFOUND=${PROXY_CACHE_VALID_NOTFOUND}
165
+ PROXY_CACHE_VALID_NOTFOUND=${PROXY_CACHE_VALID_NOTFOUND:- ' 1m ' }
165
166
# Proxy caching time for response code 403
166
- PROXY_CACHE_VALID_FORBIDDEN=${PROXY_CACHE_VALID_FORBIDDEN}
167
+ PROXY_CACHE_VALID_FORBIDDEN=${PROXY_CACHE_VALID_FORBIDDEN:- ' 30s ' }
167
168
# Enables or disables CORS for the S3 Gateway (true=enabled, false=disabled)
168
- CORS_ENABLED=${CORS_ENABLED}
169
+ CORS_ENABLED=${CORS_ENABLED:- ' false ' }
169
170
EOF
170
171
171
172
# By enabling CORS, we also need to enable the OPTIONS method which
172
173
# is not normally used as part of the gateway. The following variable
173
174
# defines the set of acceptable headers.
175
+ set +o nounset # don't abort on unbound variable
174
176
if [ " ${CORS_ENABLED} " == " 1" ]; then
175
177
cat >> " /etc/nginx/environment" << EOF
176
178
LIMIT_METHODS_TO="GET HEAD OPTIONS"
@@ -182,6 +184,7 @@ LIMIT_METHODS_TO="GET HEAD"
182
184
LIMIT_METHODS_TO_CSV="GET, HEAD"
183
185
EOF
184
186
fi
187
+ set -o nounset # abort on unbound variable
185
188
186
189
if [ -z " ${CORS_ALLOWED_ORIGIN+x} " ]; then
187
190
CORS_ALLOWED_ORIGIN=" *"
0 commit comments