mirror of
https://github.com/overleaf/toolkit.git
synced 2025-04-19 23:38:06 +02:00
Fix pathing in the upgrade script
This commit is contained in:
parent
30b3e6106c
commit
e46e080d33
1 changed files with 19 additions and 11 deletions
30
bin/upgrade
30
bin/upgrade
|
@ -1,6 +1,14 @@
|
|||
#! /usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
#### Detect Toolkit Project Root ####
|
||||
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
|
||||
|
||||
function usage() {
|
||||
echo "Usage: bin/upgrade"
|
||||
|
@ -15,7 +23,7 @@ function usage() {
|
|||
}
|
||||
|
||||
function services_up() {
|
||||
top_output="$(bin/docker-compose top)"
|
||||
top_output="$("$TOOLKIT_ROOT/bin/docker-compose" top)"
|
||||
if [[ -z "$top_output" ]]; then
|
||||
return 1
|
||||
else
|
||||
|
@ -25,7 +33,7 @@ function services_up() {
|
|||
|
||||
function git_pull_available() {
|
||||
branch="$1"
|
||||
fetch_output="$(git fetch --dry-run origin "$branch" 2>&1)"
|
||||
fetch_output="$(git -C "$TOOLKIT_ROOT" fetch --dry-run origin "$branch" 2>&1)"
|
||||
filtered_fetch_output="$(echo "$fetch_output" | grep '\-> origin/'"$branch")"
|
||||
if [[ -z "$filtered_fetch_output" ]]; then
|
||||
return 1
|
||||
|
@ -35,8 +43,8 @@ function git_pull_available() {
|
|||
}
|
||||
|
||||
function handle_image_upgrade() {
|
||||
user_image_version="$(head -n 1 config/version)"
|
||||
seed_image_version="$(head -n 1 lib/config-seed/version)"
|
||||
user_image_version="$(head -n 1 "$TOOLKIT_ROOT/config/version")"
|
||||
seed_image_version="$(head -n 1 "$TOOLKIT_ROOT/lib/config-seed/version")"
|
||||
|
||||
if [[ ! "$seed_image_version" > "$user_image_version" ]]; then
|
||||
echo "No change to docker image version"
|
||||
|
@ -68,7 +76,7 @@ function handle_image_upgrade() {
|
|||
fi
|
||||
services_stopped="true"
|
||||
echo "Stopping docker services"
|
||||
bin/docker-compose stop
|
||||
"$TOOLKIT_ROOT/bin/docker-compose" stop
|
||||
fi
|
||||
|
||||
## Advise the user to take a backup
|
||||
|
@ -85,9 +93,9 @@ function handle_image_upgrade() {
|
|||
|
||||
## Set the new image version
|
||||
echo "Backing up old version file to config/__old-version"
|
||||
cp config/version config/__old-version
|
||||
cp "$TOOLKIT_ROOT/config/version" "$TOOLKIT_ROOT/config/__old-version"
|
||||
echo "Over-writing config/version with $seed_image_version"
|
||||
cp lib/config-seed/version config/version
|
||||
cp "$TOOLKIT_ROOT/lib/config-seed/version" "$TOOLKIT_ROOT/config/version"
|
||||
|
||||
## Maybe offer to start services again
|
||||
if [[ "${services_stopped:-null}" == "true" ]]; then
|
||||
|
@ -95,14 +103,14 @@ function handle_image_upgrade() {
|
|||
read -r -p "Start docker services again? [y/n] " should_start
|
||||
if [[ "$should_start" =~ [Yy] ]]; then
|
||||
echo "Starting docker services"
|
||||
bin/docker-compose up -d
|
||||
"$TOOLKIT_ROOT/bin/docker-compose" up -d
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function handle_git_update() {
|
||||
current_branch="$(git rev-parse --abbrev-ref HEAD)"
|
||||
current_commit="$(git rev-parse --short HEAD)"
|
||||
current_branch="$(git -C "$TOOLKIT_ROOT" rev-parse --abbrev-ref HEAD)"
|
||||
current_commit="$(git -C "$TOOLKIT_ROOT" rev-parse --short HEAD)"
|
||||
|
||||
if [[ ! "$current_branch" == "master" ]]; then
|
||||
echo "Warning: current branch is not master, '$current_branch' instead"
|
||||
|
@ -122,7 +130,7 @@ function handle_git_update() {
|
|||
echo "Continuing without pulling update"
|
||||
else
|
||||
echo "Pulling new code..."
|
||||
git pull origin "$current_branch"
|
||||
git -C "$TOOLKIT_ROOT" pull origin "$current_branch"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue