2020-07-03 03:01:37 +08:00
|
|
|
#!/bin/bash
|
2020-07-24 13:42:51 +08:00
|
|
|
set -e
|
|
|
|
|
2020-07-03 03:01:37 +08:00
|
|
|
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`
|
2020-07-24 13:42:51 +08:00
|
|
|
if [ "$CHECK_CONTAINER" = "1" ]; then
|
2020-07-03 03:01:37 +08:00
|
|
|
echo "Killing container"
|
2020-07-24 13:42:51 +08:00
|
|
|
docker kill bbb-libreoffice-${INSTANCE_NUMBER};
|
|
|
|
sleep 1
|
|
|
|
fi;
|
2020-07-03 03:01:37 +08:00
|
|
|
}
|
|
|
|
|
2020-07-03 03:20:36 +08:00
|
|
|
trap _kill SIGINT
|
2020-07-03 03:01:37 +08:00
|
|
|
|
|
|
|
|
2020-07-24 13:42:51 +08:00
|
|
|
if (($INSTANCE_NUMBER >= 1)); then
|
2020-07-03 03:01:37 +08:00
|
|
|
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
|
|
|
|
|
|
|
_kill
|
|
|
|
|
2020-07-24 13:42:51 +08:00
|
|
|
let PORT=8200+${INSTANCE_NUMBER}
|
|
|
|
|
|
|
|
SOFFICE_WORK_DIR="/var/tmp/soffice_"`printf "%02d\n" $INSTANCE_NUMBER`
|
|
|
|
|
2020-07-24 23:29:24 +08:00
|
|
|
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
|
|
|
|
|
|
|
|
|
2020-08-03 07:05:11 +08:00
|
|
|
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 &
|
2020-07-03 03:20:36 +08:00
|
|
|
|
|
|
|
wait $!
|
2020-07-03 03:01:37 +08:00
|
|
|
else
|
|
|
|
echo ;
|
|
|
|
echo "Invalid or missing parameter INSTANCE_NUMBER"
|
|
|
|
echo " Usage: $0 INSTANCE_NUMBER"
|
|
|
|
exit 1
|
|
|
|
fi;
|