aboutsummaryrefslogtreecommitdiff
path: root/bin/dependencies
blob: bfbd5e9f90ce9c6f5c148f8eb94b271ee2745c85 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
#
# Puppet bootstrap dependencies.
#

# Parameters
BASENAME="`basename $0`"
DEPLOY_DEPENDENCIES="rsync puppet hiera-eyaml r10k"
DEVELOP_DEPENDENCIES="git mr whois hiera-eyaml"

# Set sudo config
if [ "`whoami`" != 'root' ]; then
  SUDO="sudo"

  if ! sudo -n true; then
    echo "Please set passwordless sudo."
    exit 1
  fi
fi

# Install a package, thanks to the Hydra Suite.
function provision_package {
  if [ -z "$1" ]; then
    return
  fi

  dpkg -s $1 &> /dev/null

  if [ "$?" == "1" ]; then
    echo "Installing package $1..."
    DEBIAN_FRONTEND=noninteractive $SUDO apt-get install $1 -y
  fi
}

# Ensure basic packages are installed.
if [ "$BASENAME" == "dependencies" ]; then
  for package in $DEVELOP_DEPENDENCIES; do
    provision_package $package
  done
fi