127127
128128
129129if [ " ${to_install} " != " " ]; then
130+ echo " ▶ Installing ${to_install} "
130131 apt-get -qq install --yes ${to_install}
131132 echo " ▶ Stopping nginx so that it can be configured as a S3 Gateway"
132133 systemctl stop nginx
135136echo " ▶ Adding environment variables to NGINX configuration file: /etc/nginx/environment"
136137cat > " /etc/nginx/environment" << EOF
137138# 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 ' }
139140# Enables or disables directory listing for the S3 Gateway (true=enabled, false=disabled)
140141DIRECTORY_LISTING_PATH_PREFIX=${DIRECTORY_LISTING_PATH_PREFIX:- ' ' }
141142# AWS Authentication signature version (2=v2 authentication, 4=v4 authentication)
@@ -151,26 +152,27 @@ S3_SERVER_PROTO=${S3_SERVER_PROTO}
151152# S3 host to connect to
152153S3_SERVER=${S3_SERVER}
153154# The S3 host/path method - 'virtual', 'path' or 'default'
154- S3_STYLE=${S3_STYLE}
155+ S3_STYLE=${S3_STYLE:- ' default ' }
155156# Flag (true/false) enabling AWS signatures debug output (default: false)
156- DEBUG=${DEBUG}
157+ DEBUG=${DEBUG:- ' false ' }
157158# Cache size limit
158- PROXY_CACHE_MAX_SIZE=${PROXY_CACHE_MAX_SIZE}
159+ PROXY_CACHE_MAX_SIZE=${PROXY_CACHE_MAX_SIZE:- ' 10g ' }
159160# 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 ' }
161162# 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 ' }
163164# 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 ' }
165166# 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 ' }
167168# Enables or disables CORS for the S3 Gateway (true=enabled, false=disabled)
168- CORS_ENABLED=${CORS_ENABLED}
169+ CORS_ENABLED=${CORS_ENABLED:- ' false ' }
169170EOF
170171
171172# By enabling CORS, we also need to enable the OPTIONS method which
172173# is not normally used as part of the gateway. The following variable
173174# defines the set of acceptable headers.
175+ set +o nounset # don't abort on unbound variable
174176if [ " ${CORS_ENABLED} " == " 1" ]; then
175177 cat >> " /etc/nginx/environment" << EOF
176178LIMIT_METHODS_TO="GET HEAD OPTIONS"
@@ -182,6 +184,7 @@ LIMIT_METHODS_TO="GET HEAD"
182184LIMIT_METHODS_TO_CSV="GET, HEAD"
183185EOF
184186fi
187+ set -o nounset # abort on unbound variable
185188
186189if [ -z " ${CORS_ALLOWED_ORIGIN+x} " ]; then
187190CORS_ALLOWED_ORIGIN=" *"
0 commit comments