#!/bin/bash
#
# A script for upgrading from OpenVZ to commercial Virtuozzo.
# Upgrade steps are like the following:
# 1. Install virtuozzo-release package
# 2. Install a group of packages specific to commercial Virtuozzo
# 3. Activate trial license
#

# Just for the case, check if we have openvz-release
if [ ! -f /etc/openvz-release ]; then
	echo "/etc/openvz-release file not found! Have you already updated your system from OpenVZ to Virtuozzo?"
	exit 1
fi

SERVER_REPO="http://repo.virtuozzo.com"
PKG_PATH="vz/releases/7.0/x86_64/os/Packages/v"

# Get the current version of virtuozzo-release package available on server
release_pkg=`curl ${SERVER_REPO}/${PKG_PATH}/ 2>/dev/null | grep virtuozzo-release | cut -f8 -d\"`
echo "Installing ${release_pkg} ..."
rpm -Uvh $SERVER_REPO/${PKG_PATH}/${release_pkg}

# Install Vz-specific packages
yum groupinstall vz-comm-upgrade

# Activate trial license
vzlicupdate --activate trial
