upgrade openvidu added into script

pull/473/head
OscarSotoSanchez 2020-05-05 18:01:08 +02:00
parent 2f571467dd
commit 00ff6969b1
4 changed files with 222 additions and 43 deletions

View File

@ -1,9 +1,17 @@
version: '3.1' version: '3.1'
services: services:
# --------------------------------------------------------------
#
# Change this if your want use your own application. # Change this if your want use your own application.
# It's very important expose your application in port 5442 # It's very important expose your application in port 5442
# and use the http protocol. # and use the http protocol.
#
# Default Application
#
# Openvidu-Call Version: 2.12.0
#
# --------------------------------------------------------------
app: app:
image: openvidu/openvidu-call:2.12.0 image: openvidu/openvidu-call:2.12.0
restart: on-failure restart: on-failure

View File

@ -11,6 +11,8 @@
# #
# This file will be overridden when update OpenVidu Platform # This file will be overridden when update OpenVidu Platform
# #
# Openvidu Version: 2.13.0
#
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
version: '3.1' version: '3.1'

View File

@ -1,8 +1,182 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Global variables
OPENVIDU_FOLDER=openvidu OPENVIDU_FOLDER=openvidu
OPENVIDU_VERSION=master OPENVIDU_VERSION=master
fatal_error() {
printf "\n =======¡ERROR!======="
printf "\n %s" "$1"
printf "\n"
exit 0
}
new_ov_installation() {
printf '\n'
printf '\n ======================================='
printf '\n Install Openvidu CE %s' "${OPENVIDU_VERSION}"
printf '\n ======================================='
printf '\n'
# Create folder openvidu-docker-compose
printf '\n => Creating folder '%s'...' "${OPENVIDU_FOLDER}"
mkdir "${OPENVIDU_FOLDER}" || fatal_error "Error while creating the folder '${OPENVIDU_FOLDER}'"
# Download necessaries files
printf '\n => Downloading Openvidu CE files:'
curl --silent https://raw.githubusercontent.com/OpenVidu/openvidu/${OPENVIDU_VERSION}/openvidu-server/docker/openvidu-docker-compose/.env \
--output "${OPENVIDU_FOLDER}/.env" || fatal_error "Error when downloading the file '.env'"
printf '\n - .env'
curl --silent https://raw.githubusercontent.com/OpenVidu/openvidu/${OPENVIDU_VERSION}/openvidu-server/docker/openvidu-docker-compose/docker-compose.override.yml \
--output "${OPENVIDU_FOLDER}/docker-compose.override.yml" || fatal_error "Error when downloading the file 'docker-compose.override.yml'"
printf '\n - docker-compose.override.yml'
curl --silent https://raw.githubusercontent.com/OpenVidu/openvidu/${OPENVIDU_VERSION}/openvidu-server/docker/openvidu-docker-compose/docker-compose.yml \
--output "${OPENVIDU_FOLDER}/docker-compose.yml" || fatal_error "Error when downloading the file 'docker-compose.yml'"
printf '\n - docker-compose.yml'
curl --silent https://raw.githubusercontent.com/OpenVidu/openvidu/${OPENVIDU_VERSION}/openvidu-server/docker/openvidu-docker-compose/openvidu \
--output "${OPENVIDU_FOLDER}/openvidu" || fatal_error "Error when downloading the file 'openvidu'"
printf '\n - openvidu'
curl --silent https://raw.githubusercontent.com/OpenVidu/openvidu/${OPENVIDU_VERSION}/openvidu-server/docker/openvidu-docker-compose/readme.md \
--output "${OPENVIDU_FOLDER}/readme.md" || fatal_error "Error when downloading the file 'readme.md'"
printf '\n - readme.md'
# Add execution permissions
printf "\n => Adding permission to 'openvidu' program..."
chmod +x "${OPENVIDU_FOLDER}/openvidu" || fatal_error "Error while adding permission to 'openvidu' program"
# Create own certificated folder
printf "\n => Creating folder 'owncert'..."
mkdir "${OPENVIDU_FOLDER}/owncert" || fatal_error "Error while creating the folder 'owncert'"
# Ready to use
printf '\n'
printf '\n'
printf '\n ======================================='
printf '\n Openvidu Platform successfully installed.'
printf '\n ======================================='
printf '\n'
printf '\n 1. Go to openvidu folder:'
printf '\n $ cd openvidu'
printf '\n'
printf '\n 2. Configure DOMAIN_OR_PUBLIC_IP and OPENVIDU_SECRET in .env file:'
printf '\n $ nano .env'
printf '\n'
printf '\n 3. Start OpenVidu'
printf '\n $ ./openvidu start'
printf '\n'
printf '\n For more information, check readme.md'
printf '\n'
printf '\n'
exit 0
}
upgrade_ov() {
# Search local Openvidu installation
printf '\n'
printf '\n ============================================'
printf '\n Search Previous Installation of Openvidu'
printf '\n ============================================'
printf '\n'
SEARCH_IN_FOLDERS=(
"."
"/opt/openvidu"
)
for folder in "${SEARCH_IN_FOLDERS[@]}"; do
printf "\n => Searching in '%s' folder..." "${folder}"
if [ -f "${folder}/docker-compose.yml" ]; then
OPENVIDU_PREVIOUS_FOLDER="${folder}"
printf "\n => Found installation in folder '%s'" "${folder}"
break
fi
done
[ -z "${OPENVIDU_PREVIOUS_FOLDER}" ] && fatal_error "No previous Openvidu installation found"
# Uppgrade Openvidu
OPENVIDU_PREVIOUS_VERSION=$(grep 'Openvidu Version:' "${OPENVIDU_PREVIOUS_FOLDER}/docker-compose.yml" | awk '{ print $4 }')
[ -z "${OPENVIDU_PREVIOUS_VERSION}" ] && OPENVIDU_PREVIOUS_VERSION=2.13.0
# In this point using the variable 'OPENVIDU_PREVIOUS_VERSION' we can verify if the upgrade is
# posible or not. If it is not posible launch a warning and stop the upgrade.
printf '\n'
printf '\n ======================================='
printf '\n Upgrade Openvidu CE %s to %s' "${OPENVIDU_PREVIOUS_VERSION}" "${OPENVIDU_VERSION}"
printf '\n ======================================='
printf '\n'
ROLL_BACK_FOLDER="${OPENVIDU_PREVIOUS_FOLDER}/.old-${OPENVIDU_PREVIOUS_VERSION}"
printf "\n Creating roll back folder '%s'..." ".old-${OPENVIDU_PREVIOUS_VERSION}"
mkdir "${ROLL_BACK_FOLDER}" || fatal_error "Error while creating the folder '.old-${OPENVIDU_PREVIOUS_VERSION}'"
# Move old files to roll back folder
USE_OV_CALL=$(grep -E '^ image: openvidu/openvidu-call:2.12.0$' "${OPENVIDU_PREVIOUS_FOLDER}/docker-compose.override.yml" | tr -d '[:space:]')
printf '\n => Moving previous installation files:'
mv "${OPENVIDU_PREVIOUS_FOLDER}/docker-compose.yml" "${ROLL_BACK_FOLDER}"
printf '\n - docker-compose.yml'
mv "${OPENVIDU_PREVIOUS_FOLDER}/openvidu" "${ROLL_BACK_FOLDER}"
printf '\n - openvidu'
mv "${OPENVIDU_PREVIOUS_FOLDER}/readme.md" "${ROLL_BACK_FOLDER}"
printf '\n - readme.md'
if [ ! -z "${USE_OV_CALL}" ]; then
mv "${OPENVIDU_PREVIOUS_FOLDER}/docker-compose.override.yml" "${ROLL_BACK_FOLDER}"
printf '\n - docker-compose.override.yml'
fi
# Download necessaries files
printf '\n => Downloading new Openvidu CE files:'
curl --silent https://raw.githubusercontent.com/OpenVidu/openvidu/${OPENVIDU_VERSION}/openvidu-server/docker/openvidu-docker-compose/.env \
--output "${OPENVIDU_PREVIOUS_FOLDER}/.env-${OPENVIDU_VERSION}" || fatal_error "Error when downloading the file '.env'"
printf '\n - .env-%s' "${OPENVIDU_VERSION}"
if [ ! -z "${USE_OV_CALL}" ]; then
curl --silent https://raw.githubusercontent.com/OpenVidu/openvidu/${OPENVIDU_VERSION}/openvidu-server/docker/openvidu-docker-compose/docker-compose.override.yml \
--output "${OPENVIDU_PREVIOUS_FOLDER}/docker-compose.override.yml" || fatal_error "Error when downloading the file 'docker-compose.override.yml'"
printf "\n - docker-compose.override.yml"
else
curl --silent https://raw.githubusercontent.com/OpenVidu/openvidu/${OPENVIDU_VERSION}/openvidu-server/docker/openvidu-docker-compose/docker-compose.override.yml \
--output "${OPENVIDU_PREVIOUS_FOLDER}/docker-compose.override.yml-${OPENVIDU_VERSION}" || fatal_error "Error when downloading the file 'docker-compose.override.yml'"
printf '\n - docker-compose.override.yml-%s' "${OPENVIDU_VERSION}"
fi
curl --silent https://raw.githubusercontent.com/OpenVidu/openvidu/${OPENVIDU_VERSION}/openvidu-server/docker/openvidu-docker-compose/docker-compose.yml \
--output "${OPENVIDU_PREVIOUS_FOLDER}/docker-compose.yml" || fatal_error "Error when downloading the file 'docker-compose.yml'"
printf '\n - docker-compose.yml'
curl --silent https://raw.githubusercontent.com/OpenVidu/openvidu/${OPENVIDU_VERSION}/openvidu-server/docker/openvidu-docker-compose/openvidu \
--output "${OPENVIDU_PREVIOUS_FOLDER}/openvidu" || fatal_error "Error when downloading the file 'openvidu'"
printf '\n - openvidu'
curl --silent https://raw.githubusercontent.com/OpenVidu/openvidu/${OPENVIDU_VERSION}/openvidu-server/docker/openvidu-docker-compose/readme.md \
--output "${OPENVIDU_PREVIOUS_FOLDER}/readme.md" || fatal_error "Error when downloading the file 'readme.md'"
printf '\n - readme.md'
# Add execution permissions
printf "\n => Adding permission to 'openvidu' program..."
chmod +x "${OPENVIDU_PREVIOUS_FOLDER}/openvidu" || fatal_error "Error while adding permission to 'openvidu' program"
# Ready to use
printf '\n'
printf '\n'
printf '\n ======================================='
printf '\n Openvidu Platform successfully upgrade.'
printf '\n ======================================='
printf '\n'
printf '\n'
exit 0
}
# Check docker and docker-compose installation # Check docker and docker-compose installation
if ! command -v docker > /dev/null; then if ! command -v docker > /dev/null; then
echo "You don't have docker installed, please install it and re-run the command" echo "You don't have docker installed, please install it and re-run the command"
@ -20,41 +194,9 @@ else
fi fi
fi fi
# Create folder openvidu-docker-compose # Check type of installation
mkdir ${OPENVIDU_FOLDER} if [[ ! -z "$1" && "$1" == "upgrade" ]]; then
upgrade_ov
# Download necessaries files else
curl --silent https://raw.githubusercontent.com/OpenVidu/openvidu/${OPENVIDU_VERSION}/openvidu-server/docker/openvidu-docker-compose/.env \ new_ov_installation
--output ${OPENVIDU_FOLDER}/.env fi
curl --silent https://raw.githubusercontent.com/OpenVidu/openvidu/${OPENVIDU_VERSION}/openvidu-server/docker/openvidu-docker-compose/docker-compose.override.yml \
--output ${OPENVIDU_FOLDER}/docker-compose.override.yml
curl --silent https://raw.githubusercontent.com/OpenVidu/openvidu/${OPENVIDU_VERSION}/openvidu-server/docker/openvidu-docker-compose/docker-compose.yml \
--output ${OPENVIDU_FOLDER}/docker-compose.yml
curl --silent https://raw.githubusercontent.com/OpenVidu/openvidu/${OPENVIDU_VERSION}/openvidu-server/docker/openvidu-docker-compose/openvidu \
--output ${OPENVIDU_FOLDER}/openvidu
curl --silent https://raw.githubusercontent.com/OpenVidu/openvidu/${OPENVIDU_VERSION}/openvidu-server/docker/openvidu-docker-compose/readme.md \
--output ${OPENVIDU_FOLDER}/readme.md
# Add execution permissions
chmod +x ${OPENVIDU_FOLDER}/openvidu
# Create own certificated folder
mkdir ${OPENVIDU_FOLDER}/owncert
# Ready to use
printf "\n"
printf "\n Openvidu Platform successfully installed."
printf "\n"
printf '\n 1. Go to openvidu folder:'
printf '\n $ cd openvidu'
printf "\n"
printf '\n 2. Configure DOMAIN_OR_PUBLIC_IP and OPENVIDU_SECRET in .env file:'
printf "\n $ nano .env"
printf "\n"
printf '\n 3. Start OpenVidu'
printf '\n $ ./openvidu start'
printf '\n'
printf '\n For more information, check readme.md'
printf '\n'
printf '\n'
exit 0

