#!/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=( "DEBIAN" )
PLATFORM_VERSIONS=( 5 )

PLATFORM_NAME="Debian 5.x (Lenny)"
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
}

# Install objdump tool
platform_install_objdump()
{
    apt-get install binutils
}

# 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
        PLATFORM_RESULT="DEBIAN"
        return 0
    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
        PLATFORM_RESULT=$(cat "/etc/debian_version" | sed 's/\..*//')
        return 0
    fi
    
    return 1
}

# 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
}

# 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
}
