forked from hashicorp/puppet-bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 2
/
express.sh
65 lines (61 loc) · 1.92 KB
/
express.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env bash
#
# Bootstrap express script to install/config/start puppet on multi POSIX platforms
# with one line
#
set -e
BOOTSTRAP_TAR_URL=${BOOTSTRAP_TAR_URL:-"https://github.com/MiamiOH/puppet-bootstrap/archive/master.tar.gz"}
PLATFORM=${PLATFORM:-$1}
# Attempt to Detect PLATFORM if not set
if [ -z "${PLATFORM}" ]; then
case "$(uname -s)" in
Darwin)
PLATFORM="mac_os_x"
echo "[Mac OS X Detected]"
;;
Linux)
# is lsb available to detect distribution info?
if hash lsb_release 2>/dev/null; then
lsb_id=$(lsb_release -is)
lsb_re=$(lsb_release -rs | cut -f1 -d'.')
case "${lsb_id}" in
RedHatEnterpriseServer|CentOS|OracleServer|EnterpriseEnterpriseServer)
PLATFORM="centos_${lsb_re}_x"
echo "[${lsb_id} ${lsb_re} Detected]"
;;
Debian)
PLATFORM="debian"
echo "[${lsb_id} ${lsb_re} Detected]"
;;
Ubuntu)
PLATFORM="ubuntu"
echo "[${lsb_id} ${lsb_re} Detected]"
;;
esac
elif [ -e /etc/system-release ]; then
etcsys_id=$(cat /etc/system-release | cut -f1 -d' ')
etcsys_re=$(cat /etc/system-release | grep -o [0-9] | head -n 1)
echo "[${etcsys_id} ${etcrh_re} Detected]"
case "${etcsys_id}" in
RedHatEnterpriseServer|CentOS|OracleServer|Oracle|EnterpriseEnterpriseServer)
PLATFORM="centos_${etcsys_re}_x"
;;
Amazon)
PLATFORM="centos_7_x"
;;
esac
echo "[Treated as ${PLATFORM}]"
fi
;;
esac
fi
bootstrap_tmp_path=$(mktemp -d -t puppet-bootstrap.XXXXXXXXXX)
if hash curl 2>/dev/null; then
\curl -sSL "${BOOTSTRAP_TAR_URL}" | tar xz -C "${bootstrap_tmp_path}"
elif hash wget 2>/dev/null; then
\wget -qO - "${BOOTSTRAP_TAR_URL}" | tar xz -C "${bootstrap_tmp_path}"
else
echo "Can't find curl or wget to download puppet-bootstrap" >&2
exit 1
fi
source "${bootstrap_tmp_path}/puppet-bootstrap-master/bootstrap.sh" "$@"