Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Marketplace products to upgrade process #6328

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 28 additions & 7 deletions src/main/server/upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,23 @@
INSTALL_DIRECTORY=$(dirname "$0")
cd $INSTALL_DIRECTORY

# If not installed jq package, install it
if ! command -v jq &> /dev/null; then
sudo apt-get install -y jq
fi


REMOTE_VERSION=$(curl -s https://antmedia.io/download/latest-version.json | jq -r ".versionName")
LOCAL_VERSION=$(unzip -p $INSTALL_DIRECTORY/ant-media-server.jar | grep -a "Implementation-Version"|cut -d' ' -f2 | tr -d '\r')
GITHUB_LATEST_VERSION=$(curl -s -H "Accept: application/vnd.github+json" https://api.github.com/repos/ant-media/Ant-Media-Server/releases/latest | jq -r '.tag_name' | cut -d 'v' -f 2)

# If not installed jq package, install it
if [ ! command -v jq &> /dev/null ]; then
sudo apt-get install -y jq
fi
while getopts t: option
do
case "${option}" in
t) TOKEN=${OPTARG};;
esac
done


# Check if a variable DIR is provided (this is for the automation)
if [ -n "$DIR" ]; then
Expand All @@ -43,14 +51,27 @@ check_ams() {
#Download the latest version of the installation script
wget -O install_ant-media-server.sh https://raw.githubusercontent.com/ant-media/Scripts/master/install_ant-media-server.sh && sudo chmod 755 install_ant-media-server.sh
get_license_key=`cat $INSTALL_DIRECTORY/conf/red5.properties | grep "server.licence_key=*" | cut -d "=" -f 2`
check_token=$(curl -s https://api.antmedia.io/?token="$TOKEN" | tr -d "\"")

if [ ! -z "${TOKEN}" ]; then
if [ "$check_token" == "400" ] || [ "$check_token" == "401" ]; then
echo "Invalid token."
exit 1
else
echo "Downloading the latest version of Ant Media Server Enterprise Edition..."
curl --progress-bar -o ams_enterprise.zip "$check_token"
ANT_MEDIA_SERVER_ZIP_FILE="ams_enterprise.zip"
fi

#Check if it is Enterprise or Community
if [ -z "$get_license_key" ]; then
elif [ -z "$get_license_key" ]; then

#if there is no license key, it can be still enterprise edition in the marketplace

if find "$INSTALL_DIRECTORY/plugins/" -type f -name "ant-media-enterprise*" | grep -q .; then
# there is enterprise file in plugins directory, check that if it's marketplace edition
echo "It seems like an enterprise version. On the other hand, there is no license key. If this is a Cloud Marketplace build, upgrade your version through your Cloud Marketplace"
echo -e "It seems like an enterprise version. On the other hand, there is no license key. If this is a Cloud Marketplace build, upgrade your version through your Cloud Marketplace or you can send an e-mail to [email protected] and request a token for the upgrade.\n"
echo -e "Example Usage: ./upgrade -t 'XXXX-XXXX-XXXX'\n"
exit 1
elif [ "$GITHUB_LATEST_VERSION" == "$REMOTE_VERSION" ]; then
echo "Downloading the latest version of Ant Media Server Community Edition..."
Expand All @@ -63,7 +84,7 @@ check_ams() {
else

check_license=$(curl -s https://api.antmedia.io/?license="$get_license_key" | tr -d "\"")

if [ "$check_license" == "400" ] || [ "$check_license" == "401" ]; then
echo "Invalid license key. Please check your license key."
exit 1
Expand Down