From 045c39d3073d03548ebea9dd6fcc42e9d22bf10d Mon Sep 17 00:00:00 2001 From: Kike Date: Fri, 26 Jul 2019 13:09:21 +0200 Subject: [PATCH] Script to build agent docker --- pandora_agents/Dockerfile | 45 ++++++++++++++++++++++++++++ pandora_agents/build_agent_docker.sh | 18 +++++++++++ 2 files changed, 63 insertions(+) create mode 100644 pandora_agents/Dockerfile create mode 100644 pandora_agents/build_agent_docker.sh diff --git a/pandora_agents/Dockerfile b/pandora_agents/Dockerfile new file mode 100644 index 0000000000..9ea41c484b --- /dev/null +++ b/pandora_agents/Dockerfile @@ -0,0 +1,45 @@ +FROM centos:centos7 +MAINTAINER Pandora FMS Team + +# Add Pandora FMS agent installer +ADD unix /tmp/pandora_agent/unix + +# Install dependencies +RUN yum -y install \ + epel-release \ + unzip \ + perl \ + sed \ + "perl(Sys::Syslog)" + +# Install Pandora FMS agent +RUN cd /tmp/pandora_agent/unix \ + && ./pandora_agent_installer --install + +# Set default variables +ENV SERV_DEST '127.0.0.1' +ENV REMOTE_CONF '0' +ENV AGROUP 'Servers' +ENV DEBUG '0' +ENV NAME 'agent_docker' +ENV TIMEZONE 'UTC' + +# Create the entrypoint script. +RUN echo -e '#/bin/bash\n \ +sed -i "s/^server_ip.*$/server_ip $SERV_DEST/g" /etc/pandora/pandora_agent.conf\n \ +sed -i "s/^remote_config.*$/remote_config $REMOTE_CONF/g" /etc/pandora/pandora_agent.conf\n \ +sed -i "s/^group.*$/group $AGROUP/g" /etc/pandora/pandora_agent.conf\n \ +sed -i "s/^debug.*$/debug $DEBUG/g" /etc/pandora/pandora_agent.conf\n \ +sed -i "s/^#agent_name.*$/agent_name $NAME/g" /etc/pandora/pandora_agent.conf\n \ +if [ $TIMEZONE != "" ]; then\n \ +\tln -sfn /usr/share/zoneinfo/$TIMEZONE /etc/localtime\n \ +fi\n \ +/etc/init.d/pandora_agent_daemon start\n \ +rm -f $0\n \ +bash' \ +>> /entrypoint.sh && \ +chmod +x /entrypoint.sh + +# Entrypoint + CMD +ENTRYPOINT ["bash"] +CMD ["/entrypoint.sh"] \ No newline at end of file diff --git a/pandora_agents/build_agent_docker.sh b/pandora_agents/build_agent_docker.sh new file mode 100644 index 0000000000..0ebf8ac7a0 --- /dev/null +++ b/pandora_agents/build_agent_docker.sh @@ -0,0 +1,18 @@ +#!/bin/bash +source /root/code/pandorafms/extras/build_vars.sh + +# Set tag for docker build +if [ "$1" == "nightly" ]; then + LOCAL_VERSION="latest" +else + LOCAL_VERSION=$VERSION +fi + +# Build image with code +docker build --rm=true --pull --no-cache -t pandorafms/pandorafms-agent:$LOCAL_VERSION -f $CODEHOME/pandora_agents/Dockerfile $CODEHOME/pandora_agents/ + +# Push image +docker push pandorafms/pandorafms-agent:$LOCAL_VERSION + +# Delete local image +docker image rm -f pandorafms/pandorafms-agent:$LOCAL_VERSION \ No newline at end of file