~charm-demo/charms/trusty/nagios/trunk

« back to all changes in this revision

Viewing changes to hooks/install

  • Committer: Marco Ceppi
  • Date: 2014-10-14 16:30:46 UTC
  • mfrom: (16.1.1 nagios)
  • Revision ID: marco@ceppi.net-20141014163046-ugwmqsmpso05jctb
MergeĀ fromĀ upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/bin/bash
2
2
 
3
 
set -ue
 
3
set -uex
4
4
 
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
8
8
 
9
 
apt-get -y install pwgen
 
9
apt-get -y install pwgen --force-yes
10
10
 
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)
14
14
else
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
18
18
fi
19
19
 
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
22
22
 
23
23
DEBIAN_FRONTEND=noninteractive apt-get -qy \
24
 
        install nagios3 nagios-plugins python-cheetah python-jinja2 dnsutils debconf-utils nagios-nrpe-plugin
25
 
 
26
 
# Ideally these would be moved into the distro ASAP
27
 
if [ -d debs ] ; then
28
 
    dpkg -i debs/*.deb
29
 
fi
 
24
  install nagios3 nagios-plugins python-cheetah python-jinja2 dnsutils debconf-utils nagios-nrpe-plugin pynag
30
25
 
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
34
29
fi
 
30
 
 
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
 
38
fi
 
39
 
 
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
 
43
fi
 
44
 
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 || :