Skip to content

Commit

Permalink
Add default configurations for nagios graph if the directory is empty
Browse files Browse the repository at this point in the history
This is instead of updating the readme as per #147
  • Loading branch information
JasonRivers committed Jun 5, 2024
1 parent 33d7f8d commit 5503ee7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,12 @@ RUN echo "use_timezone=${NAGIOS_TIMEZONE}" >> ${NAGIOS_HOME}/etc/nagios.cfg

RUN mkdir -p /orig/var && \
mkdir -p /orig/etc && \
mkdir -p /orig/graph-etc && \
mkdir -p /orig/graph-var && \
cp -Rp ${NAGIOS_HOME}/var/* /orig/var/ && \
cp -Rp ${NAGIOS_HOME}/etc/* /orig/etc/
cp -Rp ${NAGIOS_HOME}/etc/* /orig/etc/ && \
cp -Rp /opt/nagiosgraph/etc/* /orig/graph-etc && \
cp -Rp /opt/nagiosgraph/var/* /orig/graph-var

## Set the permissions for example config
RUN find /opt/nagios/etc \! -user ${NAGIOS_USER} -exec chown ${NAGIOS_USER}:${NAGIOS_GROUP} '{}' + && \
Expand Down
10 changes: 10 additions & 0 deletions overlay/usr/local/bin/start_nagios
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ if [ -z "$(ls -A /opt/nagios/var)" ]; then
cp -Rp /orig/var/* /opt/nagios/var/
fi

if [ -z "$(ls -A /opt/nagiosgraph/etc)" ]; then
echo "Started with empty /opt/nagiosgraph/etc, copying example data in-place"
cp -Rp /orig/graph-etc/* /opt/nagiosgraph/etc/
fi

if [ -z "$(ls -A /opt/nagiosgraph/var)" ]; then
echo "Started with empty /opt/nagiosgraph/var, copying example data in-place"
cp -Rp /orig/graph-var/* /opt/nagiosgraph/var/
fi

if [ ! -f "${NAGIOS_HOME}/etc/htpasswd.users" ] ; then
htpasswd -c -b -s "${NAGIOS_HOME}/etc/htpasswd.users" "${NAGIOSADMIN_USER}" "${NAGIOSADMIN_PASS}"
chown -R ${NAGIOS_USER}.${NAGIOS_GROUP} "${NAGIOS_HOME}/etc/htpasswd.users"
Expand Down

0 comments on commit 5503ee7

Please sign in to comment.