mirror of
https://github.com/overleaf/toolkit.git
synced 2025-04-19 07:18:06 +02:00
Make TLS config optional
This commit is contained in:
parent
20e99b5fe7
commit
cdfb418361
2 changed files with 54 additions and 13 deletions
65
bin/init
65
bin/init
|
@ -16,19 +16,25 @@ if [[ ! -d "$TOOLKIT_ROOT/bin" ]] || [[ ! -d "$TOOLKIT_ROOT/config" ]]; then
|
|||
fi
|
||||
|
||||
function usage() {
|
||||
echo "Usage: bin/init"
|
||||
echo "Usage: bin/init [OPTION]"
|
||||
echo ""
|
||||
echo "Initialises local configuration files in the 'config/' directory"
|
||||
echo ""
|
||||
echo "--help display this help and exit"
|
||||
echo "--tls Initialises local configuration with NGINX config, or"
|
||||
echo " adds NGINX config to an existing local configuration"
|
||||
}
|
||||
|
||||
function check_existing_config() {
|
||||
if [[ -f "$TOOLKIT_ROOT/config/overleaf.rc" ]] \
|
||||
|| [[ -f "$TOOLKIT_ROOT/config/variables.env" ]] \
|
||||
|| [[ -f "$TOOLKIT_ROOT/config/version" ]]; then
|
||||
echo "ERROR: Config files already exist, exiting "
|
||||
exit 1
|
||||
fi
|
||||
function config_exists() {
|
||||
[ -f "$TOOLKIT_ROOT/config/overleaf.rc" ] \
|
||||
|| [ -f "$TOOLKIT_ROOT/config/variables.env" ] \
|
||||
|| [ -f "$TOOLKIT_ROOT/config/version" ]
|
||||
}
|
||||
|
||||
function tls_config_exists() {
|
||||
[ -f "$TOOLKIT_ROOT/config/nginx/nginx.conf" ] \
|
||||
|| [ -f "$TOOLKIT_ROOT/config/nginx/certs/overleaf_certificate.pem" ] \
|
||||
|| [ -f "$TOOLKIT_ROOT/config/nginx/certs/overleaf_key.pem" ]
|
||||
}
|
||||
|
||||
function set_up_config_files() {
|
||||
|
@ -50,14 +56,49 @@ function set_up_tls_proxy() {
|
|||
openssl x509 -req -days 365 -in $CERT_SIGN_REQ -signkey $PRIVATE_KEY -out $CERT
|
||||
}
|
||||
|
||||
HELP=false
|
||||
TLS=false
|
||||
|
||||
function __main__() {
|
||||
if [[ "${1:-null}" == "help" ]] || [[ "${1:-null}" == "--help" ]]; then
|
||||
while [[ $# -gt 0 ]] ; do
|
||||
case "$1" in
|
||||
help | --help )
|
||||
HELP=true
|
||||
shift
|
||||
;;
|
||||
--tls )
|
||||
TLS=true
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
echo "Unrecognised option $1"
|
||||
exit
|
||||
;;
|
||||
esac
|
||||
done
|
||||
if [[ "$HELP" == "true" ]]; then
|
||||
usage
|
||||
exit
|
||||
fi
|
||||
check_existing_config
|
||||
set_up_config_files
|
||||
set_up_tls_proxy
|
||||
if [[ "$TLS" == "true" ]]; then
|
||||
if tls_config_exists; then
|
||||
echo "ERROR: TLS config files already exist, exiting"
|
||||
exit 1
|
||||
else
|
||||
set_up_tls_proxy
|
||||
fi
|
||||
fi
|
||||
if config_exists; then
|
||||
if [[ "$TLS" == "true" ]]; then
|
||||
echo "Config files already exist, exiting"
|
||||
exit 0
|
||||
else
|
||||
echo "ERROR: Config files already exist, exiting"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
set_up_config_files
|
||||
fi
|
||||
}
|
||||
|
||||
__main__ "$@"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
An optional TLS proxy for terminating https connections, based on NGINX.
|
||||
|
||||
The toolkit is initialised with a sample private key in `config/nginx/certs/overleaf_key.pem` and a dummy certificate in `config/nginx/certs/overleaf_certificate.pem`. Either replace these with your actual private key and certificate, or set the values of the `TLS_PRIVATE_KEY_PATH` and `TLS_CERTIFICATE_PATH` variables to the paths of your actual private key and certificate respectively.
|
||||
Run `bin/init --tls` to initialise local configuration with NGINX proxy configuration, or to add NGINX proxy configuration to an existing local configuration. A sample private key is created in `config/nginx/certs/overleaf_key.pem` and a dummy certificate in `config/nginx/certs/overleaf_certificate.pem`. Either replace these with your actual private key and certificate, or set the values of the `TLS_PRIVATE_KEY_PATH` and `TLS_CERTIFICATE_PATH` variables to the paths of your actual private key and certificate respectively.
|
||||
|
||||
A default config for NGINX is provided in `config/nginx/nginx.conf` which may be customised to your requirements. The path to the config file can be changed with the `NGINX_CONFIG_PATH` variable.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue