From 5d16be5659b85287074568ac4f0531612f378f94 Mon Sep 17 00:00:00 2001 From: Gardar Thorsteinsson Date: Fri, 27 Sep 2019 12:00:21 +0000 Subject: [PATCH] Removed init script --- Dockerfile | 38 +++++++++++++++++++------------------- run.sh | 51 --------------------------------------------------- 2 files changed, 19 insertions(+), 70 deletions(-) delete mode 100644 run.sh diff --git a/Dockerfile b/Dockerfile index 7ba5633..f836b03 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,11 +29,11 @@ RUN yum --enablerepo=ok-testing install -y naemon naemon-livestatus git adagios # Lets make sure adagios can write to naemon configuration files, and that # it is a valid git repo so we have audit trail WORKDIR /etc/naemon -#RUN git config user.name "admin" -#RUN git config user.email "admin@adagios.local" -#RUN git init /etc/naemon -#UN git add . -#RUN git commit -a -m "Initial commit" +RUN git init /etc/naemon +RUN git config user.name "admin" +RUN git config user.email "admin@adagios.local" +RUN git add . +RUN git commit -a -m "Initial commit" # Fix permissions for naemon and pnp4nagios 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 @@ -109,29 +109,29 @@ RUN pynag config --append cfg_dir=/etc/naemon/commands/ RUN mv /etc/httpd/conf.d/thruk_cookie_auth_vhost.conf /etc/httpd/conf.d/thruk_cookie_auth_vhost.conf.disabled +RUN htpasswd -b /etc/thruk/htpasswd "$ADAGIOS_USER" "$ADAGIOS_PASS" +RUN rm -f /etc/nagios/passwd +RUN ln -s /etc/thruk/htpasswd /etc/nagios/passwd + # Redirect root URL to /adagios RUN echo "RedirectMatch ^/$ /adagios" > /etc/httpd/conf.d/redirect.conf +# Fix permissions for naemon and pnp4nagios +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 +# ACL group permissions need g+rwx +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 +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 + +# Enable services RUN systemctl enable httpd RUN systemctl enable naemon -# Install supervisor and supervisor-quick. Service restarts are painfully slow -# otherwise -#RUN pip install supervisor -#RUN pip install supervisor-quick - -# Remove cache and default passwd files -RUN rm -rf /var/cache/yum /etc/nagios/passwd +RUN systemctl enable npcd -# Copy over our custom init script -#COPY run.sh /usr/bin/run.sh - -# Make run.sh script executable -#RUN chmod 755 /usr/bin/run.sh +# Remove yum cache +RUN rm -rf /var/cache/yum WORKDIR /etc/naemon -#ENTRYPOINT ["/bin/bash", "/usr/bin/run.sh"] - EXPOSE 80 VOLUME ["/etc/naemon", "/var/log/naemon"] diff --git a/run.sh b/run.sh deleted file mode 100644 index ac1fa18..0000000 --- a/run.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env bash - -set -e - -ADAGIOS_HOST=${ADAGIOS_HOST:-localhost} -ADAGIOS_USER=${ADAGIOS_USER:-thrukadmin} -ADAGIOS_PASS=${ADAGIOS_PASS:-P@ssw0rd} -GIT_REPO=${GIT_REPO:-True} - -# Set password if htpasswd file does not exist yet -if [[ ! -f /etc/thruk/htpasswd ]] -then - htpasswd -c -b /etc/thruk/htpasswd "$ADAGIOS_USER" "$ADAGIOS_PASS" - ln -s /etc/thruk/htpasswd /etc/nagios/passwd -fi - -# Init git repo at /etc/naemon/ -if [[ "$GIT_REPO" = "true" && ! -d /etc/naemon/.git ]] -then - cd /etc/naemon - echo "passwd" > .gitignore - git init - git add . - git commit -m "Initial commit" - chown -R naemon /etc/naemon/.git -fi - -# Create necessary logfile structure -#touch /var/log/nagios/nagios.log -#for dir in /var/log/nagios/{archives,spool/checkresults} -#do -# if [[ ! -d "$dir" ]] -# then -# mkdir -p "$dir" -# fi -#done - -# Fix permissions for naemon and pnp4nagios -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 -# ACL group permissions need g+rwx -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 -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 - -# Execute custom init scripts -for script in $(ls -1 /opt/*.sh 2> /dev/null) -do - [[ -x "$script" ]] && "$script" -done - -#systemctl restart httpd -#systemctl restart naemon