#!/bin/sh
#  $Id: UpgradeFrom_463000.sh 144933 2017-02-08 09:50:25Z justin.carveley@oracle.com $
#  Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
#  This software code contains proprietary information 
#  and should be treated as confidential.
#
#  Component: Installation/upgrade
#  Author: Bill Weir

FROM_VERSION=463000 TO_VERSION=470000

. ./util

# handy shortcut vars
TTA="${instdir}/bin/tarantella"
VIN="${instdir}/var/info"
TSR="${instdir}/etc/templates/serverresources"
VSR="${instdir}/var/serverresources"
TSC="${TSR}/serverconfig"
VSC="${instdir}/var/serverconfig"
TSB="${TSC}/global/beans"
VSB="${VSC}/global/beans"
TC="tarantella.config"
T_C="--tarantella-config"

# Remove various properties files
rm -rf ${VIN}/rdplicpool 2>/dev/null
for f in \
    tfn/tta/jserver/rdplicpool.properties \
    tfn/ntauthsp.properties \
    tfn/extauthsp.properties ; do
    rm -f ${TSR}/${f} ${VSR}/${f} 2>/dev/null
done

# Remove rdplicensepoolpersisterservice
f="${VSC}/global/components.properties"
cp -p ${f} ${f}+
egrep -v "^${TC}.components.rdplicensepoolpersisterservice=" <${f}+ >${f}
rm -f ${f}+ 2>/dev/null

# Remove various obsolete beans
for f in \
    searchntauth.properties \
    searchextauth.properties \
    com.sco.tta.server.soapcommands.Tscal.properties \
    com.sco.tta.server.login.ntauth.NTAuthService.properties \
    com.sco.tta.server.login.ntauth.NTAuthUserModel.properties \
    com.sco.tta.server.login.ntauth.NTAuthLoginAuthority.properties \
    com.sco.tta.server.login.extauth.ExternalAuthService.properties \
    com.sco.tta.server.login.extauth.ExternalAuthUserModel.properties \
    com.sco.tta.server.login.extauth.ExternalLoginAuthority.properties \
    com.sco.tta.server.services.RDPLicensePoolPersisterService.properties ; do
    rm -f ${TSB}/${f} ${VSB}/${f} 2>/dev/null
done

remove_property "local/xpe.properties" "${TC}.xpeconfig.rgbdatabase"
remove_property "local/xpe.properties" "${TC}.xpeconfig.keymapdir"
remove_property "local/xpe.properties" "${TC}.xpeconfig.keymapfile"

remove_property "local/scottaxapplication.properties" "${TC}.scottaxapplication.scottaeurokeymapping"
remove_property "local/scottaxapplication.properties" "${TC}.scottaxapplication.scottakeymaplock"

remove_property "local/scottawindowsapplication.properties" "${TC}.scottaxapplication.scottaeurokeymapping"
remove_property "local/scottawindowsapplication.properties" "${TC}.scottaxapplication.scottakeymaplock"

append_property "local/scottawindowsapplication.properties" "${TC}.scottaapplication.scottascriptvars" "TTA_Input_Iso639=ttasessionclientinputiso639,TTA_Input_Iso3166=ttasessionclientinputiso3166,TTA_EnhancedNetworkSecurity=sgdenhancednetworksecurity,TTA_AudioIn=oraclesgdaudioinenabled"

# Get config into line with current schema
LANG=C LC_ALL=C export LANG LC_ALL
${TTA} config edit "${T_C}-audiopeconfig-compression" "auto"

${TTA} config edit "${T_C}-scottaapplication-scottatransport" "ssh"
${TTA} config edit "${T_C}-security-ciphers" "AES256-SHA"
${TTA} config edit "${T_C}-xpeconfig-fontpath" "%%INSTALLDIR%%/etc/data/share/fonts/X11/misc,%%INSTALLDIR%%/etc/data/share/fonts/X11/TTF,%%INSTALLDIR%%/etc/data/share/fonts/X11/Type1,%%INSTALLDIR%%/etc/data/share/fonts/X11/OTF,%%INSTALLDIR%%/etc/data/share/fonts/X11/100dpi,%%INSTALLDIR%%/etc/data/share/fonts/X11/75dpi,%%INSTALLDIR%%/etc/data/share/fonts/X11/cyrillic,%%INSTALLDIR%%/etc/data/share/fonts/X11/ibm"
[ -n "`${TTA} config list \"${T_C}-ad-thirdparty-enabled\" | grep ': *not found'`" ] && \
	${TTA} config edit "${T_C}-ad-thirdparty-enabled" "0"
[ -n "`${TTA} config list \"${T_C}-array-xrandr-enabled\" | grep ': *not found'`" ] && \
	${TTA} config edit "${T_C}-array-xrandr-enabled" "0"
[ -n "`${TTA} config list \"${T_C}-audioin-enabled\" | grep ': *not found'`" ] && \
	${TTA} config edit "${T_C}-audioin-enabled" "0"
[ -n "`${TTA} config list \"${T_C}-audioinpeconfig-compression\" | grep ': *not found'`" ] && \
	${TTA} config edit "${T_C}-audioinpeconfig-compression" "auto"
[ -n "`${TTA} config list \"${T_C}-audioinpeconfig-listen\" | grep ': *not found'`" ] && \
	${TTA} config edit "${T_C}-audioinpeconfig-listen" "1"
[ -n "`${TTA} config list \"${T_C}-ldap-group-name-filter\" | grep ': *not found'`" ] && \
	${TTA} config edit "${T_C}-ldap-group-name-filter" ""
[ -n "`${TTA} config list \"${T_C}-ldap-thirdparty-enabled\" | grep ': *not found'`" ] && \
	${TTA} config edit "${T_C}-ldap-thirdparty-enabled" "1"
[ -n "`${TTA} config list \"${T_C}-xpeconfig-keyboard-layout\" | grep ': *not found'`" ] && \
	${TTA} config edit "${T_C}-xpeconfig-keyboard-layout" "us"
[ -n "`${TTA} config list \"${T_C}-xpeconfig-keyboard-model\" | grep ': *not found'`" ] && \
	${TTA} config edit "${T_C}-xpeconfig-keyboard-model" "pc105"
[ -n "`${TTA} config list \"${T_C}-xpeconfig-keyboard-options\" | grep ': *not found'`" ] && \
	${TTA} config edit "${T_C}-xpeconfig-keyboard-options" ""
[ -n "`${TTA} config list \"${T_C}-xpeconfig-keyboard-variant\" | grep ': *not found'`" ] && \
	${TTA} config edit "${T_C}-xpeconfig-keyboard-variant" ""
[ -n "`${TTA} config list \"${T_C}-xpeconfig-xkb-basedir\" | grep ': *not found'`" ] && \
	${TTA} config edit "${T_C}-xpeconfig-xkb-basedir" "%%INSTALLDIR%%/etc/data/share/X11/xkb"
[ -n "`${TTA} config list \"${T_C}-xpeconfig-xkb-binarydir\" | grep ': *not found'`" ] && \
	${TTA} config edit "${T_C}-xpeconfig-xkb-binarydir" "%%INSTALLDIR%%/bin/bin"

exit 0
