
#
# Copyright (C) 2019 OX Software GmbH
# 
# This file is part of OX Automation.
#
# OX Automation is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OX Automation is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# 
# See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OX Automation. If not, see <http://www.gnu.org/licenses/>.
#
#
# Authors:
# Benedikt Kroening <benedikt.kroening@open-xchange.com>
#
AS_BUILDKEY=http://software.open-xchange.com/oxbuildkey.pub

DEBIAN_STRETCH_REPOSITORY="http://httpredir.debian.org/debian stretch main"
DEBIAN_JESSIE_REPOSITORY="http://httpredir.debian.org/debian jessie main"
DEBIAN_JESSIE_BACKPORTS_REPOSITORY="http://httpredir.debian.org/debian jessie-backports main"

# Installs the provided packages with the available package manager
function installPackages {
    if [ -z $DIST ]; then
        detectDistribution
    fi
    
    PACKAGES="$@"
    echo "Installing the following list of packages:"
    echo "${PACKAGES}"
    echo ""
    sleep 5
    
    if [[ true == "${ANY_DEB}" ]]; then
        apt-get -qq update
        apt-get -y install ${PACKAGES}
    elif [[ true == "${ANY_SLES}" ]]; then
        zypper clean
        zypper ref
        zypper -n install ${PACKAGES}
    elif [[ true == "${ANY_RHEL}" ]]; then
        yum clean all
        #subscription-manager refresh
        yum -y install ${PACKAGES}
    elif [[ true == "${ANY_CENTOS}" ]]; then
        yum clean all
        #yum update
        yum -y install ${PACKAGES}
    fi
}
function installPackagesRetry {
    # Sometimes package install will fail because of updated packages on the buildservice
    # Simply retrying the installation most probably will fix everything
    echo "Retrying installation on failure ..."
    INSTALLCOUNT=0
    while [[ ${INSTALLCOUNT} -lt 6 ]]; do
            # Calling the actual installPackages function ...
            installPackages "$1"
            if [[ $? -ne 0 ]]; then
                INSTALLCOUNT=$((INSTALLCOUNT+1))
                echo "Error while installing packages, retrying in 30s ($INSTALLCOUNT/5)."
                sleep 30
            else
                break
            fi
    done
    if [[ ${INSTALLCOUNT} -ge 5 ]]; then
        echo "Error while installing packages, aborting."
        exit 1
    fi
}
# This function sets all repositories as long as their respective values are available as environmental variable
function setRepositories {
    if [[ "${AS_REPO_SOURCE}" == "OBS" ]]; then
        if [[ -n "${AS_BACKEND_VERSION}" ]]; then
            AS_REPO_BACKEND=http://buildservice.open-xchange.com/backend-${AS_BACKEND_VERSION}/${DISTRO}/
        fi
        if [[ -n "${AS_FRONTEND_VERSION}" ]]; then
            AS_REPO_FRONTEND=http://buildservice.open-xchange.com/frontend-${AS_FRONTEND_VERSION}/${DISTRO}/
        fi
        if [[ -n "${AS_FRONTEND_LEGACY_VERSION}" ]]; then
            AS_REPO_FRONTEND_LEGACY=http://buildservice.open-xchange.com/frontend6-${AS_FRONTEND_LEGACY_VERSION}/${DISTRO}/
        fi
        if [[ -n "${AS_OFFICE_VERSION}" ]]; then
            AS_REPO_OFFICE=http://buildservice.open-xchange.com/office-${AS_OFFICE_VERSION}/${DISTRO}/
        fi
        if [[ -n "${AS_OFFICE_FRONTEND_VERSION}" ]]; then
            AS_REPO_OFFICE_FRONTEND=http://buildservice.open-xchange.com/oxhh/office-web-${AS_OFFICE_FRONTEND_VERSION}/${DISTRO}/
        fi
        if [[ -n "${AS_OFFICE_COLLABORATION_VERSION}" ]]; then
            AS_REPO_OFFICE_COLLABORATION=http://buildservice.open-xchange.com/oxhh/documents-collaboration-${AS_OFFICE_COLLABORATION_VERSION}/${DISTRO}/
        fi
        if [[ -n "${AS_DOCUMENTCONVERTER_VERSION}" ]]; then
            AS_REPO_DOCUMENTCONVERTER=http://buildservice.open-xchange.com/documentconverter-${AS_DOCUMENTCONVERTER_VERSION}/${DISTRO}/
        fi
        if [[ -n "${AS_DOCUMENTCONVERTER_API_VERSION}" ]]; then
            AS_REPO_DOCUMENTCONVERTER_API=http://buildservice.open-xchange.com/documentconverter-api-${AS_DOCUMENTCONVERTER_API_VERSION}/${DISTRO}/
        fi
        if [[ -n "${AS_PDFTOOL_VERSION}" ]]; then
            AS_REPO_PDFTOOL=http://buildservice.open-xchange.com/oxhh/open-xchange-pdftool-${AS_PDFTOOL_VERSION}/${DISTRO}/
        fi
        if [[ -n "${AS_READERENGINE_VERSION}" ]]; then
            AS_REPO_READERENGINE=http://buildservice.open-xchange.com/oxhh/readerengine-${AS_READERENGINE_VERSION}/${DISTRO}/
        fi
        if [[ -n "${AS_USM_VERSION}" ]]; then
            AS_REPO_USM=http://buildservice.open-xchange.com/usm-${AS_USM_VERSION}/${DISTRO}/
        fi
        if [[ -n "${AS_EAS_VERSION}" ]]; then
            AS_REPO_EAS=http://buildservice.open-xchange.com/eas-${AS_EAS_VERSION}/${DISTRO}/
        fi
        if [[ -n "${AS_DRIVE_CLIENT_GENERIC_VERSION}" ]]; then
            AS_REPO_DRIVE_CLIENT_GENERIC=http://buildservice.open-xchange.com/drive-client-generic-${AS_DRIVE_CLIENT_GENERIC_VERSION}/${DISTRO}/
        fi
        if [[ -n "${AS_DRIVE_HELP_VERSION}" ]]; then
            AS_REPO_DRIVE_HELP=http://buildservice.open-xchange.com/drive-help-${AS_DRIVE_HELP_VERSION}/${DISTRO}/
        fi
        if [[ -n "${AS_GUARD_VERSION}" ]]; then
            AS_REPO_GUARD=http://buildservice.open-xchange.com/guard-${AS_GUARD_VERSION}/${DISTRO}/
        fi
        if [[ -n "${AS_DRIVERESTRICTED_VERSION}" ]]; then
            AS_REPO_DRIVERESTRICTED=http://buildservice.open-xchange.com/driverestricted-${AS_DRIVERESTRICTED_VERSION}/${DISTRO}/
        fi
        if [[ -n "${AS_WEAKFORCE_VERSION}" ]]; then
            AS_REPO_WEAKFORCE=http://buildservice.open-xchange.com/backend-weakforced-${AS_WEAKFORCE_VERSION}/${DISTRO}/
        fi
        if [[ -n "${AS_EMIG_VERSION}" ]]; then
            AS_REPO_EMIG=http://buildservice.open-xchange.com/emig-${AS_EMIG_VERSION}/${DISTRO}/
        fi
        if [[ -n "${AS_MOBILE_API_FACADE_VERSION}" ]]; then
            AS_REPO_MOBILE_API_FACADE=http://buildservice.open-xchange.com/mobile-api-facade-${AS_MOBILE_API_FACADE_VERSION}/${DISTRO}/
        fi
        if [[ -n "${AS_CLOUDPLUGINS_VERSION}" ]]; then
            AS_REPO_CLOUDPLUGINS=http://buildservice.open-xchange.com/cloud-plugins-${AS_CLOUDPLUGINS_VERSION}/${DISTRO}/
        fi
        if [[ -n "${AS_IMAGECONVERTER_VERSION}" ]]; then
            AS_REPO_IMAGECONVERTER=http://buildservice.open-xchange.com/imageconverter-${AS_IMAGECONVERTER_VERSION}/${DISTRO}/
        fi
    elif [[ "${AS_REPO_SOURCE}" == "EXT" ]]; then
        if [[ -n "${AS_BACKEND_VERSION}" ]]; then
            AS_REPO_BACKEND=https://software.open-xchange.com/products/appsuite/${AS_BACKEND_VERSION}/backend/${DISTRO}/
            if [[ -n "${AS_USER}" ]]; then
                AS_REPO_BACKEND_UPDATES=https://${AS_USER}:${AS_PASS}@software.open-xchange.com/products/appsuite/${AS_BACKEND_VERSION}/backend/updates/${DISTRO}/
            fi
        fi
        if [[ -n "${AS_FRONTEND_VERSION}" ]]; then
            AS_REPO_FRONTEND=https://software.open-xchange.com/products/appsuite/${AS_FRONTEND_VERSION}/appsuiteui/${DISTRO}/
            if [[ -n "${AS_USER}" ]]; then
                AS_REPO_FRONTEND_UPDATES=https://${AS_USER}:${AS_PASS}@software.open-xchange.com/products/appsuite/${AS_FRONTEND_VERSION}/appsuiteui/updates/${DISTRO}/
            fi
        fi
        if [[ -n "${AS_FRONTEND_LEGACY_VERSION}" ]]; then
            AS_REPO_FRONTEND_LEGACY=https://software.open-xchange.com/OX6/6.22/${AS_FRONTEND_LEGACY_VERSION}/frontend/${DISTRO}/
            if [[ -n "${AS_USER}" ]]; then
                AS_REPO_FRONTEND_LEGACY_UPDATES=https://${AS_USER}:${AS_PASS}@software.open-xchange.com/OX6/6.22/${AS_FRONTEND_LEGACY_VERSION}/updates/frontend/${DISTRO}/
            fi
        fi
        if [[ -n "${AS_OFFICE_VERSION}" ]]; then
            AS_REPO_OFFICE=https://software.open-xchange.com/products/appsuite/${AS_OFFICE_VERSION}/office/${DISTRO}/
            if [[ -n "${AS_USER}" ]]; then
                AS_REPO_OFFICE_UPDATES=https://${AS_USER}:${AS_PASS}@software.open-xchange.com/products/appsuite/${AS_OFFICE_VERSION}/office/updates/${DISTRO}/
            fi
        fi
        if [[ -n "${AS_OFFICE_FRONTEND_VERSION}" ]]; then
            AS_REPO_OFFICE_FRONTEND=https://software.open-xchange.com/products/appsuite/${AS_OFFICE_FRONTEND_VERSION}/office-web/${DISTRO}/
            if [[ -n "${AS_USER}" ]]; then
                AS_REPO_OFFICE_FRONTEND_UPDATES=https://${AS_USER}:${AS_PASS}@software.open-xchange.com/products/appsuite/${AS_OFFICE_FRONTEND_VERSION}/office-web/updates/${DISTRO}/
            fi
        fi
        if [[ -n "${AS_OFFICE_COLLABORATION_VERSION}" ]]; then
            AS_REPO_OFFICE_COLLABORATION=https://software.open-xchange.com/products/appsuite/${AS_OFFICE_COLLABORATION_VERSION}/documents-collaboration/${DISTRO}/
            if [[ -n "${AS_USER}" ]]; then
                AS_REPO_OFFICE_COLLABORATION_UPDATES=https://${AS_USER}:${AS_PASS}@software.open-xchange.com/products/appsuite/${AS_OFFICE_COLLABORATION_VERSION}/documents-collaboration/updates/${DISTRO}/
            fi
        fi
        if [[ -n "${AS_DOCUMENTCONVERTER_VERSION}" ]] && [[ -n "${AS_USER}" ]]; then
            AS_REPO_DOCUMENTCONVERTER=https://${AS_USER}:${AS_PASS}@software.open-xchange.com/products/appsuite/${AS_DOCUMENTCONVERTER_VERSION}/documentconverter/${DISTRO}/
        fi
        if [[ -n "${AS_DOCUMENTCONVERTER_API_VERSION}" ]]; then
            AS_REPO_DOCUMENTCONVERTER_API=https://software.open-xchange.com/products/appsuite/${AS_DOCUMENTCONVERTER_API_VERSION}/documentconverter-api/${DISTRO}/
            if [[ -n "${AS_USER}" ]]; then
                AS_REPO_DOCUMENTCONVERTER_API_UPDATES=https://${AS_USER}:${AS_PASS}@software.open-xchange.com/products/appsuite/${AS_DOCUMENTCONVERTER_API_VERSION}/documentconverter-api/updates/${DISTRO}/
            fi
        fi
        if [[ -n "${AS_READERENGINE_VERSION}" ]] && [[ -n "${AS_USER}" ]]; then
            AS_REPO_READERENGINE=https://${AS_USER}:${AS_PASS}@software.open-xchange.com/products/appsuite/${AS_READERENGINE_VERSION}/readerengine/${DISTRO}/
        fi
        if [[ -n "${AS_PDFTOOL_VERSION}" ]] && [[ -n "${AS_USER}" ]]; then
            AS_REPO_PDFTOOL=https://${AS_USER}:${AS_PASS}@software.open-xchange.com/products/appsuite/${AS_PDFTOOL_VERSION}/pdftool/${DISTRO}/
        fi
        if [[ -n "${AS_USM_VERSION}" ]]; then
            AS_REPO_USM=https://software.open-xchange.com/products/appsuite/${AS_USM_VERSION}/usm/${DISTRO}/
            if [[ -n "${AS_USER}" ]]; then
                AS_REPO_USM_UPDATES=https://${AS_USER}:${AS_PASS}@software.open-xchange.com/products/appsuite/${AS_USM_VERSION}/usm/updates/${DISTRO}/
            fi
        fi
        if [[ -n "${AS_EAS_VERSION}" ]] && [[ -n "${AS_USER}" ]]; then
            AS_REPO_EAS=https://${AS_USER}:${AS_PASS}@software.open-xchange.com/products/appsuite/${AS_EAS_VERSION}/mobilityconnector/${DISTRO}/
        fi
        if [[ -n "${AS_DRIVE_CLIENT_GENERIC_VERSION}" ]] && [[ -n "${AS_USER}" ]]; then
            AS_REPO_DRIVE_CLIENT_GENERIC=https://${AS_USER}:${AS_PASS}@software.open-xchange.com/products/drive/${AS_DRIVE_CLIENT_GENERIC_VERSION}/drive-client-windows/${DISTRO}/
        fi
        if [[ -n "${AS_DRIVE_HELP_VERSION}" ]]; then
            AS_REPO_DRIVE_HELP=https://${AS_USER}:${AS_PASS}@software.open-xchange.com/products/drive/${AS_DRIVE_HELP_VERSION}/drive-help/${DISTRO}/
            if [[ -n "${AS_USER}" ]]; then
                AS_REPO_DRIVE_HELP_UPDATES=https://${AS_USER}:${AS_PASS}@software.open-xchange.com/products/drive/${AS_DRIVE_HELP_VERSION}/drive-help/updates/${DISTRO}/
            fi
        fi
        if [[ -n "${AS_GUARD_VERSION}" ]]; then
            AS_REPO_GUARD=https://${AS_USER}:${AS_PASS}@software.open-xchange.com/products/guard/${AS_GUARD_VERSION}/guard/${DISTRO}/
            if [[ -n "${AS_USER}" ]]; then
                AS_REPO_GUARD_UPDATES=https://${AS_USER}:${AS_PASS}@software.open-xchange.com/products/guard/${AS_GUARD_VERSION}/guard/updates/${DISTRO}/
            fi
        fi
        if [[ -n "${AS_DRIVERESTRICTED_VERSION}" ]] && [[ -n "${AS_USER}" ]]; then
            AS_REPO_DRIVERESTRICTED=https://${AS_USER}:${AS_PASS}@software.open-xchange.com/products/appsuite/${AS_DRIVERESTRICTED_VERSION}/drive/${DISTRO}/
        fi
        if [[ -n "${AS_WEAKFORCE_VERSION}" ]]; then
            AS_REPO_WEAKFORCE=https://${AS_USER}:${AS_PASS}@software.open-xchange.com/products/weakforced/${AS_WEAKFORCE_VERSION}/backend-weakforced/${DISTRO}/
            if [[ -n "${AS_USER}" ]]; then
                AS_REPO_WEAKFORCE_UPDATES=https://${AS_USER}:${AS_PASS}@software.open-xchange.com/products/weakforced/${AS_WEAKFORCE_VERSION}/backend-weakforced/updates/${DISTRO}/
            fi
        fi

    fi
}


function writeRepositories {
    setRepositories
    echo "Adding repository information..."
    if [[ true == "${ANY_DEB}" ]]; then
        echo "# Debian and third-party Repositories" > /etc/apt/sources.list.d/ox-debian.list
        if [[ "${DIST}" == "DebianJessie" ]]; then
            echo "deb ${DEBIAN_JESSIE_REPOSITORY}" >> /etc/apt/sources.list.d/ox-debian.list
            echo "deb ${DEBIAN_JESSIE_BACKPORTS_REPOSITORY}" >> /etc/apt/sources.list.d/ox-debian.list
        fi
        # if [[ "${DIST}" == "DebianStretch" ]]; then
        #     echo "deb ${DEBIAN_STRETCH_REPOSITORY}" >> /etc/apt/sources.list.d/ox-debian.list
        # fi
        echo "# OX App Suite Repositories" > /etc/apt/sources.list.d/ox-appsuite.list
        if [[ -n "${AS_REPO_BACKEND}" ]]; then
            echo "deb ${AS_REPO_BACKEND} /" >> /etc/apt/sources.list.d/ox-appsuite.list
        fi
        if [[ -n "${AS_REPO_FRONTEND_LEGACY}" ]]; then
            echo "deb ${AS_REPO_FRONTEND_LEGACY} /" >> /etc/apt/sources.list.d/ox-appsuite.list
        fi
        if [[ -n "${AS_REPO_FRONTEND}" ]]; then
            echo "deb ${AS_REPO_FRONTEND} /" >> /etc/apt/sources.list.d/ox-appsuite.list
        fi
        if [[ -n "${AS_REPO_OFFICE}" ]]; then
            echo "deb ${AS_REPO_OFFICE} /" >> /etc/apt/sources.list.d/ox-appsuite.list
        fi
        if [[ -n "${AS_REPO_OFFICE_FRONTEND}" ]]; then
            echo "deb ${AS_REPO_OFFICE_FRONTEND} /" >> /etc/apt/sources.list.d/ox-appsuite.list
        fi
        if [[ -n "${AS_REPO_OFFICE_COLLABORATION}" ]]; then
            echo "deb ${AS_REPO_OFFICE_COLLABORATION} /" >> /etc/apt/sources.list.d/ox-appsuite.list
        fi
        if [[ -n "${AS_REPO_DOCUMENTCONVERTER}" ]]; then
            echo "deb ${AS_REPO_DOCUMENTCONVERTER} /" >> /etc/apt/sources.list.d/ox-appsuite.list
        fi
        if [[ -n "${AS_REPO_DOCUMENTCONVERTER_API}" ]]; then
            echo "deb ${AS_REPO_DOCUMENTCONVERTER_API} /" >> /etc/apt/sources.list.d/ox-appsuite.list
        fi
        if [[ -n "${AS_REPO_PDFTOOL}" ]]; then
            echo "deb ${AS_REPO_PDFTOOL} /" >> /etc/apt/sources.list.d/ox-appsuite.list
        fi
        if [[ -n "${AS_REPO_READERENGINE}" ]]; then
            echo "deb ${AS_REPO_READERENGINE} /" >> /etc/apt/sources.list.d/ox-appsuite.list
        fi
        if [[ -n "${AS_REPO_USM}" ]]; then
            echo "deb ${AS_REPO_USM} /" >> /etc/apt/sources.list.d/ox-appsuite.list
        fi
        if [[ -n "${AS_REPO_EAS}" ]]; then
            echo "deb ${AS_REPO_EAS} /" >> /etc/apt/sources.list.d/ox-appsuite.list
        fi
        if [[ -n "${AS_REPO_DRIVE_CLIENT_GENERIC}" ]]; then
            echo "deb ${AS_REPO_DRIVE_CLIENT_GENERIC} /" >> /etc/apt/sources.list.d/ox-appsuite.list
        fi
        if [[ -n "${AS_REPO_DRIVE_HELP}" ]]; then
            echo "deb ${AS_REPO_DRIVE_HELP} /" >> /etc/apt/sources.list.d/ox-appsuite.list
        fi
        if [[ -n "${AS_REPO_GUARD}" ]]; then
            echo "deb ${AS_REPO_GUARD} /" >> /etc/apt/sources.list.d/ox-appsuite.list
        fi
        if [[ -n "${AS_REPO_DRIVERESTRICTED}" ]]; then
            echo "deb ${AS_REPO_DRIVERESTRICTED} /" >> /etc/apt/sources.list.d/ox-appsuite.list
        fi
        if [[ -n "${AS_REPO_WEAKFORCE}" ]]; then
            echo "deb ${AS_REPO_WEAKFORCE} /" >> /etc/apt/sources.list.d/ox-appsuite.list
        fi
        if [[ -n "${AS_REPO_EMIG}" ]]; then
            echo "deb ${AS_REPO_EMIG} /" >> /etc/apt/sources.list.d/ox-appsuite.list
        fi
        if [[ -n "${AS_REPO_MOBILE_API_FACADE}" ]]; then
            echo "deb ${AS_REPO_MOBILE_API_FACADE} /" >> /etc/apt/sources.list.d/ox-appsuite.list
        fi
        if [[ -n "${AS_REPO_CLOUDPLUGINS}" ]]; then
            echo "deb ${AS_REPO_CLOUDPLUGINS} /" >> /etc/apt/sources.list.d/ox-appsuite.list
        fi
        if [[ -n "${AS_REPO_BACKEND_UPDATES}" ]]; then
            echo "deb ${AS_REPO_BACKEND_UPDATES} /" >> /etc/apt/sources.list.d/ox-appsuite.list
        fi
        if [[ -n "${AS_REPO_FRONTEND_UPDATES}" ]]; then
            echo "deb ${AS_REPO_FRONTEND_UPDATES} /" >> /etc/apt/sources.list.d/ox-appsuite.list
        fi
        if [[ -n "${AS_REPO_FRONTEND_LEGACY_UPDATES}" ]]; then
            echo "deb ${AS_REPO_FRONTEND_LEGACY_UPDATES} /" >> /etc/apt/sources.list.d/ox-appsuite.list
        fi
        if [[ -n "${AS_REPO_OFFICE_UPDATES}" ]]; then
            echo "deb ${AS_REPO_OFFICE_UPDATES} /" >> /etc/apt/sources.list.d/ox-appsuite.list
        fi
        if [[ -n "${AS_REPO_OFFICE_FRONTEND_UPDATES}" ]]; then
            echo "deb ${AS_REPO_OFFICE_FRONTEND_UPDATES} /" >> /etc/apt/sources.list.d/ox-appsuite.list
        fi
        if [[ -n "${AS_REPO_OFFICE_COLLABORATION_UPDATES}" ]]; then
            echo "deb ${AS_REPO_OFFICE_COLLABORATION_UPDATES} /" >> /etc/apt/sources.list.d/ox-appsuite.list
        fi
        if [[ -n "${AS_REPO_DOCUMENTCONVERTER_API_UPDATES}" ]]; then
            echo "deb ${AS_REPO_DOCUMENTCONVERTER_API_UPDATES} /" >> /etc/apt/sources.list.d/ox-appsuite.list
        fi
        if [[ -n "${AS_REPO_USM_UPDATES}" ]]; then
            echo "deb ${AS_REPO_USM_UPDATES} /" >> /etc/apt/sources.list.d/ox-appsuite.list
        fi
        if [[ -n "${AS_REPO_DRIVE_HELP_UPDATES}" ]]; then
            echo "deb ${AS_REPO_DRIVE_HELP_UPDATES} /" >> /etc/apt/sources.list.d/ox-appsuite.list
        fi
        if [[ -n "${AS_REPO_GUARD_UPDATES}" ]]; then
            echo "deb ${AS_REPO_GUARD_UPDATES} /" >> /etc/apt/sources.list.d/ox-appsuite.list
        fi
        if [[ -n "${AS_REPO_WEAKFORCE_UPDATES}" ]]; then
            echo "deb ${AS_REPO_WEAKFORCE_UPDATES} /" >> /etc/apt/sources.list.d/ox-appsuite.list
        fi
        if [[ -n "${AS_CUSTOM_REPO}" ]]; then
            echo "deb ${AS_CUSTOM_REPO} /" >> /etc/apt/sources.list.d/ox-appsuite.list
        fi
        if [[ -n "${AS_REPO_IMAGECONVERTER}" ]]; then
            echo "deb ${AS_REPO_IMAGECONVERTER} /" >> /etc/apt/sources.list.d/ox-appsuite.list
        fi
    elif [[ true == "${ANY_SLES}" ]]; then
        if [[ -n "${AS_REPO_BACKEND}" ]]; then
            zypper rr ox-appsuite-backend
            zypper ar "${AS_REPO_BACKEND}" ox-appsuite-backend
        fi
        if [[ -n "${AS_REPO_FRONTEND_LEGACY}" ]]; then
            zypper rr ox-appsuite-frontend-legacy
            zypper ar "${AS_REPO_FRONTEND_LEGACY}" ox-appsuite-frontend-legacy
        fi
        if [[ -n "${AS_REPO_FRONTEND}" ]]; then
            zypper rr ox-appsuite-frontend
            zypper ar "${AS_REPO_FRONTEND}" ox-appsuite-frontend
        fi
        if [[ -n "${AS_REPO_USM}" ]]; then
            zypper rr ox-appsuite-usm
            zypper ar "${AS_REPO_USM}" ox-appsuite-usm
        fi
        if [[ -n "${AS_REPO_OFFICE}" ]]; then
            zypper rr ox-appsuite-office
            zypper ar "${AS_REPO_OFFICE}" ox-appsuite-office
        fi
        if [[ -n "${AS_REPO_OFFICE_FRONTEND}" ]]; then
            zypper rr ox-appsuite-office-frontend
            zypper ar "${AS_REPO_OFFICE_FRONTEND}" ox-appsuite-office-frontend
        fi
        if [[ -n "${AS_REPO_OFFICE_COLLABORATION}" ]]; then
            zypper rr ox-appsuite-office-collaboration
            zypper ar "${AS_REPO_OFFICE_COLLABORATION}" ox-appsuite-office-collaboration
        fi
        if [[ -n "${AS_REPO_DOCUMENTCONVERTER}" ]]; then
            zypper rr ox-appsuite-documentconverter
            zypper ar "${AS_REPO_DOCUMENTCONVERTER}" ox-appsuite-documentconverter
        fi
        if [[ -n "${AS_REPO_DOCUMENTCONVERTER_API}" ]]; then
            zypper rr ox-appsuite-documentconverter-api
            zypper ar "${AS_REPO_DOCUMENTCONVERTER_API}" ox-appsuite-documentconverter-api
        fi
        if [[ -n "${AS_REPO_READERENGINE}" ]]; then
            zypper rr ox-appsuite-readerengine
            zypper ar "${AS_REPO_READERENGINE}" ox-appsuite-readerengine
        fi
        if [[ -n "${AS_REPO_PDFTOOL}" ]]; then
            zypper rr ox-appsuite-pdftool
            zypper ar "${AS_REPO_PDFTOOL}" ox-appsuite-pdftool
        fi
        if [[ -n "${AS_REPO_EAS}" ]]; then
            zypper rr ox-appsuite-eas
            zypper ar "${AS_REPO_EAS}" ox-appsuite-eas
        fi
        if [[ -n "${AS_REPO_DRIVE_CLIENT_GENERIC}" ]]; then
            zypper rr ox-appsuite-drive-client-generic
            zypper ar "${AS_REPO_DRIVE_CLIENT_GENERIC}" ox-appsuite-drive-client-generic
        fi
        if [[ -n "${AS_REPO_DRIVE_HELP}" ]]; then
            zypper rr ox-appsuite-drive-help
            zypper ar "${AS_REPO_DRIVE_HELP}" ox-appsuite-drive-help
        fi
        if [[ -n "${AS_REPO_GUARD}" ]]; then
            zypper rr ox-appsuite-guard
            zypper ar "${AS_REPO_GUARD}" ox-appsuite-guard
        fi
        if [[ -n "${AS_REPO_DRIVERESTRICTED}" ]]; then
            zypper rr ox-appsuite-driverestricted
            zypper ar "${AS_REPO_DRIVERESTRICTED}" ox-appsuite-driverestricted
        fi
        if [[ -n "${AS_REPO_WEAKFORCE}" ]]; then
            zypper rr ox-appsuite-weakforce
            zypper ar "${AS_REPO_WEAKFORCE}" ox-appsuite-weakforce
        fi
        if [[ -n "${AS_REPO_EMIG}" ]]; then
            zypper rr ox-appsuite-emig
            zypper ar "${AS_REPO_EMIG}" ox-appsuite-emig
        fi
        if [[ -n "${AS_REPO_MOBILE_API_FACADE}" ]]; then
            zypper rr ox-appsuite-mobile-api-facade
            zypper ar "${AS_REPO_MOBILE_API_FACADE}" ox-appsuite-mobile-api-facade
        fi
        if [[ -n "${AS_REPO_CLOUDPLUGINS}" ]]; then
            zypper rr ox-appsuite-cloudplugins
            zypper ar "${AS_REPO_CLOUDPLUGINS}" ox-appsuite-cloudplugins
        fi
        if [[ -n "${AS_REPO_BACKEND_UPDATES}" ]]; then
            zypper rr ox-appsuite-backend-updates
            zypper ar "${AS_REPO_BACKEND_UPDATES}" ox-appsuite-backend-updates
        fi
        if [[ -n "${AS_REPO_FRONTEND_UPDATES}" ]]; then
            zypper rr ox-appsuite-frontend-updates
            zypper ar "${AS_REPO_FRONTEND_UPDATES}" ox-appsuite-frontend-updates
        fi
        if [[ -n "${AS_REPO_FRONTEND_LEGACY_UPDATES}" ]]; then
            zypper rr ox-appsuite-frontend-legacy-updates
            zypper ar "${AS_REPO_FRONTEND_LEGACY_UPDATES}" ox-appsuite-frontend-legacy-updates
        fi
        if [[ -n "${AS_REPO_OFFICE_UPDATES}" ]]; then
            zypper rr ox-appsuite-office-updates
            zypper ar "${AS_REPO_OFFICE_UPDATES}" ox-appsuite-office-updates
        fi
        if [[ -n "${AS_REPO_OFFICE_FRONTEND_UPDATES}" ]]; then
            zypper rr ox-appsuite-office-frontend-updates
            zypper ar "${AS_REPO_OFFICE_FRONTEND_UPDATES}" ox-appsuite-office-frontend-updates
        fi
        if [[ -n "${AS_REPO_OFFICE_COLLABORATION_UPDATES}" ]]; then
            zypper rr ox-appsuite-office-collabortaion-updates
            zypper ar "${AS_REPO_OFFICE_COLLABORATION_UPDATES}" ox-appsuite-office-collaboration-updates
        fi
        if [[ -n "${AS_REPO_DOCUMENTCONVERTER_API_UPDATES}" ]]; then
            zypper rr ox-appsuite-documentconverter-api-updates
            zypper ar "${AS_REPO_DOCUMENTCONVERTER_API_UPDATES}" ox-appsuite-documentconverter-api-updates
        fi
        if [[ -n "${AS_REPO_USM_UPDATES}" ]]; then
            zypper rr ox-appsuite-usm-updates
            zypper ar "${AS_REPO_USM_UPDATES}" ox-appsuite-usm-updates
        fi
        if [[ -n "${AS_REPO_DRIVE_HELP_UPDATES}" ]]; then
            zypper rr ox-appsuite-drive-help-updates
            zypper ar "${AS_REPO_DRIVE_HELP_UPDATES}" ox-appsuite-drive-help-updates
        fi
        if [[ -n "${AS_REPO_GUARD_UPDATES}" ]]; then
            zypper rr ox-appsuite-guard-updates
            zypper ar "${AS_REPO_GUARD_UPDATES}" ox-appsuite-guard-updates
        fi
        if [[ -n "${AS_REPO_WEAKFORCE_UPDATES}" ]]; then
            zypper rr ox-appsuite-weakforce-updates
            zypper ar "${AS_REPO_WEAKFORCE_UPDATES}" ox-appsuite-weakforce-updates
        fi
        if [[ -n "${AS_CUSTOM_REPO}" ]]; then
            zypper rr ox-appsuite-custom-update
            zypper ar "${AS_CUSTOM_REPO}" ox-appsuite-custom-update
        fi
        if [[ -n "${AS_REPO_IMAGECONVERTER}" ]]; then
            zypper rr ox-appsuite-imageconverter
            zypper ar "${AS_REPO_IMAGECONVERTER}" ox-appsuite-imageconverter
        fi
    elif [[ true == "${ANY_RHEL}" ]] || [[ true == "${ANY_CENTOS}" ]]; then

        echo "# OX App Suite Repositories" > /etc/yum.repos.d/ox-appsuite.repo
        if [[ -n "${AS_REPO_BACKEND}" ]]; then
            {
            echo "[ox-appsuite-backend]"
            echo "name=OX App Suite Middleware"
            echo "baseurl=${AS_REPO_BACKEND}"
            echo "enabled=1"
            echo "proxy=_none_"
            } >> /etc/yum.repos.d/ox-appsuite.repo
        fi
        if [[ -n "${AS_REPO_FRONTEND_LEGACY}" ]]; then
            {
            echo "[ox-frontend-legacy]"
            echo "name=OX App Suite Frontend Legacy"
            echo "baseurl=${AS_REPO_FRONTEND_LEGACY}"
            echo "enabled=1"
            echo "proxy=_none_"
            } >> /etc/yum.repos.d/ox-appsuite.repo
        fi
        if [[ -n "${AS_REPO_FRONTEND}" ]]; then
            {
            echo "[ox-appsuite-frontend]"
            echo "name=OX App Suite Frontend"
            echo "baseurl=${AS_REPO_FRONTEND}"
            echo "enabled=1"
            echo "proxy=_none_"
            } >> /etc/yum.repos.d/ox-appsuite.repo
        fi
        if [[ -n "${AS_REPO_OFFICE}" ]]; then
            {
            echo "[ox-appsuite-office]"
            echo "name=OX App Suite Office"
            echo "baseurl=${AS_REPO_OFFICE}"
            echo "enabled=1"
            echo "proxy=_none_"
            } >> /etc/yum.repos.d/ox-appsuite.repo
        fi
        if [[ -n "${AS_REPO_OFFICE_FRONTEND}" ]]; then
	    {
            echo "[ox-appsuite-office-frontend]"
            echo "name=OX App Suite Office Frontend"
            echo "baseurl=${AS_REPO_OFFICE_FRONTEND}"
            echo "enabled=1"
            echo "proxy=_none_"
            } >> /etc/yum.repos.d/ox-appsuite.repo
	fi
        if [[ -n "${AS_REPO_OFFICE_COLLABORATION}" ]]; then
	    {
            echo "[ox-appsuite-office-collabortaion]"
            echo "name=OX App Suite Office Collaboration"
            echo "baseurl=${AS_REPO_OFFICE_COLLABORATION}"
            echo "enabled=1"
            echo "proxy=_none_"
            } >> /etc/yum.repos.d/ox-appsuite.repo
	fi
        if [[ -n "${AS_REPO_DOCUMENTCONVERTER}" ]]; then
            {
            echo "[ox-appsuite-documentconverter]"
            echo "name=OX App Suite Documentconverter"
            echo "baseurl=${AS_REPO_DOCUMENTCONVERTER}"
            echo "enabled=1"
            echo "proxy=_none_"
            } >> /etc/yum.repos.d/ox-appsuite.repo
        fi
        if [[ -n "${AS_REPO_DOCUMENTCONVERTER_API}" ]]; then
            {
            echo "[ox-appsuite-documentconverter-api]"
            echo "name=OX App Suite Documentconverter API"
            echo "baseurl=${AS_REPO_DOCUMENTCONVERTER_API}"
            echo "enabled=1"
            echo "proxy=_none_"
            } >> /etc/yum.repos.d/ox-appsuite.repo
        fi
        if [[ -n "${AS_REPO_PDFTOOL}" ]]; then
            {
            echo "[ox-appsuite-pdftool]"
            echo "name=OX App Suite PDFTool"
            echo "baseurl=${AS_REPO_PDFTOOL}"
            echo "enabled=1"
            echo "proxy=_none_"
            } >> /etc/yum.repos.d/ox-appsuite.repo
        fi
        if [[ -n "${AS_REPO_READERENGINE}" ]]; then
            {
            echo "[ox-appsuite-readerengine]"
            echo "name=OX App Suite Reader Engine"
            echo "baseurl=${AS_REPO_READERENGINE}"
            echo "enabled=1"
            echo "proxy=_none_"
            } >> /etc/yum.repos.d/ox-appsuite.repo
        fi
        if [[ -n "${AS_REPO_USM}" ]]; then
            {
            echo "[ox-appsuite-usm]"
            echo "name=OX App Suite USM"
            echo "baseurl=${AS_REPO_USM}"
            echo "enabled=1"
            echo "proxy=_none_"
            } >> /etc/yum.repos.d/ox-appsuite.repo
        fi
        if [[ -n "${AS_REPO_EAS}" ]]; then
            {
            echo "[ox-appsuite-eas]"
            echo "name=OX App Suite EAS"
            echo "baseurl=${AS_REPO_EAS}"
            echo "enabled=1"
            echo "proxy=_none_"
            } >> /etc/yum.repos.d/ox-appsuite.repo
        fi
        if [[ -n "${AS_REPO_DRIVE_CLIENT_GENERIC}" ]]; then
            {
            echo "[ox-appsuite-drive-client-generic]"
            echo "name=OX App Suite Drive Client Generic"
            echo "baseurl=${AS_REPO_DRIVE_CLIENT_GENERIC}"
            echo "enabled=1"
            echo "proxy=_none_"
            } >> /etc/yum.repos.d/ox-appsuite.repo
        fi
        if [[ -n "${AS_REPO_DRIVE_HELP}" ]]; then
            {
            echo "[ox-appsuite-drive-help]"
            echo "name=OX App Suite Drive Help"
            echo "baseurl=${AS_REPO_DRIVE_HELP}"
            echo "enabled=1"
            echo "proxy=_none_"
            } >> /etc/yum.repos.d/ox-appsuite.repo
        fi
        if [[ -n "${AS_REPO_GUARD}" ]]; then
            {
            echo "[ox-appsuite-guard]"
            echo "name=OX App Suite Guard"
            echo "baseurl=${AS_REPO_GUARD}"
            echo "enabled=1"
            echo "proxy=_none_"
            } >> /etc/yum.repos.d/ox-appsuite.repo
        fi
        if [[ -n "${AS_REPO_DRIVERESTRICTED}" ]]; then
            {
            echo "[ox-appsuite-driverestricted]"
            echo "name=OX App Suite Driverestricted"
            echo "baseurl=${AS_REPO_DRIVERESTRICTED}"
            echo "enabled=1"
            echo "proxy=_none_"
            } >> /etc/yum.repos.d/ox-appsuite.repo
        fi
        if [[ -n "${AS_REPO_WEAKFORCE}" ]]; then
            {
            echo "[ox-appsuite-weakforce]"
            echo "name=OX App Suite Weakforce"
            echo "baseurl=${AS_REPO_WEAKFORCE}"
            echo "enabled=1"
            echo "proxy=_none_"
            } >> /etc/yum.repos.d/ox-appsuite.repo
        fi
        if [[ -n "${AS_REPO_EMIG}" ]]; then
            {
            echo "[ox-appsuite-emig]"
            echo "name=OX App Suite EMIG"
            echo "baseurl=${AS_REPO_EMIG}"
            echo "enabled=1"
            echo "proxy=_none_"
            } >> /etc/yum.repos.d/ox-appsuite.repo
        fi
        if [[ -n "${AS_REPO_MOBILE_API_FACADE}" ]]; then
            {
            echo "[ox-appsuite-mobile-api-facade]"
            echo "name=OX App Suite Mobile API Facade"
            echo "baseurl=${AS_REPO_MOBILE_API_FACADE}"
            echo "enabled=1"
            echo "proxy=_none_"
            } >> /etc/yum.repos.d/ox-appsuite.repo
        fi
        if [[ -n "${AS_REPO_CLOUDPLUGINS}" ]]; then
            {
            echo "[ox-appsuite-cloudplugins]"
            echo "name=OX App Suite Cloud Plugins"
            echo "baseurl=${AS_REPO_CLOUDPLUGINS}"
            echo "enabled=1"
            echo "proxy=_none_"
            } >> /etc/yum.repos.d/ox-appsuite.repo
        fi
        if [[ -n "${AS_REPO_BACKEND_UPDATES}" ]]; then
            {
            echo "[ox-appsuite-backend-updates]"
            echo "name=OX App Suite Backend Updates"
            echo "baseurl=${AS_REPO_BACKEND_UPDATES}"
            echo "enabled=1"
            echo "proxy=_none_"
            } >> /etc/yum.repos.d/ox-appsuite.repo
        fi
        if [[ -n "${AS_REPO_FRONTEND_UPDATES}" ]]; then
            {
            echo "[ox-appsuite-frontend-updates]"
            echo "name=OX App Suite Frontend Updates"
            echo "baseurl=${AS_REPO_FRONTEND_UPDATES}"
            echo "enabled=1"
            echo "proxy=_none_"
            } >> /etc/yum.repos.d/ox-appsuite.repo
        fi
        if [[ -n "${AS_REPO_FRONTEND_LEGACY_UPDATES}" ]]; then
            {
            echo "[ox-appsuite-frontend-legacy-updates]"
            echo "name=OX App Suite Frontend Legacy Updates"
            echo "baseurl=${AS_REPO_FRONTEND_LEGACY_UPDATES}"
            echo "enabled=1"
            echo "proxy=_none_"
            } >> /etc/yum.repos.d/ox-appsuite.repo
        fi
        if [[ -n "${AS_REPO_OFFICE_UPDATES}" ]]; then
            {
            echo "[ox-appsuite-office-updates]"
            echo "name=OX App Suite Office Updates"
            echo "baseurl=${AS_REPO_OFFICE_UPDATES}"
            echo "enabled=1"
            echo "proxy=_none_"
            } >> /etc/yum.repos.d/ox-appsuite.repo
        fi
        if [[ -n "${AS_REPO_OFFICE_FRONTEND_UPDATES}" ]]; then
            {
            echo "[ox-appsuite-office-frontend-updates]"
            echo "name=OX App Suite Office Frontend Updates"
            echo "baseurl=${AS_REPO_OFFICE_FRONTEND_UPDATES}"
            echo "enabled=1"
            echo "proxy=_none_"
            } >> /etc/yum.repos.d/ox-appsuite.repo
        fi
        if [[ -n "${AS_REPO_OFFICE_COLLABORATION_UPDATES}" ]]; then
            {
            echo "[ox-appsuite-office-collaboration-updates]"
            echo "name=OX App Suite Office Collaboration Updates"
            echo "baseurl=${AS_REPO_OFFICE_COLLABORATION_UPDATES}"
            echo "enabled=1"
            echo "proxy=_none_"
            } >> /etc/yum.repos.d/ox-appsuite.repo
        fi
        if [[ -n "${AS_REPO_DOCUMENTCONVERTER_API_UPDATES}" ]]; then
            {
            echo "[ox-appsuite-documentconverter-api-updates]"
            echo "name=OX App Suite Documentconverter-api-updates"
            echo "baseurl=${AS_REPO_DOCUMENTCONVERTER_API_UPDATES}"
            echo "enabled=1"
            echo "proxy=_none_"
            } >> /etc/yum.repos.d/ox-appsuite.repo
        fi
        if [[ -n "${AS_REPO_USM_UPDATES}" ]]; then
            {
            echo "[ox-appsuite-usm-updates]"
            echo "name=OX App Suite USM Updates"
            echo "baseurl=${AS_REPO_USM_UPDATES}"
            echo "enabled=1"
            echo "proxy=_none_"
            } >> /etc/yum.repos.d/ox-appsuite.repo
        fi
        if [[ -n "${AS_REPO_DRIVE_HELP_UPDATES}" ]]; then
            {
            echo "[ox-appsuite-drive-help-updates]"
            echo "name=OX App Suite Drive Help Updates"
            echo "baseurl=${AS_REPO_DRIVE_HELP_UPDATES}"
            echo "enabled=1"
            echo "proxy=_none_"
            } >> /etc/yum.repos.d/ox-appsuite.repo
        fi
        if [[ -n "${AS_REPO_GUARD_UPDATES}" ]]; then
            {
            echo "[ox-appsuite-guard-updates]"
            echo "name=OX App Suite Guard Updates"
            echo "baseurl=${AS_REPO_GUARD_UPDATES}"
            echo "enabled=1"
            echo "proxy=_none_"
            } >> /etc/yum.repos.d/ox-appsuite.repo
        fi
        if [[ -n "${AS_REPO_WEAKFORCE_UPDATES}" ]]; then
            {
            echo "[ox-appsuite-weakforce-updates]"
            echo "name=OX App Suite Weakforce Updates"
            echo "baseurl=${AS_REPO_WEAKFORCE_UPDATES}"
            echo "enabled=1"
            echo "proxy=_none_"
            } >> /etc/yum.repos.d/ox-appsuite.repo
        fi
        if [[ -n "${AS_CUSTOM_REPO}" ]]; then
            {
            echo "[ox-appsuite-custom]"
            echo "name=OX App Suite Custom"
            echo "baseurl=${AS_CUSTOM_REPO}"
            echo "enabled=1"
            echo "proxy=_none_"
            } >> /etc/yum.repos.d/ox-appsuite.repo
        fi
        if [[ -n "${AS_REPO_IMAGECONVERTER}" ]]; then
            {
            echo "[ox-appsuite-imageconverter-server]"
            echo "name=OX App Suite ImageConverter Server"
            echo "baseurl=${AS_REPO_IMAGECONVERTER}"
            echo "enabled=1"
            echo "proxy=_none_"
            } >> /etc/yum.repos.d/ox-appsuite.repo
        fi
    fi
}

function addOxBuildKey {
    echo -n "Adding OX App Suite repository build key..."
    if [[ true == "${ANY_DEB}" ]]; then
        wget -q ${AS_BUILDKEY} -O - | apt-key add -
    elif [[ true == "${ANY_SLES}" ]]; then
        wget -q ${AS_BUILDKEY} -O ox.key
        rpm --import ox.key
        rm -f ox.key
    elif [[ true == "${ANY_RHEL}" ]] || [[ true == "${ANY_CENTOS}" ]]; then
        rpm --import ${AS_BUILDKEY}
    fi
}

function preInstallActions {
    echo "Executing preInstallActions ..."
    ADDITIONAL_PACKAGES="gnupg2 curl wget"
    if [[ true == "${ANY_DEB}" ]]; then
        ADDITIONAL_PACKAGES="${ADDITIONAL_PACKAGES} apt-transport-https software-properties-common dirmngr netcat"
        # Making MySQL installation unattended (Debian)
        echo "mysql mysql-server/root_password string ${DATABASE_ROOT_PASS}" | debconf-set-selections
        echo "mysql mysql-server/root_password_again string ${DATABASE_ROOT_PASS}" | debconf-set-selections
    elif [[ true == "${ANY_RHEL}" ]] || [[ true == "${ANY_CENTOS}" ]]; then
        ADDITIONAL_PACKAGES="${ADDITIONAL_PACKAGES} nc"
        echo ""
    fi

    if [[ "${INSTALL_TYPE}" == *"docker"* ]]; then
        echo ""
        ADDITIONAL_PACKAGES="supervisor ${ADDITIONAL_PACKAGES}"
    fi

    installPackagesRetry "${ADDITIONAL_PACKAGES}"
    export EXECUTED_preInstallActions=true
}


