feat: update .gitignore, modify example .env file, and add Selenium stack deployment scripts
All checks were successful
Build and Push Docker Image / build (push) Successful in 12m53s
All checks were successful
Build and Push Docker Image / build (push) Successful in 12m53s
This commit is contained in:
121
selenium-standalone-stack/start-nodes.sh
Normal file
121
selenium-standalone-stack/start-nodes.sh
Normal file
@@ -0,0 +1,121 @@
|
||||
#!/bin/bash
|
||||
|
||||
usage() {
|
||||
cat << EOF
|
||||
$(basename "$0") (c) Framasoft 2023, WTPF
|
||||
|
||||
USAGE
|
||||
$(basename "$0") [-h] [-n <int>]
|
||||
|
||||
OPTIONS
|
||||
-h print this help and exit
|
||||
-n <int> how many selenium nodes you want to launch. Default: 1
|
||||
-e <string> the environment file path to use. Default: .env
|
||||
EOF
|
||||
exit "$1"
|
||||
}
|
||||
|
||||
NUMBER=1
|
||||
ENV_FILE=".env"
|
||||
|
||||
while getopts "hn:i:" option; do
|
||||
case $option in
|
||||
h)
|
||||
usage 0
|
||||
;;
|
||||
n)
|
||||
NUMBER=$OPTARG
|
||||
;;
|
||||
e)
|
||||
ENV_FILE=$OPTARG
|
||||
;;
|
||||
*)
|
||||
usage 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
HOST=$(hostname)
|
||||
|
||||
DEBIAN_FRONTEND=noninteractive
|
||||
export DEBIAN_FRONTEND
|
||||
|
||||
echo "Installing packages"
|
||||
apt-get -qq -y update
|
||||
apt-get -qq -y dist-upgrade
|
||||
apt-get -qq -y install jq \
|
||||
tmux \
|
||||
vim \
|
||||
multitail \
|
||||
htop \
|
||||
liquidprompt \
|
||||
coreutils \
|
||||
apparmor-utils \
|
||||
docker.io \
|
||||
|
||||
echo "Activating liquidprompt"
|
||||
liquidprompt_activate
|
||||
. /usr/share/liquidprompt/liquidprompt
|
||||
|
||||
echo "Modifying kernel parameters"
|
||||
sysctl net.ipv6.conf.default.forwarding=1
|
||||
sysctl net.ipv6.conf.all.forwarding=1
|
||||
|
||||
echo "Configuring Docker for IPv6"
|
||||
IP_ADDR=$(ip --json a show eth0 | jq '.[] | .addr_info | .[] | select(.family | contains("inet6")) | select(.scope | contains("global")) | .local' -r)
|
||||
NETWORK=$(echo "$IP_ADDR" | sed -e 's@:[^:]\+$@8000::/65@')
|
||||
|
||||
cat << EOF > /etc/docker/daemon.json
|
||||
{
|
||||
"ipv6": true,
|
||||
"fixed-cidr-v6": "$NETWORK"
|
||||
}
|
||||
EOF
|
||||
systemctl restart docker
|
||||
|
||||
echo "Starting $NUMBER Selenium nodes"
|
||||
|
||||
for NB in $(seq 1 "$NUMBER"); do
|
||||
NODE_NAME="selenium-${HOST}-instance-${NB}"
|
||||
|
||||
|
||||
|
||||
echo "Starting Selenium node n°$NB"
|
||||
docker run --rm \
|
||||
--env-file $ENV_FILE \
|
||||
--name "$NODE_NAME" \
|
||||
--pull always \
|
||||
--shm-size="2g" \
|
||||
-d \
|
||||
kobimex/peertube-collector-monolith:latest > /dev/null 2>&1
|
||||
|
||||
# Wait until the container gets an IPv6 address.
|
||||
DOCKER_IP=""
|
||||
for i in {1..10}; do
|
||||
DOCKER_IP=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.GlobalIPv6Address}}{{end}}' "$NODE_NAME")
|
||||
if [ -n "$DOCKER_IP" ]; then
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
|
||||
if [ -z "$DOCKER_IP" ]; then
|
||||
echo "Error: Could not retrieve a valid IPv6 address for $NODE_NAME." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Adding Selenium node n°$NB to neighbour proxy"
|
||||
ip -6 neighbour add proxy "$DOCKER_IP" dev eth0
|
||||
docker stop "$NODE_NAME"
|
||||
sleep 1
|
||||
|
||||
docker run --rm \
|
||||
--env-file $ENV_FILE \
|
||||
--name "$NODE_NAME" \
|
||||
--pull always \
|
||||
--shm-size="2g" \
|
||||
-d \
|
||||
-p 790$NB:790$NB \
|
||||
-e "SE_NO_VNC_PORT=790$NB" \
|
||||
kobimex/peertube-collector-monolith:latest > /dev/null 2>&1
|
||||
done
|
Reference in New Issue
Block a user