#!/bin/sh

onapp_version_major=$1

if [ "x${onapp_version_major}" = "x" ]; then
    exit 1;
fi

templates_dir='Linux'
if [ "x${2}" != "x" ]; then
    templates_dir=$2
fi

root_dir='/home/templates/template/public_html'

rm -f ${root_dir}/cdn_template.sql.new

for file in `cat ${root_dir}/cdn_template_${onapp_version_major}.list`; do 
    ${root_dir}/generate-onapp-templates-sql.sh -c -m SQL -v ${onapp_version_major} -d ${root_dir}/${templates_dir} -t $file -o ${root_dir}/cdn_template.sql.new; 
done;

exit 0 # Do not generate SQL update statement for the CDN template. Customer should upgrade the template manually from CP UI.
for file in `cat ${root_dir}/cdn_template_${onapp_version_major}.list`; do 
    ${root_dir}/generate-onapp-templates-sql.sh -c -m SQL -v ${onapp_version_major} -d ${root_dir}/${templates_dir} -t $file -o ${root_dir}/cdn_template.sql.new -u "cdn=1 and virtualization not like 'vcloud'"; 
done;

