mirror of
https://github.com/overleaf/toolkit.git
synced 2025-04-19 15:28:06 +02:00
wip: migrate saml/ldap config conditionally
This commit is contained in:
parent
7f9a9173f4
commit
088c722119
1 changed files with 34 additions and 0 deletions
34
bin/upgrade
34
bin/upgrade
|
@ -10,11 +10,35 @@ command -v realpath >/dev/null 2>&1 || realpath() {
|
|||
SCRIPT_PATH="$(realpath "${BASH_SOURCE[0]}")"
|
||||
SCRIPT_DIR="$(dirname "$SCRIPT_PATH")"
|
||||
TOOLKIT_ROOT="$(realpath "$SCRIPT_DIR/..")"
|
||||
VENDOR="$TOOLKIT_ROOT/bin/_vendor"
|
||||
if [[ ! -d "$TOOLKIT_ROOT/bin" ]] || [[ ! -d "$TOOLKIT_ROOT/config" ]]; then
|
||||
echo "ERROR: could not find root of overleaf-toolkit project (inferred project root as '$TOOLKIT_ROOT')"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
function _line_in_variables() {
|
||||
grep -qE "$1" "$TOOLKIT_ROOT/config/variables.env"
|
||||
}
|
||||
|
||||
function _migrate_update_ldap_saml_flags() {
|
||||
if _line_in_variables "^SHARELATEX_LDAP_URL=['\"]?.*['\"]?" \
|
||||
&& ! _line_in_variables "SHARELATEX_LDAP_ENABLE="
|
||||
then
|
||||
echo "Updating LDAP settings in config/variables.env"
|
||||
sed -E -i.bak "/^SHARELATEX_LDAP_URL=['\"]?.*['\"]?/ i\
|
||||
SHARELATEX_LDAP_ENABLE=true # introduced in 3.0" \
|
||||
"$TOOLKIT_ROOT/config/variables.env"
|
||||
fi
|
||||
if _line_in_variables "^SHARELATEX_SAML_ENTRYPOINT=['\"]?.*['\"]?" \
|
||||
&& ! _line_in_variables "SHARELATEX_SAML_ENABLE="
|
||||
then
|
||||
echo "Updating SAML settings in config/variables.env"
|
||||
sed -E -i.bak "/^SHARELATEX_SAML_ENTRYPOINT=['\"]?.*['\"]?/ i\
|
||||
SHARELATEX_SAML_ENABLE=true # introduced in 3.0" \
|
||||
"$TOOLKIT_ROOT/config/variables.env"
|
||||
fi
|
||||
}
|
||||
|
||||
function usage() {
|
||||
echo "Usage: bin/upgrade"
|
||||
echo ""
|
||||
|
@ -144,6 +168,16 @@ function handle_image_upgrade() {
|
|||
echo "Over-writing config/version with $seed_image_version"
|
||||
cp "$TOOLKIT_ROOT/lib/config-seed/version" "$TOOLKIT_ROOT/config/version"
|
||||
|
||||
## Check if we need to run upgrade functions
|
||||
local old_version
|
||||
local new_version
|
||||
old_version="$(cat "$TOOLKIT_ROOT/config/__old-version")"
|
||||
new_version="$(cat "$TOOLKIT_ROOT/config/version")"
|
||||
if [[ "$("$VENDOR/semver-compare" "$old_version" '3.0.0')" == "-1" ]] && \
|
||||
[[ "$("$VENDOR/semver-compare" "$new_version" '3.0.0')" == "1" ]]; then
|
||||
_migrate_update_ldap_saml_flags
|
||||
fi
|
||||
|
||||
## Maybe offer to start services again
|
||||
if [[ "${services_stopped:-null}" == "true" ]]; then
|
||||
local should_start="n"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue