#!/bin/bash
#
# IceWarp Server
# Copyright (c) 2008-2012 IceWarp Ltd. All rights reserved.
#
# http://www.icewarp.com
#
# file: platform-DEB5 - platform specific definitions for Debian 5
#

# Platform ID
PLATFORM_OSDIST=( "DEB" )
PLATFORM_DISTRO_IDS=( "UBUNTU" )
PLATFORM_VERSIONS=( "10.04" )
PLATFORM_HW_PLATFORMS=( "i386" "i686" "x86_64" )

PLATFORM_NAME="Ubuntu 10.04 (Lucid Lynx)"
PLATFORM_SERVICE_MANAGEMENT_TOOL_NAME="update-rc.d"

PLATFORM_RESULT=""

# Required dependencies
PLATFORM_DEPENDENCIES=( )
PLATFORM_PACKAGES=( )

# Returns true, if dependencies list is supported on this platform
platform_is_dependencies_supported()
{
    # Unsupported
    return 1
}

# Install given packages to system
# Param: List of packages, max. length 20
platform_install_packages()
{
    return 0
}

# Do some platform specific checks, returns false -> script ends
platform_do_specific_checks()
{
    return 0
}

# Get distribution ID, that will match one of the values in PLATFORM_DISTRO_IDS
# Value is returned in PLATFORM_RESULT
# Function result: true, when distro id was obtained
platform_get_distro_id()
{
    PLATFORM_RESULT=""
    if [ -f "/etc/debian_version" ]; then
        lsb_release &> /dev/null
	if [ $? -eq 0 ]; then
	    PLATFORM_RESULT=$(lsb_release -is | tr 'a-z' 'A-Z')
	    return 0
	fi
    fi
    
    return 1
}

# Get distribution major version
# Value is returned in PLATFORM_RESULT
# Function result: true, when distro version was obtained
platform_get_distro_major_version()
{
    PLATFORM_RESULT=""
    if [ -f "/etc/debian_version" ]; then
        lsb_release &> /dev/null
	if [ $? -eq 0 ]; then
	    PLATFORM_RESULT=$(lsb_release -rs)
            return 0
	fi
    fi
    
echo "distro version problem"
    return 1
}

# Get "bitness" of platform
platform_get_hw_platform()
{
    PLATFORM_RESULT=$(uname -m)
    return 0
}

# Check if service management tool is installed
platform_check_service_management_tool()
{
    update-rc.d &> /dev/null
    if [ $? -ne 1 ]; then
        return 1
    fi
    
    return 0
}

platform_is_install_service_management_tool_supported()
{
    return 1
}

# Install platform service management tool
platform_install_service_management_tool()
{
    return 0
}

# Functions dealing with unzip detection and installation
platform_is_install_unzip_supported()
{
    return 1
}

platform_install_unzip()
{
    return 0
}

# Functions dealing with java detection and installation
platform_is_install_java_supported()
{
    return 1
}

platform_install_java()
{
    return 0
}

# Add service to system
platform_add_service()
{
    update-rc.d "$1" defaults > /dev/null
}

# Remove service from system
platform_remove_service()
{
    update-rc.d -f "$1" remove > /dev/null
}
