mirror of
https://github.com/overleaf/toolkit.git
synced 2025-04-19 23:38:06 +02:00
renamed script
This commit is contained in:
parent
8b9fc04f55
commit
be8835721f
1 changed files with 49 additions and 0 deletions
49
bin/rename-env-vars-5-0
Executable file
49
bin/rename-env-vars-5-0
Executable file
|
@ -0,0 +1,49 @@
|
|||
#! /usr/bin/env bash
|
||||
# shellcheck source-path=..
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
#### Detect Toolkit Project Root ####
|
||||
# if realpath is not available, create a semi-equivalent function
|
||||
command -v realpath >/dev/null 2>&1 || realpath() {
|
||||
[[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
|
||||
}
|
||||
SCRIPT_PATH="$(realpath "${BASH_SOURCE[0]}")"
|
||||
SCRIPT_DIR="$(dirname "$SCRIPT_PATH")"
|
||||
TOOLKIT_ROOT="$(realpath "$SCRIPT_DIR/..")"
|
||||
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
|
||||
|
||||
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 ""
|
||||
}
|
||||
|
||||
function __main__() {
|
||||
if [[ "${1:-null}" == "help" ]] || [[ "${1:-null}" == "--help" ]]; then
|
||||
usage
|
||||
exit
|
||||
fi
|
||||
|
||||
# read_image_version
|
||||
echo "This script will update your config/variables.env."
|
||||
echo "We recommend backing up your config with bin/backup-config."
|
||||
prompt "Do you want to continue?"
|
||||
|
||||
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 "Done."
|
||||
}
|
||||
|
||||
__main__ "$@"
|
Loading…
Add table
Add a link
Reference in a new issue