forked from bigbluebutton/bigbluebutton
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add scripts for install/uninstall ( and service scripts )
- Loading branch information
1 parent
d7ab880
commit daea732
Showing
6 changed files
with
160 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[Unit] | ||
Description=BigBlueButton Libre Office container | ||
Requires=network.target | ||
|
||
[Service] | ||
Type=simple | ||
WorkingDirectory=/tmp | ||
ExecStart=/usr/share/bbb-libreoffice/libreoffice_container.sh INSTANCE_NUMBER | ||
ExecStop=/usr/bin/docker kill bbb-libreoffice-INSTANCE_NUMBER | ||
Restart=always | ||
RestartSec=60 | ||
SuccessExitStatus= | ||
TimeoutStopSec=30 | ||
PermissionsStartOnly=true | ||
LimitNOFILE=1024 | ||
|
||
[Install] | ||
WantedBy=multi-user.target | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/bash | ||
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 INT | ||
trap _kill TERM | ||
|
||
|
||
if (($INSTANCE_NUMBER >= 1 && $INSTANCE_NUMBER <= 10)); then | ||
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" | ||
|
||
_kill | ||
|
||
docker run --name bbb-libreoffice-${INSTANCE_NUMBER} -p 82${INSTANCE_NUMBER}:8000 -v/var/tmp/soffice${INSTANCE_NUMBER}:/var/tmp/soffice${INSTANCE_NUMBER} --rm bbb-libreoffice | ||
else | ||
echo ; | ||
echo "Invalid or missing parameter INSTANCE_NUMBER" | ||
echo " Usage: $0 INSTANCE_NUMBER" | ||
exit 1 | ||
fi; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
FROM openjdk:8-jre | ||
|
||
ENV DEBIAN_FRONTEND noninteractive | ||
|
||
RUN apt update | ||
|
||
RUN addgroup --system --gid 996 libreoffice | ||
RUN adduser --disabled-password --system --disabled-login --shell /sbin/nologin --gid 996 --uid 996 libreoffice | ||
|
||
RUN apt -y install locales-all fontconfig libxt6 libxrender1 | ||
RUN apt -y install libreoffice --no-install-recommends | ||
|
||
RUN dpkg-reconfigure fontconfig && fc-cache -f -s -v | ||
|
||
RUN for i in `seq -w 1 10` ; do mkdir -m 777 /var/tmp/soffice${i}; done | ||
|
||
VOLUME ["/usr/share/fonts/"] | ||
RUN chown libreoffice /home/libreoffice/ | ||
|
||
ADD ./bbb-libreoffice-entrypoint.sh /home/libreoffice/ | ||
RUN chown -R libreoffice /home/libreoffice/ | ||
RUN chmod 700 /home/libreoffice/bbb-libreoffice-entrypoint.sh | ||
|
||
USER libreoffice | ||
|
||
ENTRYPOINT ["/home/libreoffice/bbb-libreoffice-entrypoint.sh" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
|
||
## Initialize environment | ||
/usr/lib/libreoffice/program/soffice.bin -env:UserInstallation="file:///tmp/" | ||
|
||
## Run daemon | ||
/usr/lib/libreoffice/program/soffice.bin --accept="socket,host=0.0.0.0,port=8000,tcpNoDelay=1;urp;StarOffice.ServiceManager" --headless --invisible --nocrashreport --nodefault --nofirststartwizard --nolockcheck --nologo --norestore -env:UserInstallation="file:///tmp/" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/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 -t bbb-libreoffice docker/ | ||
else | ||
echo "Docker image already exists"; | ||
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/ | ||
|
||
for i in `seq 1 4` ; do | ||
cat assets/bbb-libreoffice.service | sed 's/INSTANCE_NUMBER/0'${i}'/g' > /lib/systemd/system/bbb-libreoffice-0${i}.service | ||
done | ||
|
||
systemctl daemon-reload | ||
|
||
else | ||
echo "Install folder already exists" | ||
fi; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
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 "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 -n 1 systemctl stop | ||
|
||
echo "Removing install folder" | ||
rm -rf /usr/share/bbb-libreoffice/ | ||
|
||
echo "Removing service definitions" | ||
rm /lib/systemd/system/bbb-libreoffice-0* | ||
find /etc/systemd/ | grep bbb-libreoffice | xargs --no-run-if-empty -n 1 -I __ rm __ | ||
systemctl daemon-reload | ||
fi; |