#!/bin/bash

# update_repos() - Function that updates linux repositories
function update_repos {
    echo "Updating repositories list..."
    if [ -f /var/onap/files/sources.list ]; then
        cp /var/onap/files/sources.list /etc/apt/sources.list
    fi
    source /etc/os-release || source /usr/lib/os-release
    case ${ID,,} in
        *suse)
            zypper -n ref
        ;;
        ubuntu|debian)
            if [[ "$debug" == "False" ]]; then
                apt-get update > /dev/null
            else
                apt-get update
            fi
        ;;
        rhel|centos|fedora)
            yum updateinfo
        ;;
    esac
}

# is_package_installed() - Function to tell if a package is installed
function is_package_installed {
    if [[ -z "$@" ]]; then
        return 1
    fi
    source /etc/os-release || source /usr/lib/os-release
    case ${ID,,} in
        *suse)
        ;;
        ubuntu|debian)
            dpkg -s "$@" > /dev/null
        ;;
        rhel|centos|fedora)
        ;;
    esac
}

# install_packages() - Install a list of packages
function install_packages {
    local package=$@
    source /etc/os-release || source /usr/lib/os-release
    case ${ID,,} in
        *suse)
        ;;
        ubuntu|debian)
            apt-get install -y -qq $package
        ;;
        rhel|centos|fedora)
        ;;
    esac
}

# install_package() - Install specific package if doesn't exist
function install_package {
    local package=$1

    if ! is_package_installed $package; then
        echo "Installing $package..."

        source /etc/os-release || source /usr/lib/os-release
        case ${ID,,} in
            *suse)
                zypper install -y $package
            ;;
            ubuntu|debian)
                if [[ "$debug" == "False" ]]; then
                    apt-get install -y -qq -o=Dpkg::Use-Pty=0 $package
                else
                    apt-get install -y $package
                fi
            ;;
            rhel|centos|fedora)
                PKG_MANAGER=$(which dnf || which yum)
                ${PKG_MANAGER} -y install $package
            ;;
        esac
    fi
}

# uninstall_packages() - Uninstall a list of packages
function uninstall_packages {
    local packages=$@
    source /etc/os-release || source /usr/lib/os-release
    case ${ID,,} in
        *suse)
        ;;
        ubuntu|debian)
            apt-get purge -y -qq $packages
        ;;
        rhel|centos|fedora)
        ;;
    esac
}

# uninstall_package() - Uninstall specific package if exists
function uninstall_package {
    local package=$1
    if is_package_installed $package; then
        source /etc/os-release || source /usr/lib/os-release
        case ${ID,,} in
            *suse)
            ;;
            ubuntu|debian)
                apt-get purge -y -qq $package
            ;;
            rhel|centos|fedora)
            ;;
        esac
    fi
}
