From 12befda220ba81e1b515a088f4bc0594cfeefbe4 Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Fri, 9 Feb 2024 15:17:30 +0000 Subject: [PATCH] Merge pull request #16919 from overleaf/jpa-check-env-vars [server-ce] add script for checking on old ShareLaTeX env vars GitOrigin-RevId: a60d6f7648d65c336054795affe91a349aa629cf --- server-ce/bin/rename-env-vars-5-0.sh | 18 +++++++ .../000_check_for_old_env_vars_5.sh | 54 +++++++++++++++++++ ...tex_secrets.sh => 100_generate_secrets.sh} | 0 ...rs.sh => 100_make_sharelatex_data_dirs.sh} | 0 ...site_status => 100_restore_site_status.sh} | 0 ...ss.sh => 100_set_docker_host_ipaddress.sh} | 0 ...mplate.sh => 200_nginx_config_template.sh} | 0 ...ete_old_logs.sh => 300_delete_old_logs.sh} | 0 ...ck_db_access.sh => 500_check_db_access.sh} | 0 ...igrations.sh => 900_run_web_migrations.sh} | 0 10 files changed, 72 insertions(+) create mode 100755 server-ce/bin/rename-env-vars-5-0.sh create mode 100755 server-ce/init_scripts/000_check_for_old_env_vars_5.sh rename server-ce/init_scripts/{00_regen_sharelatex_secrets.sh => 100_generate_secrets.sh} (100%) rename server-ce/init_scripts/{00_make_sharelatex_data_dirs.sh => 100_make_sharelatex_data_dirs.sh} (100%) rename server-ce/init_scripts/{00_restore_site_status => 100_restore_site_status.sh} (100%) rename server-ce/init_scripts/{00_set_docker_host_ipaddress.sh => 100_set_docker_host_ipaddress.sh} (100%) rename server-ce/init_scripts/{01_nginx_config_template.sh => 200_nginx_config_template.sh} (100%) rename server-ce/init_scripts/{10_delete_old_logs.sh => 300_delete_old_logs.sh} (100%) rename server-ce/init_scripts/{98_check_db_access.sh => 500_check_db_access.sh} (100%) rename server-ce/init_scripts/{99_run_web_migrations.sh => 900_run_web_migrations.sh} (100%) diff --git a/server-ce/bin/rename-env-vars-5-0.sh b/server-ce/bin/rename-env-vars-5-0.sh new file mode 100755 index 0000000000..292d698941 --- /dev/null +++ b/server-ce/bin/rename-env-vars-5-0.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +set -euo pipefail + +FILE=${1:-docker-compose.yml} +if [[ ! -f "$FILE" ]]; then + echo "Expected to find $FILE, are you in the wrong directory?" + exit 2 +fi + +BACKUP_FILE="$FILE.$(date '+%Y.%m.%d-%H.%M.%S')" +echo "Creating backup file $BACKUP_FILE" +cp "$FILE" "$BACKUP_FILE" + +echo "Replacing 'SHARELATEX_' with 'OVERLEAF_' in $FILE" +sed -i "s/SHARELATEX_/OVERLEAF_/g" "$FILE" + +echo "Done." diff --git a/server-ce/init_scripts/000_check_for_old_env_vars_5.sh b/server-ce/init_scripts/000_check_for_old_env_vars_5.sh new file mode 100755 index 0000000000..d37cc95b27 --- /dev/null +++ b/server-ce/init_scripts/000_check_for_old_env_vars_5.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +set -e + +OLD_ITEMS=$(env | cut -d '=' -f1 | grep SHARELATEX | sed 's/^/ - /') + +if [[ "$OLD_ITEMS" == "" ]]; then + exit 0 +fi + +N=$(echo "$OLD_ITEMS" | wc -l) +cat < OVERLEAF_MONGO_URL, or + remove old entries from your configuration. + + You can use the following script for migrating your config. + + Overleaf toolkit setups: + + github.com/overleaf/toolkit$ bin/upgrade + github.com/overleaf/toolkit$ bin/rename-env-vars-5-0.sh + + Legacy docker compose setups/Horizontal scaling setups: + + github.com/overleaf/overleaf$ git pull + github.com/overleaf/overleaf$ server-ce/bin/rename-env-vars-5-0.sh + + # When using a docker-compose.override.yml file (or other file name): + github.com/overleaf/overleaf$ server-ce/bin/rename-env-vars-5-0.sh docker-compose.override.yml + + Other deployment methods: + + Try using the docker compose script or get in touch with support. + + + Refusing to startup, existing in 10s. + +------------------------------------------------------------------------ +EOF + +sleep 10 +exit 101 diff --git a/server-ce/init_scripts/00_regen_sharelatex_secrets.sh b/server-ce/init_scripts/100_generate_secrets.sh similarity index 100% rename from server-ce/init_scripts/00_regen_sharelatex_secrets.sh rename to server-ce/init_scripts/100_generate_secrets.sh diff --git a/server-ce/init_scripts/00_make_sharelatex_data_dirs.sh b/server-ce/init_scripts/100_make_sharelatex_data_dirs.sh similarity index 100% rename from server-ce/init_scripts/00_make_sharelatex_data_dirs.sh rename to server-ce/init_scripts/100_make_sharelatex_data_dirs.sh diff --git a/server-ce/init_scripts/00_restore_site_status b/server-ce/init_scripts/100_restore_site_status.sh similarity index 100% rename from server-ce/init_scripts/00_restore_site_status rename to server-ce/init_scripts/100_restore_site_status.sh diff --git a/server-ce/init_scripts/00_set_docker_host_ipaddress.sh b/server-ce/init_scripts/100_set_docker_host_ipaddress.sh similarity index 100% rename from server-ce/init_scripts/00_set_docker_host_ipaddress.sh rename to server-ce/init_scripts/100_set_docker_host_ipaddress.sh diff --git a/server-ce/init_scripts/01_nginx_config_template.sh b/server-ce/init_scripts/200_nginx_config_template.sh similarity index 100% rename from server-ce/init_scripts/01_nginx_config_template.sh rename to server-ce/init_scripts/200_nginx_config_template.sh diff --git a/server-ce/init_scripts/10_delete_old_logs.sh b/server-ce/init_scripts/300_delete_old_logs.sh similarity index 100% rename from server-ce/init_scripts/10_delete_old_logs.sh rename to server-ce/init_scripts/300_delete_old_logs.sh diff --git a/server-ce/init_scripts/98_check_db_access.sh b/server-ce/init_scripts/500_check_db_access.sh similarity index 100% rename from server-ce/init_scripts/98_check_db_access.sh rename to server-ce/init_scripts/500_check_db_access.sh diff --git a/server-ce/init_scripts/99_run_web_migrations.sh b/server-ce/init_scripts/900_run_web_migrations.sh similarity index 100% rename from server-ce/init_scripts/99_run_web_migrations.sh rename to server-ce/init_scripts/900_run_web_migrations.sh