From 99375dd4f3096bc260e81af538414e96ac7a0fbc Mon Sep 17 00:00:00 2001 From: Martin Winkler Date: Wed, 1 Jan 2020 23:29:18 +0100 Subject: [PATCH] New step to upgrade only office installation --- seqs/onlyoffice.cfg.example | 1 + seqs/onlyoffice.sh | 55 ++++++++++++++++++++++++++++++------- 2 files changed, 46 insertions(+), 10 deletions(-) diff --git a/seqs/onlyoffice.cfg.example b/seqs/onlyoffice.cfg.example index 48c2f44..7f1018e 100644 --- a/seqs/onlyoffice.cfg.example +++ b/seqs/onlyoffice.cfg.example @@ -4,3 +4,4 @@ onlyOfficePort="80" dockerDns1="80.241.218.68" # https://dismail.de/info.html#dns dockerDns2="46.182.19.48" # https://digitalcourage.de/support/zensurfreier-dns-server dockerDefaultConf="/etc/default/docker" +dockerImageName="onlyoffice/documentserver" diff --git a/seqs/onlyoffice.sh b/seqs/onlyoffice.sh index f21cab7..31695ca 100755 --- a/seqs/onlyoffice.sh +++ b/seqs/onlyoffice.sh @@ -34,7 +34,7 @@ step_config() { fi } -step_1_info() { echo "Install docker dependencies"; } +step_1_info() { echo "Install Docker dependencies"; } step_1_alias() { ALIAS="install"; } step_1() { local aptOption= @@ -48,11 +48,11 @@ step_1() { endReturn -o $? "Docker dependencies installation failed" } -step_2_info() { echo "Install docker repository"; } +step_2_info() { echo "Install Docker repository"; } step_2() { # Add official docker GPG key exep "curl -fsSL ${dockerGpgKeyUrl} | sudo apt-key add -" - + # Add stable repository exe add-apt-repository "deb [arch=amd64] ${dockerRepoUrl} $(lsb_release -cs) stable" endReturn -o $? "Failed to add Docker repository" @@ -60,7 +60,7 @@ step_2() { endReturn -o $? "Docker repository not available" } -step_3_info() { echo "Install latest docker version"; } +step_3_info() { echo "Install latest Docker version"; } step_3() { # Install the latest version if [ $QUIET -ne 0 ] ; then @@ -83,20 +83,51 @@ step_4() { fi } -step_5_info() { echo "Install/start onlyoffice docker container "; } +step_5_info() { + echo "Install/start onlyoffice docker container ." + echoinfo "If is empty, user input will be available if not run --quiet." + echoinfo "$toolName will be run unsecured if no secret was provied." +} step_5_alias() { ALIAS="startoo"; } step_5() { local options= + local secret= + + if [ ! -z "$2" ] ; then + secret="$2" + elif [ $QUIET -eq 0 ] ; then + exe read -s -p "JWT Secret: " secret + fi + # The correct expansion for missing SECRET or SECRET with spaces is not possible. # Therefore docker without secret needs to be called separately - if [ ! -z "$2" ] && [ "$2" != "" ] ; then + if [ ! -z "$secret" ] ; then options="-e JWT_ENABLED=true -e JWT_SECRET=" # This is the only way to provide SECRET($2) to docker command line which handles all types of characters. - exe docker run -i -t -d -p ${onlyOfficePort}:80 ${options}"$2" --restart=always onlyoffice/documentserver + exe docker run -i -t -d -p ${onlyOfficePort}:80 ${options}"$secret" --restart=always onlyoffice/documentserver else - echo " [I] Running $toolName without JWT (JSON Web Tokens)" + echoerr " [W] Running $toolName without JWT (JSON Web Tokens)" exe docker run -i -t -d -p ${onlyOfficePort}:80 --restart=always onlyoffice/documentserver fi + + unset secret +} + +step_7_info() { echo "Upgrade $toolName to latest version"; } +step_7_alias() { ALIAS="upgrade"; } +step_7() { + # get container ID + local containerId=$(docker ps -aqf ancestor="$dockerImageName") + if [ ! -z $containerId ] ; then + exe docker stop $containerId + exe docker rm $containerId + else + echoerr " [W] No $toolName Docker container found" + fi + exe docker pull $dockerImageName + endReturn -o $? "Error getting $toolName Docker update" + + step startoo } step_10_info() { echo "List running Docker container"; } @@ -109,14 +140,18 @@ step_10() { echo " e.g.: docker stop 70f1c5c81be2" } -step_12_info() { echo "Clean unused Docker data (unused containers, dangling images, networks and build cache)"; } +step_12_info() { + echo "Clean unused Docker data" + echoinfo "(unused containers, dangling images, networks, build cache and volumes)" +} step_12_alias() { ALIAS="prune"; } step_12() { exe docker system df exe docker system prune + exe docker volume prune } -step_100_info() { echo "Uninstall docker"; } +step_100_info() { echo "Uninstall Docker"; } step_100_alias() { ALIAS="uninstall"; } step_100() { exe apt-get purge docker-ce