33# Based on appcontainers/nagios
44# ###########################################################
55
6- FROM centos:latest
6+ FROM centos/systemd
77MAINTAINER "Gardar Thorsteinsson" <gardart@gmail.com>
88
99ENV ADAGIOS_HOST adagios.local
@@ -29,11 +29,11 @@ RUN yum --enablerepo=ok-testing install -y naemon naemon-livestatus git adagios
2929# Lets make sure adagios can write to naemon configuration files, and that
3030# it is a valid git repo so we have audit trail
3131WORKDIR /etc/naemon
32- # RUN git config user.name "admin"
33- # RUN git config user.email "admin@adagios.local "
34- # RUN git init /etc/naemon
35- # UN git add .
36- # RUN git commit -a -m "Initial commit"
32+ RUN git init /etc/naemon
33+ RUN git config user.name "admin"
34+ RUN git config user.email "admin@adagios.local"
35+ RUN git add .
36+ RUN git commit -a -m "Initial commit"
3737
3838# Fix permissions for naemon and pnp4nagios
3939RUN chown -R naemon:naemon /etc/naemon /etc/adagios /var/lib/adagios /var/lib/pnp4nagios /var/log/pnp4nagios /var/spool/pnp4nagios /etc/pnp4nagios/process_perfdata.cfg /var/log/okconfig
@@ -109,38 +109,29 @@ RUN pynag config --append cfg_dir=/etc/naemon/commands/
109109
110110RUN mv /etc/httpd/conf.d/thruk_cookie_auth_vhost.conf /etc/httpd/conf.d/thruk_cookie_auth_vhost.conf.disabled
111111
112+ RUN htpasswd -b /etc/thruk/htpasswd "$ADAGIOS_USER" "$ADAGIOS_PASS"
113+ RUN rm -f /etc/nagios/passwd
114+ RUN ln -s /etc/thruk/htpasswd /etc/nagios/passwd
115+
112116# Redirect root URL to /adagios
113117RUN echo "RedirectMatch ^/$ /adagios" > /etc/httpd/conf.d/redirect.conf
114118
115- # Install supervisor and supervisor-quick. Service restarts are painfully slow
116- # otherwise
117- RUN pip install supervisor
118- RUN pip install supervisor-quick
119-
120- # Remove cache and default passwd files
121- RUN rm -rf /var/cache/yum /etc/nagios/passwd /etc/thruk/htpasswd
122-
123- # Copy supervisor config over to the container
124- COPY supervisord.conf /etc/supervisord.conf
125-
126- # Copy custom supervisor init.d script (for nagios start|stop)
127- COPY naemon-supervisor-wrapper.sh /usr/bin/naemon-supervisor-wrapper.sh
128- RUN sed -i 's|^\( nagios_init_script\) =\( .*\) $|\1 ="sudo /usr/bin/naemon-supervisor-wrapper.sh"|g' /etc/adagios/adagios.conf
129- RUN echo "naemon ALL=NOPASSWD: /usr/bin/naemon-supervisor-wrapper.sh" >> /etc/sudoers
130-
131- # Create childlogdir
132- RUN mkdir /var/log/supervisor
119+ # Fix permissions for naemon and pnp4nagios
120+ RUN chown -R naemon:naemon /etc/naemon /etc/adagios /var/lib/adagios /var/lib/pnp4nagios /var/log/pnp4nagios /var/spool/pnp4nagios /etc/pnp4nagios/process_perfdata.cfg /var/log/okconfig
121+ # ACL group permissions need g+rwx
122+ RUN chmod g+rwx -R /etc/naemon /etc/adagios /var/lib/adagios /var/lib/pnp4nagios /var/log/pnp4nagios /var/spool/pnp4nagios /etc/pnp4nagios/process_perfdata.cfg /var/log/okconfig
123+ RUN setfacl -R -m group:naemon:rwx -m d:group:naemon:rwx /etc/naemon/ /etc/adagios /var/lib/adagios /var/lib/pnp4nagios /var/log/pnp4nagios /var/spool/pnp4nagios /etc/pnp4nagios/process_perfdata.cfg /var/log/okconfig
133124
134- # Copy over our custom init script
135- COPY run.sh /usr/bin/run.sh
125+ # Enable services
126+ RUN systemctl enable httpd
127+ RUN systemctl enable naemon
128+ RUN systemctl enable npcd
136129
137- # Make run.sh and supervisor wrapper script executable
138- RUN chmod 755 /usr/bin/run.sh /usr/bin/naemon-supervisor-wrapper.sh
130+ # Remove yum cache
131+ RUN rm -rf /var/cache/yum
139132
140133WORKDIR /etc/naemon
141134
142- ENTRYPOINT ["/bin/bash" , "/usr/bin/run.sh" ]
143-
144135EXPOSE 80
145136
146137VOLUME ["/etc/naemon" , "/var/log/naemon" ]
0 commit comments