This repository has been archived by the owner on Jul 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·104 lines (93 loc) · 2.86 KB
/
install.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/bin/bash
distribution_id() {
RETVAL=""
if [ -z "${RETVAL}" -a -e "/etc/os-release" ]; then
. /etc/os-release
RETVAL="${ID}"
fi
if [ -z "${RETVAL}" -a -e "/etc/centos-release" ]; then
RETVAL="centos"
fi
if [ -z "${RETVAL}" -a -e "/etc/fedora-release" ]; then
RETVAL="fedora"
fi
if [ -z "${RETVAL}" -a -e "/etc/redhat-release" ]; then
RELEASE_OUT=$(head -n1 /etc/redhat-release)
case "${RELEASE_OUT}" in
Red\ Hat\ Enterprise\ Linux*)
RETVAL="rhel"
;;
CentOS*)
RETVAL="centos"
;;
Fedora*)
RETVAL="fedora"
;;
esac
fi
if [ -z "${RETVAL}" ]; then
RETVAL="unknown"
fi
echo ${RETVAL}
}
distribution_major_version() {
for RELEASE_FILE in /etc/system-release \
/etc/centos-release \
/etc/fedora-release \
/etc/redhat-release
do
if [ -e "${RELEASE_FILE}" ]; then
RELEASE_VERSION=$(head -n1 ${RELEASE_FILE})
break
fi
done
echo ${RELEASE_VERSION} | sed -e 's|\(.\+\) release \([0-9]\+\)\([0-9.]*\).*|\2|'
}
ansible_installed=`type -p ansible-playbook`
if [ x${ansible_installed}x != "xx" ]
then
echo "Ansible installed. Do not install."
else
echo "Ansible not installed. Installing ..."
DISTRO=$(distribution_id)
case $DISTRO in
debian)
apt-get update
apt-get -y install gnupg wget
echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu trusty main" >> /etc/apt/sources.list
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367
apt-get update
apt-get -y install ansible
;;
ubuntu)
apt-get update
apt-get -y install software-properties-common
apt-add-repository -y ppa:ansible/ansible
apt-get update
apt-get -y install wget ansible
;;
rhel)
yum install -y http://dl.fedoraproject.org/pub/epel/epel-release-latest-$(distribution_major_version).noarch.rpm
yum install -y wget ansible
;;
centos)
yum install -y epel-release wget
yum install -y ansible
;;
fedora)
yum install -y wget ansible python2-rpm yum
;;
*)
echo "Unsupported distribution: $DISTRO"
;;
esac
fi
if [ -f "ansible_install.yaml" ]
then
echo "ansible_install.yaml file present. Do not download."
else
echo "Downloading ansible_install.yaml file from github."
wget http://raw.githubusercontent.com/grycap/im/master/ansible_install.yaml
fi
echo "Call Ansible playbook to install the IM."
ansible-playbook ansible_install.yaml