blob: 019eeb5c233a2f82752f38bc9f2f57c065454c66 [file] [log] [blame]
Victor Morales89ce3212017-06-16 18:32:48 -05001#!/bin/bash
2
3set -o xtrace
4
5# update_repos() - Function that updates linux repositories
6function update_repos {
7 if [ -f /var/onap/files/sources.list ]; then
8 cp /var/onap/files/sources.list /etc/apt/sources.list
9 fi
Victor Moralesdd074802017-07-26 16:06:35 -050010 if [ -f /var/onap/files/proxyrc ]; then
11 source /var/onap/files/proxyrc
12 cp /var/onap/files/proxyrc /etc/profile.d/proxy.sh
13
14 if [ -f /etc/apt/apt.conf ]; then
15 echo "Acquire::http::Proxy \"${http_proxy}\";" >> /etc/apt/apt.conf
16 echo "Acquire::https::Proxy \"${https_proxy}\";" >> /etc/apt/apt.conf
17 fi
18 if [ -d /etc/apt/apt.conf.d ] & [ ! -f /etc/apt/apt.conf.d/70proxy.conf ]; then
19 echo "Acquire::http::Proxy \"${http_proxy}\";" >> /etc/apt/apt.conf.d/70proxy.conf
20 echo "Acquire::https::Proxy \"${https_proxy}\";" >> /etc/apt/apt.conf.d/70proxy.conf
21 fi
22 fi
23 apt-get update -qq -y
Victor Morales89ce3212017-06-16 18:32:48 -050024}
25
26# is_package_installed() - Function to tell if a package is installed
27function is_package_installed {
28 if [[ -z "$@" ]]; then
29 return 1
30 fi
31 dpkg -s "$@" > /dev/null 2> /dev/null
32}
33
34# install_package() - Install specific package if doesn't exist
35function install_package {
36 local package=$1
37 if ! is_package_installed $package; then
38 update_repos
Victor Moralesdd074802017-07-26 16:06:35 -050039 apt-get install -y -qq $package
Victor Morales89ce3212017-06-16 18:32:48 -050040 fi
41}