View File

@ -1,13 +1,33 @@
#!/bin/bash #!/bin/bash
upgrade_ov() {
UPGRADE_SCRIPT_URL="https://s3-eu-west-1.amazonaws.com/aws.openvidu.io/install_openvidu_OVVERSION.sh"
HTTP_STATUS=$(curl -s -o /dev/null -I -w "%{http_code}" ${UPGRADE_SCRIPT_URL//OVVERSION/$1})
printf " => Upgrading Openvidu CE to %s Version" "$1"
if [ "$HTTP_STATUS" == "200" ]; then
printf "\n => Downloading new Version"
printf "\n"
curl ${UPGRADE_SCRIPT_URL//OVVERSION/$1} | bash -s upgrade
else
printf "\n =======¡ERROR!======="
printf "\n Openvidu CE Version %s not exist" "$1"
printf "\n"
exit 0
fi
}
usage() { usage() {
printf "Usage: \n\t openvidu [command]" printf "Usage: \n\t openvidu [command]"
printf "\n\nAvailable Commands:" printf "\n\nAvailable Commands:"
printf "\n\tstart\t\tStart all services" printf "\n\tstart\t\t\tStart all services"
printf "\n\tstop\t\tStop all services" printf "\n\tstop\t\t\tStop all services"
printf "\n\trestart\t\tRestart all stoped and running services" printf "\n\trestart\t\t\tRestart all stoped and running services"
printf "\n\tlogs\t\tShow openvidu-server logs" printf "\n\tlogs\t\t\tShow openvidu-server logs"
printf "\n\thelp\t\tShow help for openvidu command" printf "\n\tupgrade\t\t\tUpgrade to the lastest Openvidu version"
printf "\n\tupgrade [version]\tUpgrade to the specific Openvidu version"
printf "\n\thelp\t\t\tShow help for openvidu command"
printf "\n" printf "\n"
} }
@ -32,6 +52,13 @@ case $1 in
docker-compose logs -f openvidu-server docker-compose logs -f openvidu-server
;; ;;
upgrade)
if [ -z "$2" ]; then
upgrade_ov latest
else
upgrade_ov "$2"
fi
;;
*) *)
usage usage
;; ;;