diff --git a/genmon/Dockerfile b/genmon/Dockerfile index 8f218fa..fc7dc10 100644 --- a/genmon/Dockerfile +++ b/genmon/Dockerfile @@ -1,6 +1,5 @@ # Use a specific tag for a stable and predictable base image. FROM python:3.8-slim -# Base image python:3.8-slim is chosen for its minimal size while still providing Python 3.8. # Set non-interactive mode and define timezone to avoid unnecessary prompts during build. ENV DEBIAN_FRONTEND=noninteractive TZ="America/Chicago" @@ -12,7 +11,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ apt-get clean && \ rm -rf /var/lib/apt/lists/* /var/cache/apt/* -# Expose necessary ports for HTTPS, and the application. +# Expose necessary ports for HTTPS and the application. EXPOSE 443 8000 # Set the working directory for any subsequent instructions. @@ -28,7 +27,6 @@ RUN git clone --depth 1 http://github.com/jgyates/genmon.git && \ # Initialize the application and configure it. RUN /git/genmon/genmonmaint.sh -i -n -# Run initial setup scripts. # Clean up apt caches. RUN apt-get clean && \ @@ -40,5 +38,5 @@ COPY entrypoint.sh /entrypoint.sh # Make the entrypoint script executable. RUN chmod +x /entrypoint.sh -# Set the custom entrypoint script as the entrypoint +# Set the custom entrypoint script as the entrypoint. ENTRYPOINT ["/entrypoint.sh"] diff --git a/genmon/entrypoint.sh b/genmon/entrypoint.sh index 01e289a..247acb7 100644 --- a/genmon/entrypoint.sh +++ b/genmon/entrypoint.sh @@ -1,8 +1,24 @@ #!/bin/bash +set -e # Ensure the /var/log/startup.log file exists touch /var/log/startup.log +# Ensure the /git/genmon directory exists and has the necessary files +if [ ! -f /git/genmon/startgenmon.sh ]; then + echo "Populating /git/genmon..." + git clone --depth 1 http://github.com/jgyates/genmon.git /git/genmon + chmod 775 /git/genmon/startgenmon.sh /git/genmon/genmonmaint.sh + rm -rf /git/genmon/.git +fi + +# Ensure the /etc/genmon directory exists and has the necessary configuration files +if [ ! -f /etc/genmon/genmon.conf ]; then + echo "Creating default configuration in /etc/genmon..." + mkdir -p /etc/genmon + cp /git/genmon/genmon.conf /etc/genmon/genmon.conf +fi + # Change the environment variable to use serial TCP in the genmon.conf file sed -i "s/use_serial_tcp = .*/use_serial_tcp = $USE_SERIAL_TCP/g" /etc/genmon/genmon.conf