Merge pull request #7 from gustavotrott/main
feat/refactor: New create_bbb.sh
This commit is contained in:
commit
0979642920
282
README.md
282
README.md
@ -10,57 +10,8 @@ An internet connection is required. It can be a shared network ( no need to forw
|
|||||||
|
|
||||||
## SSL certificate
|
## SSL certificate
|
||||||
|
|
||||||
Running a BigBlueButton server requires a SSL certificate. For this setup we're going to configure our own CA and emit our own certificate.
|
Running a BigBlueButton server requires a SSL certificate. The install script will automatically generate an self-signed certificate or you can rather specify a folder which contains a previous generated certificate.
|
||||||
|
|
||||||
### Create root CA
|
|
||||||
|
|
||||||
The following commands will create a root certificate authority with a random private key passphrase.
|
|
||||||
|
|
||||||
```sh
|
|
||||||
mkdir ~/bbb-docker-dev-setup/
|
|
||||||
cd ~/bbb-docker-dev-setup/
|
|
||||||
|
|
||||||
openssl rand -base64 48 > bbb-dev-ca.pass ;
|
|
||||||
chmod 600 bbb-dev-ca.pass ;
|
|
||||||
openssl genrsa -des3 -out bbb-dev-ca.key -passout file:bbb-dev-ca.pass 2048 ;
|
|
||||||
|
|
||||||
openssl req -x509 -new -nodes -key bbb-dev-ca.key -sha256 -days 1460 -passin file:bbb-dev-ca.pass -out bbb-dev-ca.crt -subj "/C=CA/ST=BBB/L=BBB/O=BBB/OU=BBB/CN=BBB-DEV" ;
|
|
||||||
```
|
|
||||||
|
|
||||||
Copy the CA to your trusted certificates ( so your browser will accept this certificate ):
|
|
||||||
|
|
||||||
```sh
|
|
||||||
sudo mkdir /usr/local/share/ca-certificates/bbb-dev/
|
|
||||||
sudo cp ~/bbb-docker-dev-setup/bbb-dev-ca.crt /usr/local/share/ca-certificates/bbb-dev/
|
|
||||||
sudo chmod 644 /usr/local/share/ca-certificates/bbb-dev/bbb-dev-ca.crt
|
|
||||||
sudo update-ca-certificates
|
|
||||||
```
|
|
||||||
|
|
||||||
### Generate a certificate for your first local BBB server
|
|
||||||
|
|
||||||
Here we're going to generate a certificate for domain `bbb-dev-01.test`.
|
|
||||||
|
|
||||||
```sh
|
|
||||||
cd ~/bbb-docker-dev-setup/
|
|
||||||
# change here if you want a different name
|
|
||||||
NAME="bbb-dev-01"
|
|
||||||
HOSTNAME="${NAME}.test"
|
|
||||||
openssl genrsa -out ${HOSTNAME}.key 2048
|
|
||||||
rm ${HOSTNAME}.csr ${HOSTNAME}.crt ${HOSTNAME}.key
|
|
||||||
cat > ${HOSTNAME}.ext << EOF
|
|
||||||
authorityKeyIdentifier=keyid,issuer
|
|
||||||
basicConstraints=CA:FALSE
|
|
||||||
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
|
|
||||||
subjectAltName = @alt_names
|
|
||||||
[alt_names]
|
|
||||||
DNS.1 = ${HOSTNAME}
|
|
||||||
EOF
|
|
||||||
|
|
||||||
openssl req -nodes -newkey rsa:2048 -keyout ${HOSTNAME}.key -out ${HOSTNAME}.csr -subj "/C=CA/ST=BBB/L=BBB/O=BBB/OU=BBB/CN=${HOSTNAME}" -addext "subjectAltName = DNS:${HOSTNAME}"
|
|
||||||
|
|
||||||
openssl x509 -req -in ${HOSTNAME}.csr -CA bbb-dev-ca.crt -CAkey bbb-dev-ca.key -CAcreateserial -out ${HOSTNAME}.crt -days 825 -sha256 -passin file:bbb-dev-ca.pass -extfile ${HOSTNAME}.ext
|
|
||||||
cd
|
|
||||||
```
|
|
||||||
|
|
||||||
## Docker setup
|
## Docker setup
|
||||||
|
|
||||||
@ -71,105 +22,160 @@ sudo usermod -aG docker `whoami`
|
|||||||
sudo reboot
|
sudo reboot
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## Container setup
|
## Container setup
|
||||||
|
|
||||||
This docker image is running a single container with BBB packages built from `develop` branch.
|
1. Save (right click, save as) the creation script in home directory (`~`): [create_bbb.sh](create_bbb.sh?raw=1)
|
||||||
|
|
||||||
Create a script in your home directory named `create_bbb.sh` with the following content:
|
|
||||||
|
|
||||||
|
2. Add permissions to the script:
|
||||||
```sh
|
```sh
|
||||||
#!/bin/bash
|
chmod +x create_bbb.sh
|
||||||
NAME="bbb-dev-01" # change here if you want a different name
|
|
||||||
HOSTNAME="${NAME}.test"
|
|
||||||
# IMAGE=imdt/bigbluebutton:2.4.x-develop # (for 2.4 development)
|
|
||||||
# IMAGE=imdt/bigbluebutton:2.6.x-develop # (for 2.6 development)
|
|
||||||
IMAGE=imdt/bigbluebutton:2.5.x-develop # (for 2.5 development)
|
|
||||||
|
|
||||||
# retag the commit to force a lookup but keep in cache
|
|
||||||
docker image inspect $IMAGE &>/dev/null && ( docker image tag $IMAGE $IMAGE-previous ; docker image rm $IMAGE )
|
|
||||||
|
|
||||||
# kill/remove existing container
|
|
||||||
docker inspect $NAME &> /dev/null && (
|
|
||||||
echo "Container with name $NAME already exists, removing."
|
|
||||||
docker kill $NAME ;
|
|
||||||
docker rm $NAME ;
|
|
||||||
)
|
|
||||||
|
|
||||||
if [ -d $HOME/$NAME ] ; then
|
|
||||||
echo "Directory $HOME/$NAME already exists, not initializing."
|
|
||||||
sleep 2;
|
|
||||||
else
|
|
||||||
mkdir $HOME/$NAME/
|
|
||||||
cd $HOME/$NAME/
|
|
||||||
git clone https://github.com/bigbluebutton/bigbluebutton.git
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd $HOME/$NAME/
|
|
||||||
mkdir $HOME/$NAME/certs/ -p
|
|
||||||
cp ~/bbb-docker-dev-setup/bbb-dev-ca.crt certs/
|
|
||||||
cat ~/bbb-docker-dev-setup/$HOSTNAME.crt > certs/fullchain.pem
|
|
||||||
cat ~/bbb-docker-dev-setup/bbb-dev-ca.crt >> certs/fullchain.pem
|
|
||||||
cat ~/bbb-docker-dev-setup/$HOSTNAME.key > certs/privkey.pem
|
|
||||||
|
|
||||||
cd
|
|
||||||
BBB_SRC_FOLDER=$HOME/$NAME/bigbluebutton
|
|
||||||
|
|
||||||
docker run -d --name=$NAME --hostname=$HOSTNAME --env="NODE_EXTRA_CA_CERTS=/usr/local/share/ca-certificates/bbb-dev/bbb-dev-ca.crt" --env="container=docker" --env="PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" --env="DEBIAN_FRONTEND=noninteractive" --volume="/var/run/docker.sock:/var/run/docker.sock:rw" --cap-add="NET_ADMIN" --privileged --volume="$HOME/$NAME/certs/:/local/certs:rw" --volume="/sys/fs/cgroup:/sys/fs/cgroup:ro" --volume="$BBB_SRC_FOLDER:/home/bigbluebutton/src:rw" --volume=docker_in_docker$NAME:/var/lib/docker -t $IMAGE
|
|
||||||
|
|
||||||
mkdir $HOME/.bbb/ &> /dev/null
|
|
||||||
echo "docker exec -u bigbluebutton -w /home/bigbluebutton/ -it $NAME /bin/bash -l" > $HOME/.bbb/$NAME.sh
|
|
||||||
chmod 755 $HOME/.bbb/$NAME.sh
|
|
||||||
|
|
||||||
echo "docker exec -u bigbluebutton -w /home/bigbluebutton/ $NAME /bin/hostname --ip-address" > $HOME/.bbb/ip-$NAME.sh
|
|
||||||
chmod 755 $HOME/.bbb/ip-$NAME.sh
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Add permissions to the script:
|
3. Run the script ( it will remove previously created dockers and create a new one):
|
||||||
|
Docker **bbb 2.6**
|
||||||
```sh
|
```
|
||||||
chmod 755 create_bbb.sh
|
./create_bbb.sh --image=imdt/bigbluebutton:2.6.x-develop --update bbb26
|
||||||
|
```
|
||||||
|
Docker **bbb 2.5**
|
||||||
|
```
|
||||||
|
./create_bbb.sh --image=imdt/bigbluebutton:2.5.x-develop --update bbb25
|
||||||
|
```
|
||||||
|
Docker **bbb 2.4**
|
||||||
|
```
|
||||||
|
./create_bbb.sh --image=imdt/bigbluebutton:2.4.x-develop --update bbb24
|
||||||
```
|
```
|
||||||
|
|
||||||
Run the script ( it will remove previously created dockers and create a new one):
|
|
||||||
|
|
||||||
```sh
|
Parameters:
|
||||||
./create_bbb.sh
|
`./create_bbb.sh [--update] [--fork=github_user] [--domain=domain_name] [--ip=ip_address] [--image=docker_image] [--cert=certificate_dir] {name}`
|
||||||
```
|
- {name}: Name of the container (e.g `bbb26`) **(REQUIRED)**
|
||||||
|
- --update: check for new image version `--update`
|
||||||
|
- --domain: set the host domain (e.g `--domain=test`), default: `test`. BBB URL will be `https://{NAME} + {DOMAIN}`
|
||||||
|
- --cert: specify the directory which contains a certificate (`fullchain.pem` and `privkey.pem`) (e.g `--cert=/tmp`) *(if absent a new certificate will be created)*
|
||||||
|
- --ip: force container IP (e.g `--ip=172.17.0.2`)
|
||||||
|
- --fork: Username in Github with bbb Fork `--fork=bigbluebutton`
|
||||||
|
- --image: Force an image different than default `--image=imdt/bigbluebutton:2.6.x-develop`
|
||||||
|
## Using the container
|
||||||
|
|
||||||
## Shell session within the container
|
### SSH session within the container
|
||||||
|
```
|
||||||
|
ssh bbb26
|
||||||
|
```
|
||||||
|
Replace **bbb26** with the {name} param of `create_bbb.sh`
|
||||||
|
|
||||||
You can open a shell session with the following command:
|
|
||||||
|
|
||||||
```sh
|
That's all, open https://bbb26.test in your browser and enjoy.
|
||||||
~/.bbb/bbb-dev-01.sh
|
|
||||||
```
|
|
||||||
|
|
||||||
## Configure your local machine DNS
|
|
||||||
|
|
||||||
Your computer `/etc/hosts` file must be configured in order to resolve the name of your container. You can do it by running the following command:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
echo `~/.bbb/ip-bbb-dev-01.sh | xargs -n 1 echo -n`" bbb-dev-01.test." | sudo tee -a /etc/hosts
|
|
||||||
```
|
|
||||||
|
|
||||||
## Running HTML5 from source code
|
|
||||||
|
|
||||||
To execute HTML5 component from source code, you need to open a shell session within your container ( see previous section ) and execute:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
# Restart all BBB services
|
|
||||||
sudo bbb-conf --restart
|
|
||||||
|
|
||||||
## Stop MongoDB and bbb-html5 services that are running from packages
|
|
||||||
sudo systemctl stop bbb-html5 mongod
|
|
||||||
|
|
||||||
## Start meteor in development mode ( it starts a bundled mongo too )
|
|
||||||
cd ~/src/bigbluebutton-html5/
|
|
||||||
npm install
|
|
||||||
npm start
|
|
||||||
```
|
|
||||||
|
|
||||||
That's all, open https://bbb-dev-01.test in your browser and enjoy.
|
|
||||||
|
|
||||||
PS: if you see certificate error in your browser, you need to add the CA certificate in it's trusted certificates. Instructions for Chrome and Firefox can be found [here](https://github.com/bigbluebutton/docker-dev/issues/1)
|
PS: if you see certificate error in your browser, you need to add the CA certificate in it's trusted certificates. Instructions for Chrome and Firefox can be found [here](https://github.com/bigbluebutton/docker-dev/issues/1)
|
||||||
|
|
||||||
|
## Removing an existing container
|
||||||
|
```
|
||||||
|
./create_bbb.sh --remove {container_name}
|
||||||
|
```
|
||||||
|
|
||||||
|
or rather you can remove a BBB docker image using `docker image rm imdt/bigbluebutton:2.6.x-develop --force`
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
## BBB-Conf
|
||||||
|
Link to the API-Mate: `bbb-conf --salt`
|
||||||
|
|
||||||
|
Restart BBB: `sudo bbb-conf --restart`
|
||||||
|
|
||||||
|
Check configs: `sudo bbb-conf --check`
|
||||||
|
|
||||||
|
---
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
In case of problems, you can update the packages by running:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo apt update
|
||||||
|
sudo apt dist-upgrade -y
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
# Instructions to run BigBlueButton from source (via command-line)
|
||||||
|
- **HTML5 - bigbluebutton-html5**: the Front-End (users meeting interface) [*Meteor*]
|
||||||
|
- **AKKA - akka-bbb-apps**: Backend that exchange msgs with Frontend through Redis pub/sub msgs (stores the meeting state and execute validations for Html5, *e.g: Can John send a message?*) [*Scala*]
|
||||||
|
- **API - bigbluebutton-web**: Receives requests e.g: Create room, Enter room (when someone asks to enter the room, enters the API and then is redirected to html5) [*Grails*]
|
||||||
|
- **-bbb-common-web**: Contains useful functions that are used by the API [*JAVA*]
|
||||||
|
- **bbb-common-message**: Contains all Redis messages! Akka and the API import this project to know the existing messages [*JAVA*]
|
||||||
|
|
||||||
|
Further informations in https://docs.bigbluebutton.org/2.6/dev.html
|
||||||
|
|
||||||
|
---
|
||||||
|
## HTML5 client
|
||||||
|
|
||||||
|
#### Running HTML5
|
||||||
|
```
|
||||||
|
cd ~/src/bigbluebutton-html5/
|
||||||
|
./run-dev.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Running HTML5 with **Full RESET** (needed sometimes)
|
||||||
|
```
|
||||||
|
cd ~/src/bigbluebutton-html5/
|
||||||
|
./run-dev.sh --reset
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
## Common-Message (required for BBB-Web and Akka)
|
||||||
|
```
|
||||||
|
cd ~/src/bbb-common-message
|
||||||
|
./deploy.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
## BBB-Web (API)
|
||||||
|
|
||||||
|
#### Running Bigbluebutton-web
|
||||||
|
```
|
||||||
|
cd ~/src/bigbluebutton-web/
|
||||||
|
./run-dev.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
**If `bbb-common-web` was changed run:**
|
||||||
|
```
|
||||||
|
cd ~/src/bbb-common-web
|
||||||
|
./deploy.sh
|
||||||
|
cd ~/src/bigbluebutton-web/
|
||||||
|
./build.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
## Akka-apps
|
||||||
|
|
||||||
|
#### Running Akka within **bbb-docker-dev**
|
||||||
|
```bash
|
||||||
|
cd ~/src/akka-bbb-apps/
|
||||||
|
./run-dev.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Running Akka on **IntelliJ IDEA**
|
||||||
|
- [Requires Common-Message](#common-message-required-for-bbb-web-and-akka)
|
||||||
|
- Open bbb-docker-dev SSH connection appending `-with-ports` to the command *(it will create tunnel for Redis port 6379)*
|
||||||
|
```bash
|
||||||
|
ssh {container_name}-with-ports
|
||||||
|
```
|
||||||
|
- Run Akka within Docker once, to set the configs
|
||||||
|
```bash
|
||||||
|
cd ~/src/akka-bbb-apps/
|
||||||
|
./run-dev.sh
|
||||||
|
```
|
||||||
|
- If everything is working, press `Ctrl + C` to stop
|
||||||
|
|
||||||
|
- Open IDEA, open the Sbt tab and run:
|
||||||
|
```
|
||||||
|
~reStart
|
||||||
|
```
|
||||||
|
![image](https://user-images.githubusercontent.com/5660191/158892260-8356d117-3be8-424a-aa24-ca405511f4e5.png)
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
## Redis
|
||||||
|
- To track the exchange of messages between applications
|
||||||
|
```
|
||||||
|
redis-cli psubscribe "*" | grep --line-buffered -v 'pmessage\|CheckRunningAndRecording\|MeetingInfoAnalyticsServiceMsg\|CheckAliveP\|GetUsersStatusToVoiceConfSysMsg\|SendCursorPosition\|DoLatencyTracerMsg'
|
||||||
|
```
|
||||||
|
314
create_bbb.sh
Executable file
314
create_bbb.sh
Executable file
@ -0,0 +1,314 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
NAME=
|
||||||
|
DOMAIN=test
|
||||||
|
IP=172.17.0.2
|
||||||
|
IMAGE=imdt/bigbluebutton:2.6.x-develop
|
||||||
|
GITHUB_USER=
|
||||||
|
CERT_DIR=
|
||||||
|
REMOVE_CONTAINER=0
|
||||||
|
CONTAINER_IMAGE=
|
||||||
|
|
||||||
|
for var in "$@"
|
||||||
|
do
|
||||||
|
if [[ ! $var == *"--"* ]] && [ ! $NAME ]; then
|
||||||
|
NAME="$var"
|
||||||
|
elif [[ $var == --image* ]] ; then
|
||||||
|
IMAGE=${var#*=}
|
||||||
|
CONTAINER_IMAGE=$IMAGE
|
||||||
|
elif [[ $var == "--remove" ]] ; then
|
||||||
|
REMOVE_CONTAINER=1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Container name: $NAME"
|
||||||
|
|
||||||
|
if [ ! $NAME ] ; then
|
||||||
|
echo "Missing name: ./create_bbb.sh [--update] [--fork=github_user] [--domain=domain_name] [--ip=ip_address] [--image=docker_image] [--cert=certificate_dir] {name}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
for container_id in $(docker ps -f name=$NAME -q) ; do
|
||||||
|
echo "Killing current $NAME"
|
||||||
|
docker kill $container_id;
|
||||||
|
done
|
||||||
|
|
||||||
|
for container_id in $(docker ps -f name=$NAME -q -a); do
|
||||||
|
CONTAINER_IMAGE="$(docker inspect --format '{{ .Config.Image }}' $NAME)"
|
||||||
|
echo "Removing container $NAME"
|
||||||
|
docker rm $container_id;
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "$(docker volume ls | grep \docker_in_docker${NAME}$)" ]; then
|
||||||
|
echo "Removing volume docker_in_docker$NAME"
|
||||||
|
sudo docker volume rm docker_in_docker$NAME;
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Remove entries from ~/.ssh/config
|
||||||
|
if [ -f ~/.ssh/config ] ; then
|
||||||
|
sed -i '/^Host '"$NAME"'$/,/^$/d' ~/.ssh/config
|
||||||
|
sed -i '/^Host '"$NAME-with-ports"'$/,/^$/d' ~/.ssh/config
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $REMOVE_CONTAINER == 1 ]; then
|
||||||
|
if [ $CONTAINER_IMAGE ]; then
|
||||||
|
echo
|
||||||
|
echo "----"
|
||||||
|
read -p "Do you want to remove the image $CONTAINER_IMAGE (y/n)? " -n 1 -r
|
||||||
|
echo
|
||||||
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||||
|
docker image rm $CONTAINER_IMAGE --force
|
||||||
|
echo "Image $CONTAINER_IMAGE removed!"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -d $HOME/$NAME ] ; then
|
||||||
|
echo
|
||||||
|
echo "----"
|
||||||
|
read -p "Do you want to remove all files from $HOME/$NAME (y/n)? " -n 1 -r
|
||||||
|
echo
|
||||||
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||||
|
rm -rf $HOME/$NAME
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Container $NAME removed!"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
echo "Using image $IMAGE"
|
||||||
|
|
||||||
|
for var in "$@"
|
||||||
|
do
|
||||||
|
if [ $var == "--update" ] ; then
|
||||||
|
echo "Checking for new version of image $IMAGE"
|
||||||
|
docker image tag $IMAGE ${IMAGE}_previous
|
||||||
|
docker image rm $IMAGE
|
||||||
|
docker pull $IMAGE
|
||||||
|
docker rmi ${IMAGE}_previous
|
||||||
|
elif [[ $var == --ip* ]] ; then
|
||||||
|
IP=${var#*=}
|
||||||
|
if [[ $IP == 172.17.* ]] ; then
|
||||||
|
echo "IP address can't start with 172.17"
|
||||||
|
return 1 2>/dev/null
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "Setting IP to $IP"
|
||||||
|
fi
|
||||||
|
elif [[ $var == --fork* ]] ; then
|
||||||
|
GITHUB_USER=${var#*=}
|
||||||
|
elif [[ $var == --cert* ]] ; then
|
||||||
|
CERT_DIR=${var#*=}
|
||||||
|
elif [[ $var == --domain* ]] ; then
|
||||||
|
DOMAIN=${var#*=}
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
mkdir -p $HOME/$NAME/
|
||||||
|
HOSTNAME=$NAME.$DOMAIN
|
||||||
|
|
||||||
|
|
||||||
|
BBB_SRC_FOLDER=$HOME/$NAME/bigbluebutton
|
||||||
|
if [ -d $BBB_SRC_FOLDER ] ; then
|
||||||
|
echo "Directory $HOME/$NAME/bigbluebutton already exists, not initializing."
|
||||||
|
sleep 2;
|
||||||
|
else
|
||||||
|
cd $HOME/$NAME/
|
||||||
|
|
||||||
|
if [ $GITHUB_USER ] ; then
|
||||||
|
git clone git@github.com:$GITHUB_USER/bigbluebutton.git
|
||||||
|
|
||||||
|
echo "Adding Git Upstream to https://github.com/bigbluebutton/bigbluebutton.git"
|
||||||
|
cd $HOME/$NAME/bigbluebutton
|
||||||
|
git remote add upstream https://github.com/bigbluebutton/bigbluebutton.git
|
||||||
|
else
|
||||||
|
git clone https://github.com/bigbluebutton/bigbluebutton.git
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd
|
||||||
|
|
||||||
|
#Shared folder to exchange data between local machine and container
|
||||||
|
BBB_SHARED_FOLDER=$HOME/$NAME/shared
|
||||||
|
mkdir -p $BBB_SHARED_FOLDER
|
||||||
|
|
||||||
|
###Certificate start -->
|
||||||
|
mkdir $HOME/$NAME/certs/ -p
|
||||||
|
if [ $CERT_DIR ] ; then
|
||||||
|
echo "Certificate directory passed: $CERT_DIR"
|
||||||
|
if [ ! -f $CERT_DIR/fullchain.pem ] ; then
|
||||||
|
echo "Error! $CERT_DIR/fullchain.pem not found."
|
||||||
|
exit 0
|
||||||
|
elif [ ! -f $CERT_DIR/privkey.pem ] ; then
|
||||||
|
echo "Error! $CERT_DIR/privkey.pem not found."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
cp $CERT_DIR/fullchain.pem $HOME/$NAME/certs/fullchain.pem
|
||||||
|
cp $CERT_DIR/privkey.pem $HOME/$NAME/certs/privkey.pem
|
||||||
|
echo "Using provided certificate successfully!"
|
||||||
|
elif [ -f $HOME/$NAME/certs/fullchain.pem ] && [ -f $HOME/$NAME/certs/privkey.pem ] ; then
|
||||||
|
echo "Certificate already exists, not creating."
|
||||||
|
sleep 2;
|
||||||
|
else
|
||||||
|
mkdir $HOME/$NAME/certs-source/ -p
|
||||||
|
#Create root CA
|
||||||
|
cd $HOME/$NAME/certs-source/
|
||||||
|
openssl rand -base64 48 > bbb-dev-ca.pass ;
|
||||||
|
chmod 600 bbb-dev-ca.pass ;
|
||||||
|
openssl genrsa -des3 -out bbb-dev-ca.key -passout file:bbb-dev-ca.pass 2048 ;
|
||||||
|
|
||||||
|
openssl req -x509 -new -nodes -key bbb-dev-ca.key -sha256 -days 1460 -passin file:bbb-dev-ca.pass -out bbb-dev-ca.crt -subj "/C=CA/ST=BBB/L=BBB/O=BBB/OU=BBB/CN=BBB-DEV" ;
|
||||||
|
|
||||||
|
#Copy the CA to your trusted certificates ( so your browser will accept this certificate )
|
||||||
|
sudo mkdir /usr/local/share/ca-certificates/bbb-dev/
|
||||||
|
sudo cp $HOME/$NAME/certs-source/bbb-dev-ca.crt /usr/local/share/ca-certificates/bbb-dev/
|
||||||
|
sudo chmod 644 /usr/local/share/ca-certificates/bbb-dev/bbb-dev-ca.crt
|
||||||
|
sudo update-ca-certificates
|
||||||
|
|
||||||
|
#Generate a certificate for your first local BBB server
|
||||||
|
cd $HOME/$NAME/certs-source/
|
||||||
|
openssl genrsa -out ${HOSTNAME}.key 2048
|
||||||
|
rm ${HOSTNAME}.csr ${HOSTNAME}.crt ${HOSTNAME}.key
|
||||||
|
cat > ${HOSTNAME}.ext << EOF
|
||||||
|
authorityKeyIdentifier=keyid,issuer
|
||||||
|
basicConstraints=CA:FALSE
|
||||||
|
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
|
||||||
|
subjectAltName = @alt_names
|
||||||
|
[alt_names]
|
||||||
|
DNS.1 = ${HOSTNAME}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
openssl req -nodes -newkey rsa:2048 -keyout ${HOSTNAME}.key -out ${HOSTNAME}.csr -subj "/C=CA/ST=BBB/L=BBB/O=BBB/OU=BBB/CN=${HOSTNAME}" -addext "subjectAltName = DNS:${HOSTNAME}"
|
||||||
|
openssl x509 -req -in ${HOSTNAME}.csr -CA bbb-dev-ca.crt -CAkey bbb-dev-ca.key -CAcreateserial -out ${HOSTNAME}.crt -days 825 -sha256 -passin file:bbb-dev-ca.pass -extfile ${HOSTNAME}.ext
|
||||||
|
|
||||||
|
cd $HOME/$NAME/
|
||||||
|
cp $HOME/$NAME/certs-source/bbb-dev-ca.crt certs/
|
||||||
|
cat $HOME/$NAME/certs-source/$HOSTNAME.crt > certs/fullchain.pem
|
||||||
|
cat $HOME/$NAME/certs-source/bbb-dev-ca.crt >> certs/fullchain.pem
|
||||||
|
cat $HOME/$NAME/certs-source/$HOSTNAME.key > certs/privkey.pem
|
||||||
|
rm -r $HOME/$NAME/certs-source
|
||||||
|
echo "Self-signed certificate created successfully!"
|
||||||
|
fi
|
||||||
|
### <-- Certificate end
|
||||||
|
|
||||||
|
|
||||||
|
SUBNET="$(echo $IP |cut -d "." -f 1).$(echo $IP |cut -d "." -f 2).0.0"
|
||||||
|
|
||||||
|
if [ $SUBNET == "172.17.0.0" ] ; then
|
||||||
|
SUBNETNAME="bridge"
|
||||||
|
else
|
||||||
|
SUBNETNAME="bbb_network_$(echo $IP |cut -d "." -f 1)_$(echo $IP |cut -d "." -f 2)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! "$(docker network ls | grep $SUBNETNAME)" ]; then
|
||||||
|
echo "Creating $SUBNETNAME network ..."
|
||||||
|
docker network create --driver=bridge --subnet=$SUBNET/16 $SUBNETNAME
|
||||||
|
else
|
||||||
|
echo "$SUBNETNAME network exists."
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
NETWORKPARAMS=""
|
||||||
|
if [ $SUBNETNAME != "bridge" ] ; then
|
||||||
|
NETWORKPARAMS="--ip=$IP --network $SUBNETNAME"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
#Create sbt publish folders to map in Docker
|
||||||
|
#It will sync the sbt libs in host machine and docker container (useful for backend development)
|
||||||
|
mkdir -p $HOME/.m2/repository/org/bigbluebutton
|
||||||
|
mkdir -p $HOME/.ivy2/local/org.bigbluebutton
|
||||||
|
|
||||||
|
docker run -d --name=$NAME --hostname=$HOSTNAME $NETWORKPARAMS -env="container=docker" --env="PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" --env="DEBIAN_FRONTEND=noninteractive" -v "/var/run/docker.sock:/var/run/docker.sock:rw" --cap-add="NET_ADMIN" --privileged -v "$HOME/$NAME/certs/:/local/certs:rw" --cgroupns=host -v "$BBB_SRC_FOLDER:/home/bigbluebutton/src:rw" -v "$BBB_SHARED_FOLDER:/home/bigbluebutton/shared:rw" -v "$HOME/.m2/repository/org/bigbluebutton:/home/bigbluebutton/.m2/repository/org/bigbluebutton:rw" -v "$HOME/.ivy2/local/org.bigbluebutton:/home/bigbluebutton/.ivy2/local/org.bigbluebutton:rw" -v docker_in_docker$NAME:/var/lib/docker -t $IMAGE
|
||||||
|
|
||||||
|
mkdir $HOME/.bbb/ &> /dev/null
|
||||||
|
echo "docker exec -u bigbluebutton -w /home/bigbluebutton/ -it $NAME /bin/bash -l" > $HOME/.bbb/$NAME.sh
|
||||||
|
chmod 755 $HOME/.bbb/$NAME.sh
|
||||||
|
|
||||||
|
#Create ssh key if absent
|
||||||
|
if [ ! -e ~/.ssh/id_rsa.pub ]; then
|
||||||
|
yes '' | ssh-keygen -N ''
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
docker exec -u bigbluebutton $NAME bash -c "mkdir -p ~/.ssh && echo $(cat ~/.ssh/id_rsa.pub) >> ~/.ssh/authorized_keys"
|
||||||
|
|
||||||
|
sleep 5s
|
||||||
|
if [ $SUBNETNAME == "bridge" ] ; then
|
||||||
|
DOCKERIP="$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' $NAME)"
|
||||||
|
else
|
||||||
|
DOCKERIP="$(docker inspect --format '{{ .NetworkSettings.Networks.'"$SUBNETNAME"'.IPAddress }}' $NAME)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! $DOCKERIP ] ; then
|
||||||
|
echo "ERROR! Trying to discover Docker IP"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
sudo sed -i "/$HOSTNAME/d" /etc/hosts
|
||||||
|
echo $DOCKERIP $HOSTNAME | sudo tee -a /etc/hosts
|
||||||
|
|
||||||
|
ssh-keygen -R "$HOSTNAME"
|
||||||
|
ssh-keygen -R "$DOCKERIP"
|
||||||
|
# ssh-keygen -R [hostname],[ip_address]
|
||||||
|
|
||||||
|
ssh-keyscan -H "$DOCKERIP" >> ~/.ssh/known_hosts
|
||||||
|
ssh-keyscan -H "$HOSTNAME" >> ~/.ssh/known_hosts
|
||||||
|
# ssh-keyscan -H [hostname],[ip_address] >> ~/.ssh/known_hosts
|
||||||
|
|
||||||
|
if [ ! -z $(tail -1 ~/.ssh/config) ] ; then
|
||||||
|
echo "" >> ~/.ssh/config
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! grep -q "\Host ${NAME}$" ~/.ssh/config ; then
|
||||||
|
echo "Adding alias $NAME to ~/.ssh/config"
|
||||||
|
echo "Host $NAME
|
||||||
|
HostName $HOSTNAME
|
||||||
|
User bigbluebutton
|
||||||
|
Port 22
|
||||||
|
" >> ~/.ssh/config
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! grep -q "\Host ${NAME}-with-ports$" ~/.ssh/config ; then
|
||||||
|
echo "Adding alias $NAME-with-ports to ~/.ssh/config"
|
||||||
|
echo "Host $NAME-with-ports
|
||||||
|
HostName $HOSTNAME
|
||||||
|
User bigbluebutton
|
||||||
|
Port 22
|
||||||
|
LocalForward 6379 localhost:6379
|
||||||
|
LocalForward 4101 localhost:4101
|
||||||
|
" >> ~/.ssh/config
|
||||||
|
fi
|
||||||
|
|
||||||
|
#Set Zsh as default and copy local bindkeys
|
||||||
|
if [ -d ~/.oh-my-zsh ]; then
|
||||||
|
echo "Found oh-my-zsh installed. Setting as default in Docker as well."
|
||||||
|
docker exec -u bigbluebutton $NAME bash -c "sudo chsh -s /bin/zsh bigbluebutton"
|
||||||
|
grep "^bindkey" ~/.zshrc | xargs -I{} docker exec -u bigbluebutton $NAME bash -c "echo {} >> /home/bigbluebutton/.zshrc"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
echo "------------------"
|
||||||
|
echo "Docker infos"
|
||||||
|
echo "IP $DOCKERIP"
|
||||||
|
echo "Default user: bigbluebutton"
|
||||||
|
echo "Default passwork: bigbluebutton"
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
docker exec -u bigbluebutton $NAME bash -c "bbb-conf --salt"
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
echo "------------------"
|
||||||
|
tput setaf 2; echo "Container created successfully!"; tput sgr0
|
||||||
|
echo ""
|
||||||
|
tput setaf 3; echo "BBB URL: https://$HOSTNAME"; tput sgr0
|
||||||
|
tput setaf 3; echo "Access Docker using: ssh $NAME"; tput sgr0
|
||||||
|
echo ""
|
||||||
|
echo "------------------"
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
tput setaf 4; echo "or to run Akka/Mongo locally use: ssh $NAME-with-ports"; tput sgr0
|
||||||
|
echo ""
|
||||||
|
echo ""
|
Loading…
Reference in New Issue
Block a user