blob: 2b01dc524961f88718750256b1f13f85a751ecf5 [file] [log] [blame]
Victor Morales89ce3212017-06-16 18:32:48 -05001#!/bin/bash
2
Victor Morales89ce3212017-06-16 18:32:48 -05003# update_repos() - Function that updates linux repositories
4function update_repos {
Victor Morales7abf1a82017-11-06 09:20:27 -08005 echo "Updating repositories list..."
Victor Morales89ce3212017-06-16 18:32:48 -05006 if [ -f /var/onap/files/sources.list ]; then
7 cp /var/onap/files/sources.list /etc/apt/sources.list
8 fi
Victor Morales7abf1a82017-11-06 09:20:27 -08009 if [[ "$debug" == "False" ]]; then
10 apt-get update > /dev/null
11 else
12 apt-get update
Victor Moralesdd074802017-07-26 16:06:35 -050013 fi
Victor Morales89ce3212017-06-16 18:32:48 -050014}
15
16# is_package_installed() - Function to tell if a package is installed
17function is_package_installed {
18 if [[ -z "$@" ]]; then
19 return 1
20 fi
21 dpkg -s "$@" > /dev/null 2> /dev/null
22}
23
Victor Morales7ae05a42017-08-22 14:39:00 -050024# install_packages() - Install a list of packages
25function install_packages {
26 local package=$@
Victor Morales7ae05a42017-08-22 14:39:00 -050027 apt-get install -y -qq $package
28}
29
Victor Morales89ce3212017-06-16 18:32:48 -050030# install_package() - Install specific package if doesn't exist
31function install_package {
32 local package=$1
Victor Morales7abf1a82017-11-06 09:20:27 -080033
Victor Morales89ce3212017-06-16 18:32:48 -050034 if ! is_package_installed $package; then
Victor Morales7abf1a82017-11-06 09:20:27 -080035 echo "Installing $package..."
36
37 if [[ "$debug" == "False" ]]; then
38 apt-get install -y -qq -o=Dpkg::Use-Pty=0 $package
39 else
40 apt-get install -y $package
41 fi
Victor Morales89ce3212017-06-16 18:32:48 -050042 fi
43}
Victor Morales7ae05a42017-08-22 14:39:00 -050044
45# uninstall_packages() - Uninstall a list of packages
46function uninstall_packages {
47 local packages=$@
48 apt-get purge -y -qq $packages
49}
50
51# uninstall_package() - Uninstall specific package if exists
52function uninstall_package {
53 local package=$1
54 if is_package_installed $package; then
55 apt-get purge -y -qq $package
56 fi
57}