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

Handle overleaf.rc rebranding before version upgrade

This commit is contained in:
Jakob Ackermann 2024-02-26 11:45:01 +00:00
parent e2bf1ae2e4
commit d3188d9c4d
No known key found for this signature in database
GPG key ID: 30C56800FCA3828A
2 changed files with 10 additions and 3 deletions

View file

@ -170,8 +170,6 @@ function handle_image_upgrade() {
echo "Over-writing config/version with $SEED_IMAGE_VERSION"
cp "$TOOLKIT_ROOT/lib/config-seed/version" "$TOOLKIT_ROOT/config/version"
## Rename variables in overleaf.rc SHARELATEX_ -> OVERLEAF_
rebrand_sharelatex_env_variables 'overleaf.rc'
if [[ "$IMAGE_VERSION_MAJOR" -le 4 && "$SEED_IMAGE_VERSION_MAJOR" -ge 5 ]]; then
echo "Renaming environment variables in config/variables.env and config/overleaf.rc"
prompt "Proceed with the environment variable renaming?"
@ -226,6 +224,11 @@ function handle_git_update() {
fi
}
function handle_rc_rebranding() {
## Rename variables in overleaf.rc SHARELATEX_ -> OVERLEAF_
rebrand_sharelatex_env_variables 'overleaf.rc' silent_if_no_match
}
function __main__() {
if [[ "${1:-null}" == "help" ]] \
|| [[ "${1:-null}" == "--help" ]] ; then
@ -240,6 +243,7 @@ function __main__() {
read_seed_image_version
read_image_version
handle_rc_rebranding
handle_image_upgrade
echo "Done"

View file

@ -28,6 +28,7 @@ prompt() {
rebrand_sharelatex_env_variables() {
local filename=$1
local silent=${2:-no}
sharelatex_occurrences=$(set +o pipefail && grep -o "SHARELATEX_" "$TOOLKIT_ROOT/config/$filename" | wc -l | sed 's/ //g')
if [ "$sharelatex_occurrences" -gt 0 ]; then
echo "Found $sharelatex_occurrences lines with SHARELATEX_ in $filename"
@ -38,6 +39,8 @@ rebrand_sharelatex_env_variables() {
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/$filename"
if [[ "$silent" != "silent_if_no_match" ]]; then
echo "No 'SHARELATEX_' occurrences found in config/$filename"
fi
fi
}