forked from martinrusev/devopsium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
120 lines (80 loc) · 2.98 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/bin/bash
# Edgium install script.
set -e
logfile="edgium-install.log"
# Set up a named pipe for logging
npipe=/tmp/$$.tmp
mknod $npipe p
# Log all output to a log for error checking
tee <$npipe $logfile &
exec 1>&-
exec 1>$npipe 2>&1
trap "rm -f $npipe" EXIT
function file_exists() {
[ -f "$1" ]
}
DISTRO=
if file_exists /etc/debian_version ; then
DISTRO='debian'
elif file_exists /etc/system-release; then
DISTRO='rpm'
fi
function on_error() {
printf "\033[31m
It looks like you hit an issue when trying to install Edgium.
Troubleshooting and basic usage information for Edgium are available at:
https://github.com/martinrusev/edgium
If you're still having problems, please send an email to martin@amon.cx
with the contents of edgium-install.log and we'll do our very best to help you
solve your problem.\n\033[0m\n"
}
trap on_error ERR
# Root user detection
if [ $(echo "$UID") = "0" ]; then
sudo_cmd=''
else
sudo_cmd='sudo'
fi
function install() {
# Install the necessary package sources
if [ $DISTRO == 'rpm' ]; then
echo -e "\033[34m\n* Installing YUM sources for Edgium\n\033[0m"
$sudo_cmd sh -c "echo -e '[amon]\nname = Amon.\nbaseurl = http://packages.amon.cx/rpm/\nenabled=1\ngpgcheck=0\npriority=1' > /etc/yum.repos.d/amon.repo"
printf "\033[34m* Installing the Edgium package\n\033[0m\n"
$sudo_cmd yum -y install edgium
elif [ $DISTRO == 'debian' ]; then
printf "\033[34m\n* Installing APT package sources for Edgium\n\033[0m\n"
$sudo_cmd sh -c "echo 'deb http://packages.amon.cx/repo amon contrib' > /etc/apt/sources.list.d/amonagent.list"
$sudo_cmd apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv AD53961F
printf "\033[34m\n* Installing the Edgium package\n\033[0m\n"
$sudo_cmd apt-get install -y --force-yes python-software-properties software-properties-common
$sudo_cmd apt-add-repository -y ppa:ansible/ansible
$sudo_cmd apt-get update
$sudo_cmd apt-get install -y --force-yes edgium
else
printf "\033[31mYour OS or distribution are not supported by this install script.
Please follow the instructions on the Edgium setup page:
https://github.com/martinrusev/edgium\033[0m\n"
exit;
fi
}
function install_ansible(){
printf "\033[34m\n* Installing Ansible ...\n\033[0m\n"
if [ $DISTRO == 'debian' ]; then
$sudo_cmd apt-get install -y ansible
elif [ $DISTRO == 'rpm' ]; then
$sudo_cmd sh -c "curl -L http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm | rpm -Uvh epel-release-6*.rpm"
$sudo_cmd yum -y install ansible
fi
}
# Show a message about where to go for help.
function print_troubleshooting_instructions() {
printf "\033[32m All done.
----------------------------------
To install a package with Edgium
edgium install package
\033[0m"
}
install
install_ansible
print_troubleshooting_instructions