Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | set -o xtrace |
| 4 | |
| 5 | # update_repos() - Function that updates linux repositories |
| 6 | function 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 Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 10 | 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 Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 24 | } |
| 25 | |
| 26 | # is_package_installed() - Function to tell if a package is installed |
| 27 | function 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 |
| 35 | function install_package { |
| 36 | local package=$1 |
| 37 | if ! is_package_installed $package; then |
| 38 | update_repos |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 39 | apt-get install -y -qq $package |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 40 | fi |
| 41 | } |