Skip to content

Commit 69d4bf8

Browse files
committed
(bootstrap) create function to install packages
1 parent a607018 commit 69d4bf8

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

installer/bootstrap.bash

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,31 @@
11
#! /usr/bin/env bash
22

3+
function installed_or_install
4+
{
5+
# installed_or_install executable [package]
6+
# Provide package name if it differs from executable name
7+
if [ -z "$1" ]
8+
then
9+
echo "[bootstrap] Error! No package name provided to check for installation."
10+
exit 1
11+
fi
12+
local executable package
13+
executable="$1"
14+
package="$1"
15+
[ -n "$2" ] && package="$2"
16+
hash "${executable}" 2> /dev/null || sudo apt-get install --assume-yes -qq "${package}"
17+
}
18+
19+
# Make sure curl is installed
20+
installed_or_install curl
321
# Make sure git is installed
4-
hash git 2> /dev/null || sudo apt-get install --assume-yes -qq git
22+
installed_or_install git
523
# Make sure lsb-release is installed
6-
hash lsb_release 2> /dev/null || sudo apt-get install --assume-yes -qq lsb-release
24+
installed_or_install lsb_release lsb-release
25+
# Make sure python3 is installed
26+
installed_or_install python3
727
# Make sure python3-virtualenv is installed
8-
hash virtualenv 2> /dev/null || sudo apt-get install --assume-yes -qq python3-virtualenv
28+
installed_or_install virtualenv python3-virtualenv
929

1030
# Check if OS is Ubuntu
1131
DISTRIB_ID="$(lsb_release -si)"

0 commit comments

Comments
 (0)