function checkInstallDefaults {

    if [[ "${INSTALL_TYPE}" == "singlenode" ]]; then
        echo "Performing singlenode setup, checking defaults and setting them accordingly if missing ..."
        if [ -z ${INSTALL_FRONTEND} ]; then
            export INSTALL_FRONTEND=true
        fi

        if [ -z ${INSTALL_MIDDLEWARE} ]; then
            export INSTALL_MIDDLEWARE=true
        fi

        if [ -z ${INSTALL_GUARD} ]; then
            export INSTALL_GUARD=false
        fi

        if [ -z ${INSTALL_DOCUMENTS} ]; then
            export INSTALL_DOCUMENTS=false
        fi

        if [ -z ${INSTALL_DOCUMENTCONVERTER} ]; then
            export INSTALL_DOCUMENTCONVERTER=false
        fi

        if [ -z ${INSTALL_DATABASE} ]; then
            export INSTALL_DATABASE=true
        fi  

        return 0
    else

        echo "Performing common setup, checking setup-defaults ..."
        # this simply checks if the install options are set
        if [ -z ${INSTALL_FRONTEND} ]; then
            export INSTALL_FRONTEND=false
        fi

        if [ -z ${INSTALL_MIDDLEWARE} ]; then
            export INSTALL_MIDDLEWARE=false
        fi

        if [ -z ${INSTALL_GUARD} ]; then
            export INSTALL_GUARD=false
        fi

        if [ -z ${INSTALL_DOCUMENTS} ]; then
            export INSTALL_DOCUMENTS=false
        fi

        if [ -z ${INSTALL_DOCUMENTCONVERTER} ]; then
            export INSTALL_DOCUMENTCONVERTER=false
        fi

        if [ -z ${INSTALL_DATABASE} ]; then
            export INSTALL_DATABASE=false
        fi  
    fi
}