[provisioning] Only update APT cache when necessary

This commit is contained in:
Correl Roush 2018-02-28 01:25:27 -05:00
parent 79d0fc0447
commit c6c494d070

View file

@ -1,14 +1,13 @@
#!/bin/bash
set -e
if [ -z "$__apt_updated" ]; then
_run "Update APT cache" sudo apt-get update
__apt_updated=yes
fi
function _apt {
local pkg=$1
if ! dpkg -s $pkg >/dev/null 2>&1; then
if [ -z "$__apt_updated" ]; then
_run "Update APT cache" sudo apt-get update
__apt_updated=yes
fi
_run "[apt] Install $pkg" sudo apt-get install -y $1
else
echo "[apt] $pkg is already installed, skipping."