Includes dockerfile, install/uninstall script, exec scripts and sudoer permission to run office2pdf conversion, and removes previous way files

This commit is contained in:
Gustavo Trott 2021-03-23 10:59:27 -03:00
parent 2f56f7415d
commit 894d15614c
8 changed files with 151 additions and 42 deletions

View File

@ -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

View File

@ -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" ]

View File

@ -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" ]

View File

@ -0,0 +1,59 @@
#!/bin/bash
if [ "$EUID" -ne 0 ]; then
echo "Please run this script as root ( or with sudo )" ;
exit 1;
fi;
DOCKER_CHECK=`docker --version &> /dev/null && echo 1 || echo 0`
if [ "$DOCKER_CHECK" = "0" ]; then
echo "Docker not found";
apt update;
apt install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
apt update
apt install docker-ce -y
systemctl enable docker
systemctl start docker
systemctl status docker
else
echo "Docker already installed";
fi
IMAGE_CHECK=`docker image inspect bbb-libreoffice &> /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/
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`
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
else
echo "Install folder already exists"
fi;

View File

@ -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;

View File

@ -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

View File

@ -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/
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
rm -rf /usr/share/bbb-libreoffice-conversion/
fi;
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"