blob: 2b01dc524961f88718750256b1f13f85a751ecf5 [file] [log] [blame]
#!/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
if [[ "$debug" == "False" ]]; then
apt-get update > /dev/null
else
apt-get update
fi
}
# is_package_installed() - Function to tell if a package is installed
function is_package_installed {
if [[ -z "$@" ]]; then
return 1
fi
dpkg -s "$@" > /dev/null 2> /dev/null
}
# install_packages() - Install a list of packages
function install_packages {
local package=$@
apt-get install -y -qq $package
}
# install_package() - Install specific package if doesn't exist
function install_package {
local package=$1
if ! is_package_installed $package; then
echo "Installing $package..."
if [[ "$debug" == "False" ]]; then
apt-get install -y -qq -o=Dpkg::Use-Pty=0 $package
else
apt-get install -y $package
fi
fi
}
# uninstall_packages() - Uninstall a list of packages
function uninstall_packages {
local packages=$@
apt-get purge -y -qq $packages
}
# uninstall_package() - Uninstall specific package if exists
function uninstall_package {
local package=$1
if is_package_installed $package; then
apt-get purge -y -qq $package
fi
}