5
5
# 'apt-get update' can encounter transient failures when the archive servers
6
6
# are being updated. To handle this case, just call it a few times.
7
7
apt-get update || apt-get update || apt-get update
9
apt-get -y install pwgen
9
apt-get -y install pwgen --force-yes
11
11
PASSWD_FILE="/var/lib/juju/nagios.passwd"
12
12
if [[ -e $PASSWD_FILE ]] ; then
13
PASSWORD=$(cat $PASSWD_FILE)
13
PASSWORD=$(cat $PASSWD_FILE)
15
PASSWORD=$(pwgen 10 1)
16
echo $PASSWORD >$PASSWD_FILE
17
chmod 0400 $PASSWD_FILE
15
PASSWORD=$(pwgen 10 1)
16
echo $PASSWORD >$PASSWD_FILE
17
chmod 0400 $PASSWD_FILE
20
20
echo nagios3-cgi nagios3/adminpassword password $PASSWORD | debconf-set-selections
21
21
echo nagios3-cgi nagios3/adminpassword-repeat password $PASSWORD | debconf-set-selections
23
23
DEBIAN_FRONTEND=noninteractive apt-get -qy \
24
install nagios3 nagios-plugins python-cheetah python-jinja2 dnsutils debconf-utils nagios-nrpe-plugin
26
# Ideally these would be moved into the distro ASAP
24
install nagios3 nagios-plugins python-cheetah python-jinja2 dnsutils debconf-utils nagios-nrpe-plugin pynag
31
26
# enable external commands per README.Debian file
32
27
if ! grep '^check_external_commands=1$' /etc/nagios3/nagios.cfg ; then
33
28
echo check_external_commands=1 >> /etc/nagios3/nagios.cfg
31
if [ -f $CHARM_DIR/files/hostgroups_nagios2.cfg ]; then
32
# Write the new hostgroups_nagios2.cfg file to prevent servers being classified as Debian.
33
cp -v $CHARM_DIR/files/hostgroups_nagios2.cfg /etc/nagios3/conf.d/hostgroups_nagios2.cfg
34
# Remove the services configuration file to eliminiate the need for ssh and localhost groups.
35
rm -v /etc/nagios3/conf.d/services_nagios2.cfg
36
# Remove the ext file to eliminate the need for ssh and localhost groups.
37
rm -v /etc/nagios3/conf.d/extinfo_nagios2.cfg
40
if [ -f $CHARM_DIR/files/index.html ]; then
41
# Replace the default index.html file to redirect to nagios3/
42
cp -v $CHARM_DIR/files/index.html /var/www/html/index.html
35
45
# || :'s are for idempotency
36
46
service nagios3 stop || :
37
47
dpkg-statoverride --update --add nagios www-data 2710 /var/lib/nagios3/rw || :