-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall_librenms.sh
executable file
·191 lines (147 loc) · 7.02 KB
/
install_librenms.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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#!/bin/bash
. ~/.bashrc
DIR=$(dirname $(readlink -f $0))
echo "***"
echo "*** Installing prerequisites for LibreNMS installation script..."
echo "***"
sleep 5
# Import Puppetlabs GPG Key
rpm --import https://yum.puppetlabs.com/RPM-GPG-KEY-puppetlabs
# Install Puppet Repo
rpm -ivh https://yum.puppetlabs.com/puppetlabs-release-pc1-el-7.noarch.rpm
yum history sync
# Install puppet
yum install puppet-agent -y
# Install puppet mysql module
puppet module install puppetlabs-mysql
# Install puppet VCS module
puppet module install puppetlabs-vcsrepo
# Install puppet pear module
puppet module install rafaelfc-pear
echo "*******************************************************************************************"
echo "*******************************************************************************************"
echo "*******************************************************************************************"
echo "***"
echo "*** This script will install LibreNMS. Please answer the following questions..."
echo "***"
echo "*******************************************************************************************"
echo "*******************************************************************************************"
echo "*******************************************************************************************"
echo
while true
do
read -p "Do you want to install the database on this server? (yes/no):" install_db
echo
if [ "$install_db" == "yes" ] || [ "$install_db" == "no" ] ; then
break
fi
done
while true
do
read -p "Do you want to install the NMS on this server? (yes/no):" install_nms
echo
if [ "$install_nms" == "yes" ] || [ "$install_nms" == "no" ] ; then
break
fi
done
if [ "$install_db" == "yes" ] ; then
read -p "Enter the MySQL bind address (localhost if DB and NMS the on same server, 0.0.0.0 if NMS will be on a different server):" libre_db_bind_addr
export FACTER_LIBRE_DB_BIND_ADDR=$libre_db_bind_addr
while true
do
read -s -p "Enter the MySQL root password for this installation:" mysql_root_pass
echo
read -s -p "Enter the MySQL root password for this installation (again):" mysql_root_pass2
echo
[ "$mysql_root_pass" = "$mysql_root_pass2" ] && break
echo "Passwords don't match. Please try again."
done
export FACTER_MYSQL_ROOT_PASS=$mysql_root_pass
read -p "Enter the LibreNMS database name:" libre_db_name
export FACTER_LIBRE_DB_NAME=$libre_db_name
read -p "Enter the LibreNMS MySQL username:" libre_db_user
export FACTER_LIBRE_DB_USER=$libre_db_user
while true
do
read -s -p "Enter the LibreNMS MySQL password:" libre_db_pass
echo
read -s -p "Enter the LibreNMS MySQL password (again):" libre_db_pass2
echo
[ "$libre_db_pass" = "$libre_db_pass2" ] && break
echo "Passwords don't match. Please try again."
done
export FACTER_LIBRE_DB_PASS=$libre_db_pass
puppet apply $DIR/libre_db_only.pp
echo "*******************************************************************************************"
echo "*******************************************************************************************"
echo "*******************************************************************************************"
echo "***"
echo "*** MySQL database should now installed."
echo "***"
echo "*******************************************************************************************"
echo "*******************************************************************************************"
echo "*******************************************************************************************"
fi
if [ "$install_nms" == "yes" ] ; then
if [ "$install_db" == "yes" ] ; then
echo "database is being installed locally. Moving on..."
export FACTER_LIBRE_DB_HOST='localhost'
else
read -p "Enter the LibreNMS database hostname (enter 'localhost' if the DB and NMS will be on the same server:" libre_db_host
export FACTER_LIBRE_DB_HOST=$libre_db_host
read -p "Enter the LibreNMS database name:" libre_db_name
export FACTER_LIBRE_DB_NAME=$libre_db_name
read -p "Enter the LibreNMS MySQL username:" libre_db_user
export FACTER_LIBRE_DB_USER=$libre_db_user
while true
do
read -s -p "Enter the LibreNMS MySQL password:" libre_db_pass
echo
read -s -p "Enter the LibreNMS MySQL password (again):" libre_db_pass2
echo
[ "$libre_db_pass" = "$libre_db_pass2" ] && break
echo "Passwords don't match. Please try again."
done
export FACTER_LIBRE_DB_PASS=$libre_db_pass
fi
read -p "Enter the fully qualified domain name of the LibreNMS server (ie = libre.domain.com):" libre_http_fqdn
export FACTER_LIBRE_HTTP_FQDN=$libre_http_fqdn
while true
do
read -s -p "Enter your SNMP community string for your environment. If you have multiple strings, specify the most common one:" snmp_comm_string
echo
read -s -p "Enter your SNMP community string for your environment. If you have multiple strings, specify the most common one (again):" snmp_comm_string2
echo
[ "$snmp_comm_string" = "$snmp_comm_string2" ] && break
echo "Passwords don't match. Please try again."
done
export FACTER_SNMP_COMM_STRING=$snmp_comm_string
read -p "Enter the SNMP Sys Location:" libre_snmp_location
export FACTER_LIBRE_SNMP_LOCATION=$libre_snmp_location
read -p "Enter the SNMP Sys Contact:" libre_snmp_contact
export FACTER_LIBRE_SNMP_CONTACT=$libre_snmp_contact
read -p "Enter the LibreNMS Web administrator username:" libre_web_user
export FACTER_LIBRE_WEB_USER=$libre_web_user
while true
do
read -s -p "Enter the LibreNMS Web administrator's password:" libre_web_pass
echo
read -s -p "Enter the LibreNMS Web administrator's password (again):" libre_web_pass2
echo
[ "$libre_web_pass" = "$libre_web_pass2" ] && break
echo "Passwords don't match. Please try again."
done
export FACTER_LIBRE_WEB_PASS=$libre_web_pass
read -p "Enter the LibreNMS Web administrator's email address:" libre_web_email
export FACTER_LIBRE_WEB_EMAIL=$libre_web_email
puppet apply $DIR/libre_nms_only.pp
echo "*******************************************************************************************"
echo "*******************************************************************************************"
echo "*******************************************************************************************"
echo "***"
echo "*** LibreNMS should be installed. Please go to http://${libre_http_fqdn}"
echo "***"
echo "*******************************************************************************************"
echo "*******************************************************************************************"
echo "*******************************************************************************************"
fi