diff --git a/bbb-common-web/project/Dependencies.scala b/bbb-common-web/project/Dependencies.scala index b575348add41b800fda67b0fc66b6bd2e81a82bf..49b18a58d95ebbed386ec4daea88ebf297138121 100644 --- a/bbb-common-web/project/Dependencies.scala +++ b/bbb-common-web/project/Dependencies.scala @@ -21,10 +21,8 @@ object Dependencies { val apacheHttpAsync = "4.1.4" // Office and document conversion - val jodConverter = "4.3.0" val apachePoi = "4.1.2" val nuProcess = "1.2.4" - val libreOffice = "5.4.2" // Server val servlet = "3.1.0" @@ -46,7 +44,7 @@ object Dependencies { val scalaCompiler = "org.scala-lang" % "scala-compiler" % Versions.scala val akkaActor = "com.typesafe.akka" % "akka-actor_2.12" % Versions.akkaVersion - val akkaSl4fj = "com.typesafe.akka" % "akka-slf4j_2.12" % Versions.akkaVersion % "runtime" + val akkaSl4fj = "com.typesafe.akka" % "akka-slf4j_2.12" % Versions.akkaVersion val googleGson = "com.google.code.gson" % "gson" % Versions.gson val jacksonModule = "com.fasterxml.jackson.module" %% "jackson-module-scala" % Versions.jackson @@ -56,14 +54,8 @@ object Dependencies { val apacheHttpAsync = "org.apache.httpcomponents" % "httpasyncclient" % Versions.apacheHttpAsync val poiXml = "org.apache.poi" % "poi-ooxml" % Versions.apachePoi - val jodConverter = "org.jodconverter" % "jodconverter-local" % Versions.jodConverter val nuProcess = "com.zaxxer" % "nuprocess" % Versions.nuProcess - val officeUnoil = "org.libreoffice" % "unoil" % Versions.libreOffice - val officeRidl = "org.libreoffice" % "ridl" % Versions.libreOffice - val officeJuh = "org.libreoffice" % "juh" % Versions.libreOffice - val officejurt = "org.libreoffice" % "jurt" % Versions.libreOffice - val servletApi = "javax.servlet" % "javax.servlet-api" % Versions.servlet val apacheLang = "org.apache.commons" % "commons-lang3" % Versions.lang @@ -99,7 +91,6 @@ object Dependencies { Compile.apacheHttp, Compile.apacheHttpAsync, Compile.poiXml, - Compile.jodConverter, Compile.nuProcess, Compile.servletApi, Compile.apacheLang, diff --git a/bbb-common-web/src/main/java/org/bigbluebutton/presentation/DocumentConversionServiceImp.java b/bbb-common-web/src/main/java/org/bigbluebutton/presentation/DocumentConversionServiceImp.java index e9e7d3b489b337e0e3538c60a69454bf42d9481e..c3ec28664729fd9158dee1eaf9bbf849d71b5b4b 100755 --- a/bbb-common-web/src/main/java/org/bigbluebutton/presentation/DocumentConversionServiceImp.java +++ b/bbb-common-web/src/main/java/org/bigbluebutton/presentation/DocumentConversionServiceImp.java @@ -19,8 +19,6 @@ package org.bigbluebutton.presentation; -import java.io.File; -import java.io.IOException; import java.util.HashMap; import java.util.Map; import org.bigbluebutton.api2.IBbbWebApiGWApp; @@ -28,7 +26,6 @@ import org.bigbluebutton.presentation.imp.*; import org.bigbluebutton.presentation.messages.DocConversionRequestReceived; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.bigbluebutton.api.Util; import com.google.gson.Gson; public class DocumentConversionServiceImp implements DocumentConversionService { diff --git a/bbb-common-web/src/main/java/org/bigbluebutton/presentation/handlers/Office2PdfConverterHandler.java b/bbb-common-web/src/main/java/org/bigbluebutton/presentation/handlers/Office2PdfConverterHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..b1029270ffb0fedcc655aa12deb0c18230c0da01 --- /dev/null +++ b/bbb-common-web/src/main/java/org/bigbluebutton/presentation/handlers/Office2PdfConverterHandler.java @@ -0,0 +1,29 @@ +/** + * BigBlueButton open source conferencing system - http://www.bigbluebutton.org/ + * + * Copyright (c) 2017 BigBlueButton Inc. and by respective authors (see below). + * + * This program is free software; you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free Software + * Foundation; either version 3.0 of the License, or (at your option) any later + * version. + * + * BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along + * with BigBlueButton; if not, see <http://www.gnu.org/licenses/>. + * + */ +package org.bigbluebutton.presentation.handlers; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class Office2PdfConverterHandler extends AbstractCommandHandler { + private static Logger log = LoggerFactory.getLogger(Office2PdfConverterHandler.class); +} diff --git a/bbb-common-web/src/main/java/org/bigbluebutton/presentation/imp/Office2PdfPageConverter.java b/bbb-common-web/src/main/java/org/bigbluebutton/presentation/imp/Office2PdfPageConverter.java index 96233285cb8cf6c1e5383238c264c64db4d1c84e..f78002e686aaa7ee050ce8b066c4b6e29e8181a7 100755 --- a/bbb-common-web/src/main/java/org/bigbluebutton/presentation/imp/Office2PdfPageConverter.java +++ b/bbb-common-web/src/main/java/org/bigbluebutton/presentation/imp/Office2PdfPageConverter.java @@ -19,20 +19,17 @@ package org.bigbluebutton.presentation.imp; + import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.InputStream; +import java.util.Arrays; import java.util.HashMap; import java.util.Map; +import java.util.concurrent.TimeUnit; -import com.sun.org.apache.xerces.internal.impl.xs.opti.DefaultDocument; -import org.apache.commons.io.FilenameUtils; +import com.zaxxer.nuprocess.NuProcess; +import com.zaxxer.nuprocess.NuProcessBuilder; import org.bigbluebutton.presentation.UploadedPresentation; -import org.jodconverter.core.document.DefaultDocumentFormatRegistry; -import org.jodconverter.core.document.DocumentFormat; -import org.jodconverter.core.job.AbstractConverter; -import org.jodconverter.local.LocalConverter; +import org.bigbluebutton.presentation.handlers.Office2PdfConverterHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -42,10 +39,7 @@ public abstract class Office2PdfPageConverter { private static Logger log = LoggerFactory.getLogger(Office2PdfPageConverter.class); public static boolean convert(File presentationFile, File output, int page, UploadedPresentation pres, - LocalConverter converter){ - - FileInputStream inputStream = null; - FileOutputStream outputStream = null; + String presOfficeConversionExec){ try { Map<String, Object> logData = new HashMap<>(); @@ -58,14 +52,27 @@ public abstract class Office2PdfPageConverter { String logStr = gson.toJson(logData); log.info(" --analytics-- data={}", logStr); - final DocumentFormat sourceFormat = DefaultDocumentFormatRegistry.getFormatByExtension( - FilenameUtils.getExtension(presentationFile.getName())); + if(presOfficeConversionExec == null) throw new Exception("Cannot find the conversion script path."); + + File conversionScript = new File(presOfficeConversionExec); + if(!conversionScript.exists()) throw new Exception(String.format("File not found: %s.",presOfficeConversionExec)); - inputStream = new FileInputStream(presentationFile); - outputStream = new FileOutputStream(output); + log.info(String.format("Calling conversion script %s.", presOfficeConversionExec)); - converter.convert(inputStream).as(sourceFormat).to(outputStream).as(DefaultDocumentFormatRegistry.PDF).execute(); - outputStream.flush(); + NuProcessBuilder officeConverterExec = new NuProcessBuilder(Arrays.asList(presOfficeConversionExec, presentationFile.getAbsolutePath(), output.getAbsolutePath())); + Office2PdfConverterHandler office2PdfConverterHandler = new Office2PdfConverterHandler(); + officeConverterExec.setProcessListener(office2PdfConverterHandler); + + NuProcess process = officeConverterExec.start(); + try { + process.waitFor(0, TimeUnit.SECONDS); + } catch (InterruptedException e) { + log.error("InterruptedException while counting PDF pages {}", presentationFile.getName(), e); + } + + if(!office2PdfConverterHandler.isCommandSuccessful()) { + throw new Exception(String.format("Error while executing conversion script %s.", presOfficeConversionExec)); + } if (output.exists()) { return true; @@ -94,22 +101,6 @@ public abstract class Office2PdfPageConverter { String logStr = gson.toJson(logData); log.error(" --analytics-- data={}", logStr, e); return false; - } finally { - if(inputStream!=null) { - try { - inputStream.close(); - } catch(Exception e) { - - } - } - - if(outputStream!=null) { - try { - outputStream.close(); - } catch(Exception e) { - - } - } } } diff --git a/bbb-common-web/src/main/java/org/bigbluebutton/presentation/imp/OfficeDocumentConversionFilter.java b/bbb-common-web/src/main/java/org/bigbluebutton/presentation/imp/OfficeDocumentConversionFilter.java deleted file mode 100644 index 82a8b2daaeb5c5fc91e6ae481f089da0ee8d216b..0000000000000000000000000000000000000000 --- a/bbb-common-web/src/main/java/org/bigbluebutton/presentation/imp/OfficeDocumentConversionFilter.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.bigbluebutton.presentation.imp; - -import org.jodconverter.core.office.OfficeContext; -import org.jodconverter.local.filter.Filter; -import org.jodconverter.local.filter.FilterChain; -import org.jodconverter.local.office.utils.Lo; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.sun.star.lang.XComponent; -import com.sun.star.sheet.XCalculatable; - -public class OfficeDocumentConversionFilter implements Filter { - - private static Logger log = LoggerFactory.getLogger(OfficeDocumentConversionFilter.class); - - @Override - public void doFilter(OfficeContext context, XComponent document, FilterChain chain) - throws Exception { - - log.info("Applying the OfficeDocumentConversionFilter"); - Lo.qiOptional(XCalculatable.class, document).ifPresent((x) -> { - log.info("Turn AutoCalculate off"); - x.enableAutomaticCalculation(false); - }); - - chain.doFilter(context, document); - } -} diff --git a/bbb-common-web/src/main/java/org/bigbluebutton/presentation/imp/OfficeToPdfConversionService.java b/bbb-common-web/src/main/java/org/bigbluebutton/presentation/imp/OfficeToPdfConversionService.java old mode 100755 new mode 100644 index 7501d01268814b923f78040edd0a18c2d5a66a14..23de66c929fe5326a671260230b11a62ef672ab5 --- a/bbb-common-web/src/main/java/org/bigbluebutton/presentation/imp/OfficeToPdfConversionService.java +++ b/bbb-common-web/src/main/java/org/bigbluebutton/presentation/imp/OfficeToPdfConversionService.java @@ -17,34 +17,23 @@ * */ package org.bigbluebutton.presentation.imp; -import java.io.File; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; + +import com.google.gson.Gson; import org.bigbluebutton.presentation.ConversionMessageConstants; import org.bigbluebutton.presentation.SupportedFileTypes; import org.bigbluebutton.presentation.UploadedPresentation; -import org.jodconverter.core.office.OfficeException; -import org.jodconverter.core.office.OfficeUtils; -import org.jodconverter.local.LocalConverter; -import org.jodconverter.local.office.ExternalOfficeManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.sun.star.document.UpdateDocMode; -import com.google.gson.Gson; + +import java.io.File; +import java.util.HashMap; +import java.util.Map; + public class OfficeToPdfConversionService { private static Logger log = LoggerFactory.getLogger(OfficeToPdfConversionService.class); private OfficeDocumentValidator2 officeDocumentValidator; - private final ArrayList<ExternalOfficeManager> officeManagers; - private ExternalOfficeManager currentManager = null; private boolean skipOfficePrecheck = false; - private int sofficeBasePort = 0; - private int sofficeManagers = 0; - private String sofficeWorkingDirBase = null; - public OfficeToPdfConversionService() throws OfficeException { - officeManagers = new ArrayList<>(); - } + private String presOfficeConversionExec = null; /* * Convert the Office document to PDF. If successful, update * UploadPresentation.uploadedFile with the new PDF out and @@ -109,34 +98,12 @@ public class OfficeToPdfConversionService { boolean success = false; int attempts = 0; while(!success) { - final Map<String, Object> loadProperties = new HashMap<>(); - loadProperties.put("Hidden", true); - loadProperties.put("ReadOnly", true); - loadProperties.put("UpdateDocMode", UpdateDocMode.NO_UPDATE); - LocalConverter documentConverter = LocalConverter - .builder() - .officeManager(currentManager) - .loadProperties(loadProperties) - .filterChain(new OfficeDocumentConversionFilter()) - .build(); - - success = Office2PdfPageConverter.convert(pres.getUploadedFile(), pdfOutput, 0, pres, documentConverter); - + success = Office2PdfPageConverter.convert(pres.getUploadedFile(), pdfOutput, 0, pres, presOfficeConversionExec); + if(!success) { - // In case of failure, try with other open Office Manager - - if(++attempts != officeManagers.size()) { - // Go to next Office Manager ( if the last retry with the first one ) - int currentManagerIndex = officeManagers.indexOf(currentManager); - - boolean isLastManager = ( currentManagerIndex == officeManagers.size()-1 ); - if(isLastManager) { - currentManager = officeManagers.get(0); - } else { - currentManager = officeManagers.get(currentManagerIndex+1); - } + if(++attempts != 3) { + //Try again } else { - // We tried to use all our office managers and it's still failing break; } } @@ -158,67 +125,9 @@ public class OfficeToPdfConversionService { this.skipOfficePrecheck = skipOfficePrecheck; } - public void setSofficeBasePort(int sofficeBasePort) { - this.sofficeBasePort = sofficeBasePort; - } - - public void setSofficeManagers(int sofficeServiceManagers) { - this.sofficeManagers = sofficeServiceManagers; + public void setPresOfficeConversionExec(String presOfficeConversionExec) { + this.presOfficeConversionExec = presOfficeConversionExec; } - public void setSofficeWorkingDirBase(String sofficeWorkingDirBase) { - this.sofficeWorkingDirBase = sofficeWorkingDirBase; - } - - public void start() { - log.info("Starting LibreOffice pool with " + sofficeManagers + " managers, starting from port " + sofficeBasePort); - - for(int managerIndex = 0; managerIndex < sofficeManagers; managerIndex ++) { - Integer instanceNumber = managerIndex + 1; // starts at 1 - - try { - final File workingDir = new File(sofficeWorkingDirBase + String.format("%02d", instanceNumber)); - - if(!workingDir.exists()) { - workingDir.mkdir(); - } - - ExternalOfficeManager officeManager = ExternalOfficeManager - .builder() - .connectTimeout(2000L) - .retryInterval(500L) - .portNumber(sofficeBasePort + managerIndex) - .connectOnStart(false) // If it's true and soffice is not available, exception is thrown here ( we don't want exception here - we want the manager alive trying to reconnect ) - .workingDir(workingDir) - .build(); - - // Workaround for jodconverter not calling makeTempDir when connectOnStart=false (issue 211) - Method method = officeManager.getClass().getSuperclass().getDeclaredMethod("makeTempDir"); - method.setAccessible(true); - method.invoke(officeManager); - // End of workaround for jodconverter not calling makeTempDir - - officeManager.start(); - officeManagers.add(officeManager); - } catch (Exception e) { - log.error("Could not start Office Manager " + instanceNumber + ". Details: " + e.getMessage()); - } - } - - if (officeManagers.size() == 0) { - log.error("No office managers could be started"); - return; - } - - currentManager = officeManagers.get(0); - } - - public void stop() { - try { - officeManagers.forEach(officeManager -> officeManager.stop() ); - } catch (Exception e) { - log.error("Could not stop Office Manager", e); - } - } } diff --git a/bbb-libreoffice/assets/bbb-libreoffice.service b/bbb-libreoffice/assets/bbb-libreoffice.service deleted file mode 100644 index a61bdc64731e1a514b6b32f8f8e0e5fdba6793b2..0000000000000000000000000000000000000000 --- a/bbb-libreoffice/assets/bbb-libreoffice.service +++ /dev/null @@ -1,19 +0,0 @@ -[Unit] -Description=BigBlueButton Libre Office container %i -Requires=network.target - -[Service] -Type=simple -WorkingDirectory=/tmp -ExecStart=/usr/share/bbb-libreoffice/libreoffice_container.sh %i -ExecStop=/usr/bin/docker kill bbb-libreoffice-%i -Restart=always -RestartSec=60 -SuccessExitStatus= -TimeoutStopSec=30 -PermissionsStartOnly=true -LimitNOFILE=1024 - -[Install] -WantedBy=multi-user.target - diff --git a/bbb-libreoffice/assets/convert-local.sh b/bbb-libreoffice/assets/convert-local.sh new file mode 100644 index 0000000000000000000000000000000000000000..965180165a92d242102762f0690503d03d60e09a --- /dev/null +++ b/bbb-libreoffice/assets/convert-local.sh @@ -0,0 +1,19 @@ +#!/bin/bash +# Conversion of office files to Pdf using local docker bbb-soffice + +# This script receives two params +# Param 1: Input office file path (e.g. "/tmp/test.odt") +# Param 2: Output pdf file path (e.g. "/tmp/test.pdf") + +while [ -z "$randomDirectoryName" -o -d "/tmp/bbb-libreoffice-conversion/$randomDirectoryName" ]; do + randomDirectoryName=$(shuf -i 100000000-999999999 -n 1) +done + +mkdir -p "/tmp/bbb-libreoffice-conversion/" +mkdir "/tmp/bbb-libreoffice-conversion/$randomDirectoryName/" +cp "$1" "/tmp/bbb-libreoffice-conversion/$randomDirectoryName/file" +sudo /usr/bin/docker run --rm --network none --env="HOME=/tmp/" -w /tmp/ --user=$(printf %05d `id -u`) -v "/tmp/bbb-libreoffice-conversion/$randomDirectoryName/":/data/ --rm bbb-soffice sh -c "/usr/bin/soffice -env:UserInstallation=file:///tmp/ --convert-to pdf --outdir /data /data/file" +cp "/tmp/bbb-libreoffice-conversion/$randomDirectoryName/file.pdf" "$2" +rm -r "/tmp/bbb-libreoffice-conversion/$randomDirectoryName/" + +exit 0 diff --git a/bbb-libreoffice/assets/convert-remote.sh b/bbb-libreoffice/assets/convert-remote.sh new file mode 100644 index 0000000000000000000000000000000000000000..5a0a9ca418374befca48504d16f15de8f7a0c2ff --- /dev/null +++ b/bbb-libreoffice/assets/convert-remote.sh @@ -0,0 +1,12 @@ +#/bin/bash +# This is a sample script - adjust it per your need +# 1 - setup a server with JOD-CONVERTER-REST ( docker run --memory 512m --rm -p 8080:8080 eugenmayer/jodconverter:rest ) +# 2 - replace the HOST information in below command with your server host + +# This script receives two params +# Param 1: Input office file path (e.g. "/tmp/test.odt") +# Param 2: Output pdf file path (e.g. "/tmp/test.pdf") + +curl -X POST "http://127.0.0.1:8080/lool/convert-to/pdf" -H "accept: application/octet-stream" -H "Content-Type: multipart/form-data" -F "data=@$1" > $2 + +exit 0 diff --git a/bbb-libreoffice/assets/libreoffice_container.sh b/bbb-libreoffice/assets/libreoffice_container.sh deleted file mode 100755 index dc1a4454c6109b420012a59bd475b1056d0ff08f..0000000000000000000000000000000000000000 --- a/bbb-libreoffice/assets/libreoffice_container.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/bash -set -e - -INSTANCE_NUMBER=$1 - -if [ -z "$INSTANCE_NUMBER" ]; then - INSTANCE_NUMBER=0 -fi; - -_kill() { - CHECK_CONTAINER=`docker inspect bbb-libreoffice-${INSTANCE_NUMBER} &> /dev/null && echo 1 || echo 0` - if [ "$CHECK_CONTAINER" = "1" ]; then - echo "Killing container" - docker kill bbb-libreoffice-${INSTANCE_NUMBER}; - sleep 1 - fi; -} - -trap _kill SIGINT - - -if (($INSTANCE_NUMBER >= 1)); then - PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" - - _kill - - let PORT=8200+${INSTANCE_NUMBER} - - SOFFICE_WORK_DIR="/var/tmp/soffice_"`printf "%02d\n" $INSTANCE_NUMBER` - - INPUT_RULE="INPUT -i br-soffice -m state --state NEW -j DROP" - iptables -C $INPUT_RULE || iptables -I $INPUT_RULE - - FORWARD_RULE="FORWARD -i br-soffice -m state --state NEW -j DROP" - iptables -C $FORWARD_RULE || iptables -I $FORWARD_RULE - - - docker run --network bbb-libreoffice --user `id -u bigbluebutton` --name bbb-libreoffice-${INSTANCE_NUMBER} -p $PORT:8000 -v${SOFFICE_WORK_DIR}:${SOFFICE_WORK_DIR} --rm bbb-libreoffice & - - wait $! -else - echo ; - echo "Invalid or missing parameter INSTANCE_NUMBER" - echo " Usage: $0 INSTANCE_NUMBER" - exit 1 -fi; diff --git a/bbb-libreoffice/assets/zzz-bbb-docker-libreoffice b/bbb-libreoffice/assets/zzz-bbb-docker-libreoffice new file mode 100644 index 0000000000000000000000000000000000000000..6a835ce8884496160a32c51d883f67a07d90849a --- /dev/null +++ b/bbb-libreoffice/assets/zzz-bbb-docker-libreoffice @@ -0,0 +1 @@ +bigbluebutton ALL=(ALL) NOPASSWD: /usr/bin/docker run --rm --network none --env=HOME=/tmp/ -w /tmp/ --user=[0-9][0-9][0-9][0-9][0-9] -v /tmp/bbb-libreoffice-conversion/[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]/\:/data/ --rm bbb-soffice sh -c /usr/bin/soffice -env\:UserInstallation=file\:///tmp/ --convert-to pdf --outdir /data /data/file diff --git a/bbb-libreoffice/docker-bbb-libreoffice/Dockerfile b/bbb-libreoffice/docker-bbb-libreoffice/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..eb5669bec1fd6c7f36e36caa7cab778d6b36dd93 --- /dev/null +++ b/bbb-libreoffice/docker-bbb-libreoffice/Dockerfile @@ -0,0 +1,16 @@ +FROM openjdk:8-jre + +ENV DEBIAN_FRONTEND noninteractive + +RUN apt update + +RUN apt -y install locales-all fontconfig libxt6 libxrender1 +RUN apt -y install --no-install-recommends libreoffice fonts-crosextra-carlito fonts-crosextra-caladea fonts-noto fonts-noto-cjk + + +RUN dpkg-reconfigure fontconfig && fc-cache -f -s -v + +VOLUME ["/usr/share/fonts/"] +ADD ./bbb-libreoffice-entrypoint.sh /usr/local/bin/ + +ENTRYPOINT ["/usr/local/bin/bbb-libreoffice-entrypoint.sh" ] diff --git a/bbb-libreoffice/docker/bbb-libreoffice-entrypoint.sh b/bbb-libreoffice/docker-bbb-libreoffice/bbb-libreoffice-entrypoint.sh old mode 100755 new mode 100644 similarity index 100% rename from bbb-libreoffice/docker/bbb-libreoffice-entrypoint.sh rename to bbb-libreoffice/docker-bbb-libreoffice/bbb-libreoffice-entrypoint.sh diff --git a/bbb-libreoffice/docker/Dockerfile b/bbb-libreoffice/docker/Dockerfile index eb5669bec1fd6c7f36e36caa7cab778d6b36dd93..4e557e484df5a269f2bbeca8548d5b9924a8a0ad 100644 --- a/bbb-libreoffice/docker/Dockerfile +++ b/bbb-libreoffice/docker/Dockerfile @@ -1,4 +1,4 @@ -FROM openjdk:8-jre +FROM openjdk:11-jre ENV DEBIAN_FRONTEND noninteractive @@ -10,7 +10,4 @@ RUN apt -y install --no-install-recommends libreoffice fonts-crosextra-carlito RUN dpkg-reconfigure fontconfig && fc-cache -f -s -v -VOLUME ["/usr/share/fonts/"] -ADD ./bbb-libreoffice-entrypoint.sh /usr/local/bin/ -ENTRYPOINT ["/usr/local/bin/bbb-libreoffice-entrypoint.sh" ] diff --git a/bbb-libreoffice/install.sh b/bbb-libreoffice/install.sh index 11d681c7ff57068a9c307055159fd78d5472fca3..e3641a05df403958069640728143e92e539f68d1 100755 --- a/bbb-libreoffice/install.sh +++ b/bbb-libreoffice/install.sh @@ -21,39 +21,37 @@ else echo "Docker already installed"; fi +#Uninstall old version of docker and service if exists (keep temporarily) +./uninstall-bbb-libreoffice.sh -IMAGE_CHECK=`docker image inspect bbb-libreoffice &> /dev/null && echo 1 || echo 0` +IMAGE_CHECK=`docker image inspect bbb-soffice &> /dev/null && echo 1 || echo 0` if [ "$IMAGE_CHECK" = "0" ]; then echo "Docker image doesn't exists, building" - docker build --no-cache -t bbb-libreoffice docker/ + docker build -t bbb-soffice docker/ else echo "Docker image already exists"; fi -NETWORK_CHECK=`docker network inspect bbb-libreoffice &> /dev/null && echo 1 || echo 0` - -if [ "$NETWORK_CHECK" = "0" ]; then - echo "Docker network doesn't exists, creating" - docker network create bbb-libreoffice -d bridge --opt com.docker.network.bridge.name=br-soffice -fi - -FOLDER_CHECK=`[ -d /usr/share/bbb-libreoffice/ ] && echo 1 || echo 0` +FOLDER_CHECK=`[ -d /usr/share/bbb-libreoffice-conversion/ ] && echo 1 || echo 0` if [ "$FOLDER_CHECK" = "0" ]; then echo "Install folder doesn't exists, installing" - mkdir -m 755 /usr/share/bbb-libreoffice/ - cp assets/libreoffice_container.sh /usr/share/bbb-libreoffice/ - chmod 700 /usr/share/bbb-libreoffice/libreoffice_container.sh - chown -R root /usr/share/bbb-libreoffice/ - - cp assets/bbb-libreoffice.service /lib/systemd/system/bbb-libreoffice@.service - systemctl daemon-reload - - for i in `seq 1 4` ; do - systemctl enable bbb-libreoffice@${i} - systemctl start bbb-libreoffice@${i} - done - + mkdir -m 755 /usr/share/bbb-libreoffice-conversion/ + cp assets/convert-local.sh /usr/share/bbb-libreoffice-conversion/ + cp assets/convert-remote.sh /usr/share/bbb-libreoffice-conversion/ + ln -sfn /usr/share/bbb-libreoffice-conversion/convert-local.sh /usr/share/bbb-libreoffice-conversion/convert.sh + chmod 755 /usr/share/bbb-libreoffice-conversion/convert-local.sh + chmod 755 /usr/share/bbb-libreoffice-conversion/convert-remote.sh + chmod 755 /usr/share/bbb-libreoffice-conversion/convert.sh + chown -R root /usr/share/bbb-libreoffice-conversion/ else echo "Install folder already exists" fi; +FILE_SUDOERS_CHECK=`[ -f /etc/sudoers.d/zzz-bbb-docker-libreoffice ] && echo 1 || echo 0` +if [ "$FILE_SUDOERS_CHECK" = "0" ]; then + echo "Sudoers file doesn't exists, installing" + cp assets/zzz-bbb-docker-libreoffice /etc/sudoers.d/zzz-bbb-docker-libreoffice +else + echo "Sudoers file already exists" +fi; + diff --git a/bbb-libreoffice/uninstall-bbb-libreoffice.sh b/bbb-libreoffice/uninstall-bbb-libreoffice.sh new file mode 100755 index 0000000000000000000000000000000000000000..991f4e36c81ffdee7f44ae17b6baf264bef6b76a --- /dev/null +++ b/bbb-libreoffice/uninstall-bbb-libreoffice.sh @@ -0,0 +1,37 @@ +#!/bin/bash +set -e + +if [ "$EUID" -ne 0 ]; then + echo "Please run this script as root ( or with sudo )" ; + exit 1; +fi; + +IMAGE_CHECK=`docker image inspect bbb-libreoffice 2>&1 > /dev/null && echo 1 || echo 0` +if [ "$IMAGE_CHECK" = "1" ]; then + echo "Stopping services" + systemctl --no-pager --no-legend --value --state=running | grep bbb-libreoffice | awk -F '.service' '{print $1}' | xargs --no-run-if-empty -n 1 systemctl stop + + echo "Removing image" + docker image rm bbb-libreoffice +fi + +FOLDER_CHECK=`[ -d /usr/share/bbb-libreoffice/ ] && echo 1 || echo 0` +if [ "$FOLDER_CHECK" = "1" ]; then + echo "Stopping services" + systemctl --no-pager --no-legend --value --state=running | grep bbb-libreoffice | awk -F '.service' '{print $1}' | xargs --no-run-if-empty -n 1 systemctl stop + + echo "Removing install folder" + rm -rf /usr/share/bbb-libreoffice/ + + echo "Removing service definitions" + rm /lib/systemd/system/bbb-libreoffice@.service + find /etc/systemd/ | grep bbb-libreoffice | xargs --no-run-if-empty -n 1 -I __ rm __ + systemctl daemon-reload +fi; + +NETWORK_CHECK=`docker network inspect bbb-libreoffice &> /dev/null && echo 1 || echo 0` +if [ "$NETWORK_CHECK" = "1" ]; then + echo "Removing docker network" + docker network remove bbb-libreoffice +fi + diff --git a/bbb-libreoffice/uninstall.sh b/bbb-libreoffice/uninstall.sh index 991f4e36c81ffdee7f44ae17b6baf264bef6b76a..c8143ccfa6b9d08ce605123864bdb50f7e70cf24 100755 --- a/bbb-libreoffice/uninstall.sh +++ b/bbb-libreoffice/uninstall.sh @@ -6,29 +6,30 @@ if [ "$EUID" -ne 0 ]; then exit 1; fi; -IMAGE_CHECK=`docker image inspect bbb-libreoffice 2>&1 > /dev/null && echo 1 || echo 0` -if [ "$IMAGE_CHECK" = "1" ]; then - echo "Stopping services" - systemctl --no-pager --no-legend --value --state=running | grep bbb-libreoffice | awk -F '.service' '{print $1}' | xargs --no-run-if-empty -n 1 systemctl stop +#Uninstall old version of docker and service if exists (keep temporarily) +./uninstall-bbb-libreoffice.sh + + +IMAGE_CHECK=`docker image inspect bbb-soffice 2>&1 > /dev/null && echo 1 || echo 0` +if [ "$IMAGE_CHECK" = "1" ]; then echo "Removing image" - docker image rm bbb-libreoffice + docker image rm bbb-soffice fi -FOLDER_CHECK=`[ -d /usr/share/bbb-libreoffice/ ] && echo 1 || echo 0` +FOLDER_CHECK=`[ -d /usr/share/bbb-libreoffice-conversion/ ] && echo 1 || echo 0` if [ "$FOLDER_CHECK" = "1" ]; then - echo "Stopping services" - systemctl --no-pager --no-legend --value --state=running | grep bbb-libreoffice | awk -F '.service' '{print $1}' | xargs --no-run-if-empty -n 1 systemctl stop - echo "Removing install folder" - rm -rf /usr/share/bbb-libreoffice/ + rm -rf /usr/share/bbb-libreoffice-conversion/ +fi; - echo "Removing service definitions" - rm /lib/systemd/system/bbb-libreoffice@.service - find /etc/systemd/ | grep bbb-libreoffice | xargs --no-run-if-empty -n 1 -I __ rm __ - systemctl daemon-reload +FILE_SUDOERS_CHECK=`[ -f /etc/sudoers.d/zzz-bbb-docker-libreoffice ] && echo 1 || echo 0` +if [ "$FILE_SUDOERS_CHECK" = "1" ]; then + echo "Removing Sudoers file" + rm /etc/sudoers.d/zzz-bbb-docker-libreoffice fi; + NETWORK_CHECK=`docker network inspect bbb-libreoffice &> /dev/null && echo 1 || echo 0` if [ "$NETWORK_CHECK" = "1" ]; then echo "Removing docker network" diff --git a/bigbluebutton-web/build.gradle b/bigbluebutton-web/build.gradle index 08317a990b544f7b919da12a357674320ce5df1b..75abab950d34f1bfa4e6eca52c8dc4c74b32a7b9 100755 --- a/bigbluebutton-web/build.gradle +++ b/bigbluebutton-web/build.gradle @@ -76,7 +76,6 @@ dependencies { compile "org.freemarker:freemarker:2.3.28" compile "com.google.code.gson:gson:2.8.5" compile "org.json:json:20180813" - compile "org.jodconverter:jodconverter-local:4.3.0" compile "com.zaxxer:nuprocess:1.2.4" compile "net.java.dev.jna:jna:4.5.1" // https://mvnrepository.com/artifact/commons-fileupload/commons-fileupload diff --git a/bigbluebutton-web/grails-app/conf/bigbluebutton.properties b/bigbluebutton-web/grails-app/conf/bigbluebutton.properties index c62481f1e42982bcd993095866e00daa717297ee..30bbcf15ef702a7f6e05eb73a28d1608c219fbc5 100755 --- a/bigbluebutton-web/grails-app/conf/bigbluebutton.properties +++ b/bigbluebutton-web/grails-app/conf/bigbluebutton.properties @@ -49,19 +49,8 @@ presCheckExec=/usr/share/prescheck/prescheck.sh skipOfficePrecheck=true #---------------------------------------------------- -# Number of soffice processes that are running on this machine -sofficeManagers=4 - -#---------------------------------------------------- -# Port number of the first soffice process -sofficeBasePort=8201 - -#---------------------------------------------------- -# Working directory prefix for each soffice process. -# The value of this is appended with the number of the -# soffice process (starting at 1), padded to two digits -# (e.g. /var/tmp/soffice_01 for the first process). -sofficeWorkingDirBase=/var/tmp/soffice_ +# Executable for presentation office conversion +presOfficeConversionExec=/usr/share/bbb-libreoffice-conversion/convert.sh #---------------------------------------------------- # These will be copied in cases where the conversion process diff --git a/bigbluebutton-web/grails-app/conf/spring/doc-conversion.xml b/bigbluebutton-web/grails-app/conf/spring/doc-conversion.xml index e7bc7f34c408b550e5576ddc7e50d3a3fcf95311..6c08a782cde840c0517fd1392719a38b15c2bcd4 100755 --- a/bigbluebutton-web/grails-app/conf/spring/doc-conversion.xml +++ b/bigbluebutton-web/grails-app/conf/spring/doc-conversion.xml @@ -34,14 +34,10 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>. <property name="presCheckExec" value="${presCheckExec}"/> </bean> - - <bean id="officeToPdfConversionService" class="org.bigbluebutton.presentation.imp.OfficeToPdfConversionService" - init-method="start" destroy-method="stop"> + <bean id="officeToPdfConversionService" class="org.bigbluebutton.presentation.imp.OfficeToPdfConversionService"> <property name="officeDocumentValidator" ref="officeDocumentValidator"/> <property name="skipOfficePrecheck" value="${skipOfficePrecheck}"/> - <property name="sofficeBasePort" value="${sofficeBasePort:8201}"/> - <property name="sofficeManagers" value="${sofficeManagers:4}"/> - <property name="sofficeWorkingDirBase" value="${sofficeWorkingDirBase:/var/tmp/soffice_}"/> + <property name="presOfficeConversionExec" value="${presOfficeConversionExec:/usr/share/bbb-libreoffice-conversion/convert.sh}"/> </bean> <bean id="pageExtractor" class="org.bigbluebutton.presentation.imp.PageExtractorImp"/>