Files

43 lines
1.3 KiB
Bash

# Apply defaults for unset variables
if [ -z $MODE ]; then MODE=default; fi
if [ -z $CLIENT_AUTH ]; then CLIENT_AUTH=shared_secret:runclass; fi
if [ -z $INTERACTIVE ]; then INTERACTIVE=false; fi
# Write configuration file
echo "<?php return array(" \
" 'uploads' => false, " \
" 'interactive_run' => $INTERACTIVE, " \
" 'cache_dir' => __DIR__.'/cache', " \
" 'uploads_dir' => __DIR__.'/uploads', " \
" 'mode' => '$MODE', " \
" 'client_authentication' => '$CLIENT_AUTH', " \
" 'client_authentication_must_be_secure' => false, " \
" 'global_cors_origins' => 'https://cloudobjects.io', " \
" 'co.auth_ns' => '$CO_AUTH_NS', " \
" 'co.auth_secret' => '$CO_AUTH_SECRET', " \
" 'agws.data_cache' => 'file', " \
" 'log.target' => 'errorlog', " \
" 'log.level' => Monolog\Logger::INFO, " \
" ); " > config.php
if [ ! -z $RUN_ON_HTTP_PORT ]; then
# We need to create a Caddyfile that exposes this port
echo "http://:$RUN_ON_HTTP_PORT {\n" \
" root * /www/public/\n" \
" php_fastcgi localhost:9000\n" \
" try_files {path} /index.php\n" \
" file_server\n" \
" header -Via {\n" \
" defer\n" \
" }\n" \
"}\n" > Caddyfile
echo "Configured an HTTP (unencrypted) webserver on port $RUN_ON_HTTP_PORT";
fi
# Make cache folder
mkdir cache
chown www-data:www-data cache