-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.sh
46 lines (35 loc) · 1.25 KB
/
bootstrap.sh
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
41
42
43
44
45
46
#!/usr/bin/env bash
# Bootstrap for ubuntu and debian.
# This program makes a safe-upgrade and installs puppet.
set -e
OS=$(lsb_release -c -s)
RELEASE_FILE="puppetlabs-release-pc1-${OS}.deb"
REPO_DEB_URL="https://apt.puppetlabs.com/${RELEASE_FILE}"
if [[ "$EUID" -ne "0" ]]; then
echo "This script must be run as root." >&2
exit 1
fi
if [[ $(/usr/bin/dpkg -l) != *puppetlabs* ]]; then
echo "Purge previous puppet versions... "
DEBIAN_FRONTEND=noninteractive aptitude purge puppet puppet-common -y >/dev/null
echo "Configuring Puppetlabs repository... "
wget -qO "/tmp/${RELEASE_FILE}" ${REPO_DEB_URL} >/dev/null
dpkg -i "/tmp/${RELEASE_FILE}" >/dev/null
rm -f "/tmp/${RELEASE_FILE}"
echo "Removing i386 architecture..."
if [[ "${OS}" == "trusty" ]]; then
dpkg --remove-architecture i386
elif [[ "${OS}" == "precise" ]]; then
rm -f /etc/dpkg/dpkg.cfg.d/multiarch
fi
echo "Removing deb-src sources..."
sed -i '/deb-src/d' /etc/apt/sources.list
echo "Updating system..."
aptitude update >/dev/null
echo "Upgrading system... "
DEBIAN_FRONTEND=noninteractive aptitude safe-upgrade -q -y >/dev/null
echo "Installing puppet... "
aptitude install puppet-agent -y >/dev/null
else
echo "Puppet is already installed."
fi