forked from wazuh/wazuh-docker
Updated test of Docker images
This commit is contained in:
@@ -1,60 +1,13 @@
|
||||
# Wazuh Docker Copyright (C) 2017, Wazuh Inc. (License GPLv2)
|
||||
# This has to be exported to make some magic below work.
|
||||
set -x
|
||||
export DH_OPTIONS
|
||||
|
||||
export NAME=wazuh-dashboard
|
||||
export TARGET_DIR=${CURDIR}/debian/${NAME}
|
||||
export INSTALLATION_DIR=/usr/share/${NAME}
|
||||
export CONFIG_DIR=${INSTALLATION_DIR}/config
|
||||
|
||||
##############################################################################
|
||||
# Downloading Cert Gen Tool
|
||||
##############################################################################
|
||||
# Variables for certificate generation
|
||||
CERT_TOOL="wazuh-certs-tool.sh"
|
||||
CERT_CONFIG_FILE="config.yml"
|
||||
download_package() {
|
||||
local url=$1
|
||||
local package=$2
|
||||
if curl -fsL "$url" -o "$package"; then
|
||||
echo "Downloaded $package"
|
||||
return 0
|
||||
else
|
||||
echo "Error downloading $package from $url"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
# Download the tool to create the certificates
|
||||
echo "Downloading the tool to create the certificates..."
|
||||
download_package "$wazuh_certs_tool" $CERT_TOOL
|
||||
# Download the config file for the certificate tool
|
||||
echo "Downloading the config file for the certificate tool..."
|
||||
download_package "$wazuh_config_yml" $CERT_CONFIG_FILE
|
||||
|
||||
# Modify the config file to set the IP to localhost
|
||||
sed -i 's/ ip:.*/ ip: "127.0.0.1"/' $CERT_CONFIG_FILE
|
||||
|
||||
chmod 700 "$CERT_CONFIG_FILE"
|
||||
# Create the certificates
|
||||
chmod 755 "$CERT_TOOL" && bash "$CERT_TOOL" -A
|
||||
|
||||
# Create certs directory
|
||||
mkdir -p ${CONFIG_DIR}/certs
|
||||
|
||||
# Copy Wazuh dashboard certs to install config dir
|
||||
mv /etc/wazuh-dashboard/* ${CONFIG_DIR}/
|
||||
cp -pr /wazuh-certificates/dashboard.pem ${CONFIG_DIR}/certs/dashboard.pem
|
||||
cp -pr /wazuh-certificates/dashboard-key.pem ${CONFIG_DIR}/certs/dashboard-key.pem
|
||||
cp -pr /wazuh-certificates/root-ca.key ${CONFIG_DIR}/certs/root-ca.key
|
||||
cp -pr /wazuh-certificates/root-ca.pem ${CONFIG_DIR}/certs/root-ca.pem
|
||||
cp -pr /wazuh-certificates/admin.pem ${CONFIG_DIR}/certs/admin.pem
|
||||
cp -pr /wazuh-certificates/admin-key.pem ${CONFIG_DIR}/certs/admin-key.pem
|
||||
|
||||
# Modify opensearch.yml config paths
|
||||
sed -i "s|/etc/wazuh-dashboard|${CONFIG_DIR}|g" ${CONFIG_DIR}/opensearch_dashboards.yml
|
||||
|
||||
chmod -R 500 ${CONFIG_DIR}/certs
|
||||
chmod -R 400 ${CONFIG_DIR}/certs/*
|
||||
|
||||
set +x
|
||||
@@ -55,7 +55,7 @@ RUN yum install curl-minimal shadow-utils findutils hostname -y && \
|
||||
mkdir -p /var/lib/wazuh-indexer && chown 1000:1000 /var/lib/wazuh-indexer && \
|
||||
mkdir -p $INSTALL_DIR/logs && chown 1000:1000 $INSTALL_DIR/logs && \
|
||||
mkdir -p /run/wazuh-indexer && chown 1000:1000 /run/wazuh-indexer && \
|
||||
mkdir -p /var/log/wazuh-indexer && chown 1000:1000 /var/log/wazuh-indexer
|
||||
mkdir -p /var/log/wazuh-indexer && chown 1000:1000 /var/log/wazuh-indexer
|
||||
|
||||
COPY --from=builder --chown=1000:1000 $INSTALL_DIR $INSTALL_DIR
|
||||
|
||||
@@ -72,4 +72,4 @@ EXPOSE 9200
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
# Dummy overridable parameter parsed by entrypoint
|
||||
CMD ["opensearch"]
|
||||
CMD ["opensearch"]
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
# Wazuh Docker Copyright (C) 2017, Wazuh Inc. (License GPLv2)
|
||||
# This has to be exported to make some magic below work.
|
||||
set -x
|
||||
export DH_OPTIONS
|
||||
|
||||
export NAME=wazuh-indexer
|
||||
@@ -8,55 +7,9 @@ export NAME=wazuh-indexer
|
||||
# Package build options
|
||||
export USER=${NAME}
|
||||
export GROUP=${NAME}
|
||||
export VERSION=${WAZUH_VERSION}-${WAZUH_TAG_REVISION}
|
||||
export LOG_DIR=/var/log/${NAME}
|
||||
export LIB_DIR=/var/lib/${NAME}
|
||||
export PID_DIR=/run/${NAME}
|
||||
export INSTALLATION_DIR=/usr/share/${NAME}
|
||||
export CONFIG_DIR=${INSTALLATION_DIR}/config
|
||||
|
||||
|
||||
##############################################################################
|
||||
# Downloading Cert Gen Tool
|
||||
##############################################################################
|
||||
# Variables for certificate generation
|
||||
CERT_TOOL="wazuh-certs-tool.sh"
|
||||
CERT_CONFIG_FILE="config.yml"
|
||||
download_package() {
|
||||
local url=$1
|
||||
local package=$2
|
||||
if curl -fsL "$url" -o "$package"; then
|
||||
echo "Downloaded $package"
|
||||
return 0
|
||||
else
|
||||
echo "Error downloading $package from $url"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
# Download the tool to create the certificates
|
||||
echo "Downloading the tool to create the certificates..."
|
||||
download_package "$wazuh_certs_tool" $CERT_TOOL
|
||||
# Download the config file for the certificate tool
|
||||
echo "Downloading the config file for the certificate tool..."
|
||||
download_package "$wazuh_config_yml" $CERT_CONFIG_FILE
|
||||
|
||||
# Modify the config file to set the IP to localhost
|
||||
sed -i 's/ ip:.*/ ip: "127.0.0.1"/' $CERT_CONFIG_FILE
|
||||
|
||||
chmod 700 "$CERT_CONFIG_FILE"
|
||||
# Create the certificates
|
||||
chmod 755 "$CERT_TOOL" && bash "$CERT_TOOL" -A
|
||||
|
||||
# Copy Wazuh indexer's certificates and config files to $CONFIG_DIR
|
||||
mkdir -p ${CONFIG_DIR}/certs
|
||||
mv /etc/wazuh-indexer/* ${CONFIG_DIR}/
|
||||
cp -pr /wazuh-certificates/node-1.pem ${CONFIG_DIR}/certs/indexer.pem
|
||||
cp -pr /wazuh-certificates/node-1-key.pem ${CONFIG_DIR}/certs/indexer-key.pem
|
||||
cp -pr /wazuh-certificates/root-ca.key ${CONFIG_DIR}/certs/root-ca.key
|
||||
cp -pr /wazuh-certificates/root-ca.pem ${CONFIG_DIR}/certs/root-ca.pem
|
||||
cp -pr /wazuh-certificates/admin.pem ${CONFIG_DIR}/certs/admin.pem
|
||||
cp -pr /wazuh-certificates/admin-key.pem ${CONFIG_DIR}/certs/admin-key.pem
|
||||
|
||||
# Modify opensearch.yml config paths
|
||||
sed -i "s|/etc/wazuh-indexer|${CONFIG_DIR}|g" ${CONFIG_DIR}/opensearch.yml
|
||||
|
||||
@@ -65,5 +18,3 @@ sed -i 's/-Djava.security.policy=file:\/\/\/etc\/wazuh-indexer\/opensearch-perfo
|
||||
chown -R ${USER}:${GROUP} ${CONFIG_DIR}
|
||||
chmod -R 500 ${CONFIG_DIR}/certs
|
||||
chmod -R 400 ${CONFIG_DIR}/certs/*
|
||||
|
||||
set +x
|
||||
@@ -9,10 +9,6 @@ ARG S6_VERSION="v2.2.0.3"
|
||||
ARG TARGETARCH
|
||||
ARG wazuh_manager_url_amd64_rpm
|
||||
ARG wazuh_manager_url_arm64_rpm
|
||||
ARG wazuh_certs_tool
|
||||
ARG wazuh_config_yml
|
||||
|
||||
COPY config/config.sh .
|
||||
|
||||
RUN URL_VAR="wazuh_manager_url_${TARGETARCH}_rpm" && \
|
||||
manager_url="${!URL_VAR}" && \
|
||||
@@ -22,8 +18,6 @@ RUN URL_VAR="wazuh_manager_url_${TARGETARCH}_rpm" && \
|
||||
dnf install /wazuh-manager.rpm -y && \
|
||||
rm -rf /wazuh-manager.rpm && \
|
||||
dnf clean all && \
|
||||
chmod 755 /config.sh && \
|
||||
/config.sh && \
|
||||
curl --fail --silent -L https://github.com/just-containers/s6-overlay/releases/download/${S6_VERSION}/s6-overlay-amd64.tar.gz \
|
||||
-o /tmp/s6-overlay-amd64.tar.gz && \
|
||||
tar xzf /tmp/s6-overlay-amd64.tar.gz -C / --exclude="./bin" && \
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
##############################################################################
|
||||
# Downloading Cert Gen Tool
|
||||
##############################################################################
|
||||
# Variables for certificate generation
|
||||
CERT_TOOL="wazuh-certs-tool.sh"
|
||||
CERT_CONFIG_FILE="config.yml"
|
||||
CERT_DIR=/etc/wazuh/certs
|
||||
download_package() {
|
||||
local url=$1
|
||||
local package=$2
|
||||
if curl -fsL "$url" -o "$package"; then
|
||||
echo "Downloaded $package"
|
||||
return 0
|
||||
else
|
||||
echo "Error downloading $package from $url"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
mkdir -p $CERT_DIR
|
||||
# Download the tool to create the certificates
|
||||
echo "Downloading the tool to create the certificates..."
|
||||
download_package "$wazuh_certs_tool" $CERT_TOOL
|
||||
# Download the config file for the certificate tool
|
||||
echo "Downloading the config file for the certificate tool..."
|
||||
download_package "$wazuh_config_yml" $CERT_CONFIG_FILE
|
||||
|
||||
# Modify the config file to set the IP to localhost
|
||||
sed -i 's/ ip:.*/ ip: "127.0.0.1"/' $CERT_CONFIG_FILE
|
||||
|
||||
chmod 700 "$CERT_CONFIG_FILE"
|
||||
# Create the certificates
|
||||
chmod 755 "$CERT_TOOL" && bash "$CERT_TOOL" -A
|
||||
|
||||
# Copy Wazuh manager certs
|
||||
cp -pr /wazuh-certificates/wazuh-1.pem ${CERT_DIR}/wazuh-1.pem
|
||||
cp -pr /wazuh-certificates/wazuh-1-key.pem ${CERT_DIR}/wazuh-1-key.pem
|
||||
cp -pr /wazuh-certificates/root-ca.key ${CERT_DIR}/root-ca.key
|
||||
cp -pr /wazuh-certificates/root-ca.pem ${CERT_DIR}/root-ca.pem
|
||||
cp -pr /wazuh-certificates/admin.pem ${CERT_DIR}/admin.pem
|
||||
cp -pr /wazuh-certificates/admin-key.pem ${CERT_DIR}/admin-key.pem
|
||||
@@ -6,6 +6,10 @@ source /permanent_data.env
|
||||
|
||||
WAZUH_INSTALL_PATH=/var/ossec
|
||||
WAZUH_CONFIG_MOUNT=/wazuh-config-mount
|
||||
CERT_DIR=/etc/wazuh/certs
|
||||
WAZUH_INDEXER_SSL_CA=$CERT_DIR/root-ca.pem
|
||||
WAZUH_INDEXER_SSL_CERTIFICATE=$CERT_DIR/wazuh.pem
|
||||
WAZUH_INDEXER_SSL_KEY=$CERT_DIR/wazuh-key.pem
|
||||
|
||||
##############################################################################
|
||||
# Aux functions
|
||||
@@ -194,6 +198,14 @@ if [[ -n "$WAZUH_INDEXER_HOSTS" ]]; then
|
||||
sed -i -e '/<indexer>/,/<\/indexer>/{ /<hosts>/,/<\/hosts>/{ /<hosts>/r '"$TMP_HOSTS" \
|
||||
-e 'd }}' "$OSSEC_CONF";
|
||||
rm -f "$TMP_HOSTS";
|
||||
|
||||
# --------------------------
|
||||
# Indexer SSL Configuration
|
||||
# --------------------------
|
||||
sed -i "/<indexer>/,/<\/indexer>/ s|<ca>.*</ca>|<ca>$WAZUH_INDEXER_SSL_CA</ca>|" "$OSSEC_CONF"
|
||||
sed -i "/<indexer>/,/<\/indexer>/ s|<certificate>.*</certificate>|<certificate>$WAZUH_INDEXER_SSL_CERTIFICATE</certificate>|" "$OSSEC_CONF"
|
||||
sed -i "/<indexer>/,/<\/indexer>/ s|<key>.*</key>|<key>$WAZUH_INDEXER_SSL_KEY</key>|" "$OSSEC_CONF"
|
||||
|
||||
fi
|
||||
|
||||
# --------------------------
|
||||
|
||||
Reference in New Issue
Block a user