diff --git a/docker-compose.yml b/docker-compose.yml index 13301b836..c0e45ea35 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -15,6 +15,10 @@ services: - CPAD_SANDBOX_DOMAIN=https://your-sandbox-domain.com - CPAD_CONF=/cryptpad/config/config.js + # Uncomment the next line, when you want to use OnlyOffice on + # your installation. TODO add link to license + # - CPAD_INSTALL_ONLYOFFICE=yes + volumes: - ./data/blob:/cryptpad/blob - ./data/block:/cryptpad/block diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 799e76513..af1323825 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -29,12 +29,16 @@ if [ ! -f "$CPAD_CONF" ]; then fi cd $CPAD_HOME -eval "$(ssh-agent -s)" # TODO remove this when repo is public -ssh-add install-onlyoffice-docker.key -mkdir -p ~/.ssh -chmod 0700 ~/.ssh -ssh-keyscan github.com > ~/.ssh/known_hosts -./install-onlyoffice.sh -c -l # TODO run only when OnlyOffice is enabled + +if [ "$CPAD_INSTALL_ONLYOFFICE" == "yes" ]; then + eval "$(ssh-agent -s)" # TODO remove this when repo is public + ssh-add install-onlyoffice-docker.key + mkdir -p ~/.ssh + chmod 0700 ~/.ssh + ssh-keyscan github.com > ~/.ssh/known_hosts + ./install-onlyoffice.sh -c -l +fi + npm run build exec "$@" diff --git a/install-onlyoffice.sh b/install-onlyoffice.sh index c34c03b1e..2fa1ed6bf 100755 --- a/install-onlyoffice.sh +++ b/install-onlyoffice.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -set -euxo pipefail +set -euo pipefail SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) BUILDS_DIR=$SCRIPT_DIR/onlyoffice-builds.git @@ -90,12 +90,14 @@ ensure_commit_exists () { 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 fi + echo Downloading OnlyOffice... git clone --bare git@github.com:cryptpad/onlyoffice-builds.git "$BUILDS_DIR" # TODO use https here, when repo is public } @@ -106,28 +108,31 @@ install_version () { local LAST_DIR LAST_DIR=$(pwd) - if [ ! -e "$FULL_DIR"/.commit ]; then - if [ "$(cat "$FULL_DIR"/.commit)" != "$COMMIT" ]; then - ensure_commit_exists "$COMMIT" + if [ ! -e "$FULL_DIR"/.commit ] || [ "$(cat "$FULL_DIR"/.commit)" != "$COMMIT" ]; then + ensure_commit_exists "$COMMIT" - if [ ! -e "$FULL_DIR"/.git ]; then - rm -rf "$FULL_DIR" - fi - - if [ -d "$FULL_DIR" ]; then - cd "$FULL_DIR" - git checkout "$COMMIT" - else - cd "$BUILDS_DIR" - git worktree add "$FULL_DIR" "$COMMIT" - fi - - cd "$LAST_DIR" - - echo "$COMMIT" > "$FULL_DIR"/.commit + if [ ! -e "$FULL_DIR"/.git ]; then + rm -rf "$FULL_DIR" fi + + if [ -d "$FULL_DIR" ]; then + cd "$FULL_DIR" + git checkout "$COMMIT" + else + cd "$BUILDS_DIR" + git worktree add "$FULL_DIR" "$COMMIT" + fi + + cd "$LAST_DIR" + + echo "$COMMIT" > "$FULL_DIR"/.commit + + echo "$DIR" updated + else + echo "$DIR" was up to date fi + if [ ${CLEAR+x} ]; then rm -f "$FULL_DIR"/.git fi