mirror of
https://github.com/overleaf/toolkit.git
synced 2025-04-19 07:18:06 +02:00
* Add scripts to rebrand variables.env and overleaf.rc
* Update bin/upgrade to prompt for config file rebrand
* Update bin/up to check for correct variable prefix
Ensures SHARELATEX_ is in place for version <= 4.x, and
OVERLEAF_ for version >= 5.x
* Rebrand variables for bin/docker-compose
Updates docker-compose.base.yml and sibling containers
base file with the changes in the script
* Update bin/doctor to support OVERLEAF_ prefix
* Update documentation with the OVERLEAF_ prefix
* Rebrand variables.env and overleaf.rc in config-seed
* Prepare config/version and CHANGELOG for release (WIP)
* Fix script documentation
Co-authored-by: Jakob Ackermann <jakob.ackermann@overleaf.com>
* Fix doctor logs
Co-authored-by: Jakob Ackermann <jakob.ackermann@overleaf.com>
* Remove unnecessary fallbacks to SHARELATEX_ vars
* SEt OVERLEAF_DATA_PATH to data/overleaf
* Remove duplicated environment entries
* Moved prefix brand checs from bin/up to bin/docker-compose
* Move set +o pipefail into subshell commands
* Use separate legacy compose files for required SHARELATEX_ vars
* Handle overleaf.rc rebranding before version upgrade
* Group output from rebranding process
* Move prompt for rebranding into helper function
* Refuse to start with mismatching ShareLaTeX vs Overleaf branded configs
* Print expected prefix when checking variables.env
* Print number of mismatching variables in overleaf.rc
* Check on variable rebranding from bin/doctor
* Cleanup bin/doctor lookup for ShareLaTeX branded overleaf.rc
* Update filesystem paths in bin/logs and docs
* Flag old TEXMFVAR entry in config/variables.env
REF: 1829e7ee2a
* Update config-seed version to 5.0.1 and changelog
---------
Co-authored-by: Jakob Ackermann <jakob.ackermann@overleaf.com>
103 lines
4.2 KiB
Bash
103 lines
4.2 KiB
Bash
# shellcheck shell=bash
|
|
# shellcheck disable=SC2034
|
|
# shellcheck source-path=..
|
|
|
|
function read_config() {
|
|
source "$TOOLKIT_ROOT/lib/default.rc"
|
|
# shellcheck source=/dev/null
|
|
source "$TOOLKIT_ROOT/config/overleaf.rc"
|
|
}
|
|
|
|
function read_image_version() {
|
|
IMAGE_VERSION="$(head -n 1 "$TOOLKIT_ROOT/config/version")"
|
|
if [[ ! "$IMAGE_VERSION" =~ ^([0-9]+)\.([0-9]+)\.[0-9]+(-RC[0-9]*)?(-with-texlive-full)?$ ]]; then
|
|
echo "ERROR: invalid version '${IMAGE_VERSION}'"
|
|
exit 1
|
|
fi
|
|
IMAGE_VERSION_MAJOR=${BASH_REMATCH[1]}
|
|
IMAGE_VERSION_MINOR=${BASH_REMATCH[2]}
|
|
}
|
|
|
|
prompt() {
|
|
read -p "$1 (y/n): " choice
|
|
if [[ ! "$choice" =~ [Yy] ]]; then
|
|
echo "Exiting."
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
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 "Rebranding from ShareLaTeX to Overleaf"
|
|
echo " Found $sharelatex_occurrences lines with SHARELATEX_ in config/$filename"
|
|
local timestamp=$(date "+%Y.%m.%d-%H.%M.%S")
|
|
local backup_filename="__old-$filename.$timestamp"
|
|
echo " Will create backup of config/$filename at config/$backup_filename"
|
|
prompt " Proceed with the renaming in config/$filename?"
|
|
echo " Creating backup file config/$backup_filename"
|
|
cp "$TOOLKIT_ROOT/config/$filename" "$TOOLKIT_ROOT/config/$backup_filename"
|
|
echo " Replacing 'SHARELATEX_' with 'OVERLEAF_' in config/$filename"
|
|
sed -i "s/SHARELATEX_/OVERLEAF_/g" "$TOOLKIT_ROOT/config/$filename"
|
|
echo " Updated $sharelatex_occurrences lines in config/$filename"
|
|
else
|
|
if [[ "$silent" != "silent_if_no_match" ]]; then
|
|
echo "Rebranding from ShareLaTeX to Overleaf"
|
|
echo " No 'SHARELATEX_' occurrences found in config/$filename"
|
|
fi
|
|
fi
|
|
}
|
|
|
|
function check_sharelatex_env_vars() {
|
|
local rc_occurrences=$(set +o pipefail && grep -o SHARELATEX_ "$TOOLKIT_ROOT/config/overleaf.rc" | wc -l | sed 's/ //g')
|
|
|
|
if [ "$rc_occurrences" -gt 0 ]; then
|
|
echo "Rebranding from ShareLaTeX to Overleaf"
|
|
echo " The Toolkit has adopted to Overleaf brand for its variables."
|
|
echo " Your config/overleaf.rc still has $rc_occurrences variables using the previous ShareLaTeX brand."
|
|
echo " Moving forward the 'SHARELATEX_' prefixed variables must be renamed to 'OVERLEAF_'."
|
|
echo " You can migrate your config/overleaf.rc to use the Overleaf brand by running:"
|
|
echo ""
|
|
echo " toolkit$ bin/rename-rc-vars"
|
|
echo ""
|
|
exit 1
|
|
fi
|
|
|
|
local expected_prefix="OVERLEAF_"
|
|
local invalid_prefix="SHARELATEX_"
|
|
if [[ "$IMAGE_VERSION_MAJOR" -lt 5 ]]; then
|
|
expected_prefix="SHARELATEX_"
|
|
invalid_prefix="OVERLEAF_"
|
|
fi
|
|
|
|
local env_occurrences=$(set +o pipefail && grep -o "$invalid_prefix" "$TOOLKIT_ROOT/config/variables.env" | wc -l | sed 's/ //g')
|
|
|
|
if [ "$env_occurrences" -gt 0 ]; then
|
|
echo "Rebranding from ShareLaTeX to Overleaf"
|
|
echo " Starting with Overleaf CE and Server Pro version 5.0.0 the environment variables will use the Overleaf brand."
|
|
echo " Previous versions used the ShareLaTeX brand for environment variables."
|
|
echo " Your config/variables.env has $env_occurrences entries matching '$invalid_prefix', expected prefix '$expected_prefix'."
|
|
echo " Please align your config/version with the naming scheme of variables in config/variables.env."
|
|
if [[ ! "$IMAGE_VERSION_MAJOR" -lt 5 ]]; then
|
|
echo " You can migrate your config/variables.env to use the Overleaf brand by running:"
|
|
echo ""
|
|
echo " toolkit$ bin/rename-env-vars-5-0"
|
|
echo ""
|
|
fi
|
|
exit 1
|
|
fi
|
|
|
|
if [[ ! "$IMAGE_VERSION_MAJOR" -lt 5 ]]; then
|
|
if grep -q -e 'TEXMFVAR=/var/lib/sharelatex/tmp/texmf-var' "$TOOLKIT_ROOT/config/variables.env"; then
|
|
echo "Rebranding from ShareLaTeX to Overleaf"
|
|
echo " The 'TEXMFVAR' override is not needed since Server Pro/Overleaf CE version 3.2 (August 2022) and it conflicts with the rebranded paths."
|
|
echo " Please remove the following entry from your config/variables.env:"
|
|
echo ""
|
|
echo " TEXMFVAR=/var/lib/sharelatex/tmp/texmf-var"
|
|
echo ""
|
|
exit 1
|
|
fi
|
|
fi
|
|
}
|