From 01bc866efab4b5908cc9cc26c808caf27c2abba2 Mon Sep 17 00:00:00 2001 From: Jacob Hummer Date: Thu, 17 Aug 2023 14:31:21 -0500 Subject: [PATCH] Create lib.sh --- lib.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 lib.sh diff --git a/lib.sh b/lib.sh new file mode 100644 index 0000000..f1e3ac2 --- /dev/null +++ b/lib.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +# https://github.com/devcontainers/features/blob/9fd5daf06b40794a067c4cdbb8e258d99eeefc24/src/node/install.sh +apt_get_update() { + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + echo "Running apt-get update..." + apt-get update -y + fi +} + +# https://github.com/devcontainers/features/blob/9fd5daf06b40794a067c4cdbb8e258d99eeefc24/src/node/install.sh +# Checks if packages are installed and installs them if not +check_packages() { + if ! dpkg -s "$@" > /dev/null 2>&1; then + apt_get_update + apt-get -y install --no-install-recommends "$@" + fi +}