Remove --keep to simplify install-onlyoffice.sh

https://github.com/cryptpad/cryptpad/issues/1416
This commit is contained in:
Wolfgang Ginolas 2024-03-18 15:24:40 +01:00 committed by wginolas
parent 52c7caf24b
commit d8cb5c02bd
4 changed files with 26 additions and 49 deletions

5
.gitignore vendored
View File

@ -32,8 +32,5 @@ lib/plugins/*
!lib/plugins/README.md
www/common/onlyoffice/v*
/onlyoffice-builds.git/
/www/common/onlyoffice/dist/
/install-onlyoffice-docker.key
/onlyoffice-dist/
/onlyoffice.properties
/onlyoffice-conf/

View File

@ -26,6 +26,7 @@ services:
- ./data/data:/cryptpad/data
- ./data/files:/cryptpad/datastore
- ./onlyoffice-dist:/cryptpad/www/common/onlyoffice/dist
- ./onlyoffice-conf:/cryptpad/onlyoffice-conf
ports:
- "3000:3000"

View File

@ -1,9 +1,9 @@
#!/bin/bash
# SPDX-FileCopyrightText: 2023 XWiki CryptPad Team <contact@cryptpad.org> and contributors
#
# SPDX-License-Identifier: AGPL-3.0-or-later
#/bin/bash
## Required vars
# CPAD_MAIN_DOMAIN
# CPAD_SANDBOX_DOMAIN
@ -31,10 +31,9 @@ fi
cd $CPAD_HOME
if [ "$CPAD_INSTALL_ONLYOFFICE" == "yes" ]; then
./install-onlyoffice.sh
./install-onlyoffice.sh --accept-license
fi
npm run build
exec "$@"

View File

@ -3,18 +3,26 @@
set -euo pipefail
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
BUILDS_DIR=$SCRIPT_DIR/onlyoffice-builds.git
CONF_DIR=$SCRIPT_DIR/onlyoffice-conf
BUILDS_DIR=$CONF_DIR/onlyoffice-builds.git
OO_DIR=$SCRIPT_DIR/www/common/onlyoffice/dist
PROPS_FILE="$SCRIPT_DIR"/onlyoffice.properties
PROPS_FILE="$CONF_DIR"/onlyoffice.properties
declare -A PROPS
main () {
mkdir -p "$CONF_DIR"
load_props
parse_arguments "$@"
ask_for_license
# Remeber the 1st version that is installed. This will help us install only
# needed OnlyOffice versions in a later version of this script.
set_prop oldest_needed_version v1
mkdir -p "$OO_DIR"
install_version v1 4f370beb
install_version v2b d9da72fd
@ -23,13 +31,10 @@ main () {
install_version v6 abd8a309
install_version v7 9d8b914a
if ! [ ${KEEP_REPO+x} ]; then
rm -rf "$BUILDS_DIR"
if command -v rdfind &> /dev/null; then
rdfind -makehardlinks true -makeresultsfile false $OO_DIR/v*
fi
rm -rf "$BUILDS_DIR"
if command -v rdfind &> /dev/null; then
rdfind -makehardlinks true -makeresultsfile false $OO_DIR/v*
fi
}
load_props () {
@ -55,10 +60,6 @@ parse_arguments () {
show_help
shift
;;
-k|--keep)
KEEP_REPO="1"
shift
;;
-a|--accept-license)
ACCEPT_LICENSE="1"
shift
@ -97,10 +98,6 @@ OPTIONS:
-h, --help
Show this help.
-k, --keep
Keep the onlyoffice-builds repo. This will use ~300MB and will make
future OnlyOffice upgrades faster.
-a, --accept-license
Accept the license of OnlyOffice and do not ask when running this
script. Read and accept this before using this option:
@ -109,23 +106,13 @@ EOF
exit 1
}
ensure_commit_exists () {
ensure_oo_is_downloaded () {
ensure_command_available git
if [ -d "$BUILDS_DIR" ]; then
local LAST_DIR
LAST_DIR=$(pwd)
cd "$BUILDS_DIR"
if ! git cat-file -e "$1"; then
echo Fetch new OnlyOffice version...
git fetch
fi
cd "$LAST_DIR"
return
if ! [ -d "$BUILDS_DIR" ]; then
echo Downloading OnlyOffice...
git clone --bare https://github.com/cryptpad/onlyoffice-builds.git "$BUILDS_DIR"
fi
echo Downloading OnlyOffice...
git clone --bare https://github.com/cryptpad/onlyoffice-builds.git "$BUILDS_DIR"
}
install_version () {
@ -136,19 +123,12 @@ install_version () {
LAST_DIR=$(pwd)
if [ ! -e "$FULL_DIR"/.commit ] || [ "$(cat "$FULL_DIR"/.commit)" != "$COMMIT" ]; then
ensure_commit_exists "$COMMIT"
ensure_oo_is_downloaded
if [ ! -e "$FULL_DIR"/.git ]; then
rm -rf "$FULL_DIR"
fi
rm -rf "$FULL_DIR"
if [ -d "$FULL_DIR" ]; then
cd "$FULL_DIR"
git checkout "$COMMIT"
else
cd "$BUILDS_DIR"
git worktree add "$FULL_DIR" "$COMMIT"
fi
cd "$BUILDS_DIR"
git worktree add "$FULL_DIR" "$COMMIT"
cd "$LAST_DIR"