1
0
Fork 0
mirror of https://github.com/overleaf/toolkit.git synced 2025-04-19 15:28:06 +02:00

update scripts to rebrand config/overleaf.rc

This commit is contained in:
mserranom 2024-02-12 12:53:14 +01:00
parent 85b58d6392
commit 3d5f07dc2e
4 changed files with 22 additions and 16 deletions

View file

@ -21,7 +21,7 @@ source "$TOOLKIT_ROOT/lib/shared-functions.sh"
function usage() {
echo "Usage: bin/update-env"
echo ""
echo "Updates config/variables.env, adding new environment variables"
echo "Updates config/variables.env and config/overleaf.rc, adding new environment variables"
echo ""
}
@ -32,11 +32,12 @@ function __main__() {
fi
# read_image_version
echo "This script will update your config/variables.env."
echo "This script will update your config/variables.env and config/overleaf.rc."
echo "We recommend backing up your config with bin/backup-config."
prompt "Do you want to continue?"
rebrand_sharelatex_env_variables
rebrand_sharelatex_env_variables 'variables.env'
rebrand_sharelatex_env_variables 'overleaf.rc'
echo "Done."
}

9
bin/up
View file

@ -41,12 +41,15 @@ function check_sharelatex_env_vars() {
invalid_prefix="OVERLEAF_"
fi
if grep -q "$invalid_prefix" "$TOOLKIT_ROOT/config/variables.env"; then
local env_occurrences=$(grep -o "$invalid_prefix" "$TOOLKIT_ROOT/config/variables.env" | wc -l | sed 's/ //g')
local rc_occurrences=$(grep -o "$invalid_prefix" "$TOOLKIT_ROOT/config/overleaf.rc" | wc -l | sed 's/ //g')
if [ "$env_occurrences" -gt 0 ] || [ "$rc_occurrences" -gt 0 ]; then
echo "WARNING: some environment variables defined in config/variables.env"
echo "contain '$invalid_prefix' in their name"
echo "or config/overleaf.rc contain '$invalid_prefix' in their name"
echo "Starting with Overleaf CE and Server Pro 5.0.0 the environment variables"
echo "use the prefix 'OVERLEAF_' instead of 'SHARELATEX_'."
echo "Please check your config/version and config/variables.env files"
echo "Please check your config/version, config/variables.env and config/overleaf.rc files"
prompt "Do you want to continue?"
fi
}

View file

@ -159,9 +159,10 @@ function handle_image_upgrade() {
cp "$TOOLKIT_ROOT/lib/config-seed/version" "$TOOLKIT_ROOT/config/version"
if [[ "$IMAGE_VERSION_MAJOR" -le 4 && "$SEED_IMAGE_VERSION_MAJOR" -ge 5 ]]; then
echo "Renaming environment variables in config/variables.env"
echo "Renaming environment variables in config/variables.env and config/overleaf.rc"
prompt "Proceed with the environment variable renaming?"
rebrand_sharelatex_env_variables
rebrand_sharelatex_env_variables 'variables.env'
rebrand_sharelatex_env_variables 'overleaf.rc'
fi
## Maybe offer to start services again

View file

@ -27,18 +27,19 @@ prompt() {
}
rebrand_sharelatex_env_variables() {
local filename=$1
set +o pipefail
sharelatex_occurrences=$(grep -o "SHARELATEX_" "$TOOLKIT_ROOT/config/variables.env" | wc -l | sed 's/ //g')
sharelatex_occurrences=$(grep -o "SHARELATEX_" "$TOOLKIT_ROOT/config/$filename" | wc -l | sed 's/ //g')
set -o pipefail
if [ "$sharelatex_occurrences" -gt 0 ]; then
echo "Found $sharelatex_occurrences lines with SHARELATEX_"
echo "Found $sharelatex_occurrences lines with SHARELATEX_ in $filename"
local timestamp=$(date "+%Y.%m.%d-%H.%M.%S")
echo "Creating backup file config/__old-variables.env.$timestamp"
cp config/variables.env config/__old-variables.env.$timestamp
echo "Replacing 'SHARELATEX_' with 'OVERLEAF_' in config/variables.env"
sed -i "s/SHARELATEX_/OVERLEAF_/g" "$TOOLKIT_ROOT/config/variables.env"
echo "Updated $sharelatex_occurrences lines in $TOOLKIT_ROOT/config/variables.env"
echo "Creating backup file config/__old-$filename.$timestamp"
cp config/$filename config/__old-$filename.$timestamp
echo "Replacing 'SHARELATEX_' with 'OVERLEAF_' in config/$filename"
sed -i "s/SHARELATEX_/OVERLEAF_/g" "$TOOLKIT_ROOT/config/$filename"
echo "Updated $sharelatex_occurrences lines in $TOOLKIT_ROOT/config/$filename"
else
echo "No 'SHARELATEX_' ocurrences found in config/variables.env"
echo "No 'SHARELATEX_' ocurrences found in config/$filename"
fi
}