diff --git a/bbb-libreoffice/assets/convert-local.sh b/bbb-libreoffice/assets/convert-local.sh index 965180165a92d242102762f0690503d03d60e09a..89501ee83b7e38ec3f12e08520b44aaf5e151745 100644 --- a/bbb-libreoffice/assets/convert-local.sh +++ b/bbb-libreoffice/assets/convert-local.sh @@ -1,19 +1,31 @@ #!/bin/bash # Conversion of office files to Pdf using local docker bbb-soffice -# This script receives two params +# This script receives three params # Param 1: Input office file path (e.g. "/tmp/test.odt") # Param 2: Output pdf file path (e.g. "/tmp/test.pdf") +# Param 3: Output format (pdf default) while [ -z "$randomDirectoryName" -o -d "/tmp/bbb-libreoffice-conversion/$randomDirectoryName" ]; do randomDirectoryName=$(shuf -i 100000000-999999999 -n 1) done +#If output format is missing, define PDF +convertTo="${3:-pdf}" +convertToParam="--convert-to $convertTo" + +#If output is html, include param --writer to avoid blank page +if [ ${1: -5} == ".html" ] +then + convertToParam="$convertToParam --writer" +fi + mkdir -p "/tmp/bbb-libreoffice-conversion/" +chmod 777 "/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" +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/ $convertToParam --outdir /data /data/file" +cp "/tmp/bbb-libreoffice-conversion/$randomDirectoryName/file.$convertTo" "$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 index 5a0a9ca418374befca48504d16f15de8f7a0c2ff..e0df27cab5f73b90c8db287846d6a6b6e68942de 100644 --- a/bbb-libreoffice/assets/convert-remote.sh +++ b/bbb-libreoffice/assets/convert-remote.sh @@ -3,10 +3,14 @@ # 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 +# This script receives three params # Param 1: Input office file path (e.g. "/tmp/test.odt") # Param 2: Output pdf file path (e.g. "/tmp/test.pdf") +# Param 3: Destination Format (pdf default) -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 +#If output format is missing, define PDF +convertTo="${3:-pdf}" + +curl -X POST "http://127.0.0.1:8080/lool/convert-to/$convertTo" -H "accept: application/octet-stream" -H "Content-Type: multipart/form-data" -F "data=@$1" > $2 exit 0 diff --git a/bbb-libreoffice/assets/etherpad-export.sh b/bbb-libreoffice/assets/etherpad-export.sh new file mode 100644 index 0000000000000000000000000000000000000000..0643eadada5ff753b2bd326309318bf613479d7d --- /dev/null +++ b/bbb-libreoffice/assets/etherpad-export.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +#This script is used to enable Etherpad to export to PDF/ODT +# 1- Edit /usr/share/etherpad-lite/settings.json +# 2- Set "soffice" config to this script path + +/usr/share/bbb-libreoffice-conversion/convert.sh "$8" "$(echo $8 | sed 's/html/'$7'/')" $7 + +exit 0 \ No newline at end of file diff --git a/bbb-libreoffice/assets/zzz-bbb-docker-libreoffice b/bbb-libreoffice/assets/zzz-bbb-docker-libreoffice index 6a835ce8884496160a32c51d883f67a07d90849a..2b62bb9d7d2e4eaef488cd1b5fd0ad4f5a58da58 100644 --- a/bbb-libreoffice/assets/zzz-bbb-docker-libreoffice +++ b/bbb-libreoffice/assets/zzz-bbb-docker-libreoffice @@ -1 +1,3 @@ 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 +etherpad 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 --writer --outdir /data /data/file +etherpad 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 odt --writer --outdir /data /data/file \ No newline at end of file