Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Wazuh-Dashboards packages to big-product Branch #1233

Merged
merged 35 commits into from
Feb 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
6966a62
First wazuh-dashboard package
c-bordon Jan 5, 2022
4e11355
Testing deb package
c-bordon Jan 7, 2022
b76008f
Add deb package
c-bordon Jan 7, 2022
000d1ee
The directory tree for dashboard is changed
c-bordon Jan 10, 2022
caf3bf3
Fix rpm package for dashboard
c-bordon Jan 11, 2022
a482986
New Changes in builders
c-bordon Jan 12, 2022
040b07b
Changes in copyrigth and others files
c-bordon Jan 12, 2022
11349df
add some changes
c-bordon Jan 13, 2022
2147df2
Add chmods for postinst deb
c-bordon Jan 13, 2022
81d4b1d
Change certificates
c-bordon Jan 13, 2022
d927ca3
Fix files permissions and updated builder.sh
c-bordon Jan 14, 2022
2da8bf2
Fixed version calc on --reference option RPM
c-bordon Jan 17, 2022
962917e
Fix log generation in deb package
c-bordon Jan 18, 2022
5c7b746
Reduced number of rpm spec lines
c-bordon Jan 19, 2022
ed5f660
Fix deb specs for Upgrade
c-bordon Jan 20, 2022
e33dd5c
Fix remove log dir
c-bordon Jan 21, 2022
47d6477
Add wazuh pluggin for wazuh-dashboard
c-bordon Jan 24, 2022
aa129fd
Fix init.d issue
c-bordon Jan 26, 2022
c2869da
Fix systemctl enable for deb package
c-bordon Jan 26, 2022
745dfaf
Change wazuh-dashboard.yml to dashboard.yml
c-bordon Jan 26, 2022
effb4e4
Replace Sudo for runuser
c-bordon Jan 27, 2022
5d99ac0
Fix debian rules
c-bordon Jan 28, 2022
205dd59
Change wazuh-dashboard to wazuh-dashboards
c-bordon Jan 28, 2022
31d5dab
Change certificates names
c-bordon Feb 3, 2022
912d3e9
Fix rmp changelog error
c-bordon Feb 3, 2022
dcd4831
Removed some dependencies from deb packages
c-bordon Feb 3, 2022
9df13ec
Change directory for dashboard
c-bordon Feb 3, 2022
260caeb
Fix wazuh-dashboards.pid behavior after uninstall
c-bordon Feb 4, 2022
76b1f75
Merge branch 'big-product' of github.com:wazuh/wazuh-packages into 11…
c-bordon Feb 4, 2022
7c4c639
removed stack/dashboards/deb/debian/conffiles
c-bordon Feb 4, 2022
02a29f8
Fix all PR comments
c-bordon Feb 4, 2022
a4c061c
The requested changes are made in the PR Review
c-bordon Feb 7, 2022
1435f28
Fix restart after upgrade rpm
c-bordon Feb 7, 2022
9110c0c
Removed doble check for postun rpm
c-bordon Feb 8, 2022
3b47138
Removed check for installation dir in preinst
c-bordon Feb 8, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions debs/generate_debian_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ build() {
build_deb ${DEB_AMD64_BUILDER} ${DEB_AMD64_BUILDER_DOCKERFILE} || return 1
fi

elif [[ "${TARGET}" == "manager" ]] || [[ "${TARGET}" == "agent" ]]; then
elif [[ "${TARGET}" == "manager" ]] || [[ "${TARGET}" == "agent" ]] ; then

BUILD_NAME=""
FILE_PATH=""
Expand All @@ -131,7 +131,7 @@ build() {
fi
build_deb ${BUILD_NAME} ${FILE_PATH} || return 1
else
echo "Invalid target. Choose: manager, agent or api."
echo "Invalid target. Choose: manager or agent."
return 1
fi

Expand All @@ -143,7 +143,7 @@ help() {
echo "Usage: $0 [OPTIONS]"
echo
echo " -b, --branch <branch> [Required] Select Git branch [${BRANCH}]. By default: master."
echo " -t, --target <target> [Required] Target package to build: manager, api or agent."
echo " -t, --target <target> [Required] Target package to build: manager or agent."
echo " -a, --architecture <arch> [Optional] Target architecture of the package [amd64/i386/ppc64le/arm64/armhf]."
echo " -j, --jobs <number> [Optional] Change number of parallel jobs when compiling the manager or agent. By default: 2."
echo " -r, --revision <rev> [Optional] Package revision. By default: 1."
Expand Down
3 changes: 2 additions & 1 deletion rpms/generate_rpm_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ build_rpm() {
# Copy the necessary files
cp ${CURRENT_PATH}/build.sh ${DOCKERFILE_PATH}


# Download the legacy tar file if it is needed
if [ "${CONTAINER_NAME}" = "${LEGACY_RPM_I386_BUILDER}" ] && [ ! -f "${LEGACY_TAR_FILE}" ]; then
${DOWNLOAD_TAR}
Expand Down Expand Up @@ -170,7 +171,7 @@ help() {
echo "Usage: $0 [OPTIONS]"
echo
echo " -b, --branch <branch> [Required] Select Git branch or tag e.g. $BRANCH"
echo " -t, --target <target> [Required] Target package to build [manager/api/agent]."
echo " -t, --target <target> [Required] Target package to build [manager/agent]."
echo " -a, --architecture <arch> [Optional] Target architecture of the package [x86_64/i386/ppc64le/aarch64/armv7hl]."
echo " -r, --revision <rev> [Optional] Package revision that append to version e.g. x.x.x-rev"
echo " -l, --legacy [Optional] Build package for CentOS 5."
Expand Down
154 changes: 154 additions & 0 deletions stack/dashboards/deb/build_package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
#!/bin/bash

# Wazuh package generator
# Copyright (C) 2021, Wazuh Inc.
#
# This program is a free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public
# License (version 2) as published by the FSF - Free Software
# Foundation.

CURRENT_PATH="$( cd $(dirname $0) ; pwd -P )"
ARCHITECTURE="amd64"
OUTDIR="${CURRENT_PATH}/output"
REVISION="1"
BUILD_DOCKER="yes"
DEB_AMD64_BUILDER="deb_dashboard_builder_amd64"
DEB_BUILDER_DOCKERFILE="${CURRENT_PATH}/docker"
FUTURE="no"

trap ctrl_c INT

clean() {
exit_code=$1

# Clean the files
rm -rf ${DOCKERFILE_PATH}/{*.sh,*.tar.gz,wazuh-*}

exit ${exit_code}
}

ctrl_c() {
clean 1
}

build_deb() {
CONTAINER_NAME="$1"
DOCKERFILE_PATH="$2"

# Copy the necessary files
cp ${CURRENT_PATH}/builder.sh ${DOCKERFILE_PATH}

# Build the Docker image
if [[ ${BUILD_DOCKER} == "yes" ]]; then
docker build -t ${CONTAINER_NAME} ${DOCKERFILE_PATH} || return 1
fi


# Build the Debian package with a Docker container
if [ "${REFERENCE}" ];then
docker run -t --rm -v ${OUTDIR}/:/tmp:Z \
${CONTAINER_NAME} ${ARCHITECTURE} ${REVISION} \
${FUTURE} ${REFERENCE} || return 1
else
docker run -t --rm -v ${OUTDIR}/:/tmp:Z \
-v ${CURRENT_PATH}/../../..:/root:Z \
${CONTAINER_NAME} ${ARCHITECTURE} \
${REVISION} ${FUTURE} || return 1
fi

echo "Package $(ls -Art ${OUTDIR} | tail -n 1) added to ${OUTDIR}."

return 0
}

build() {
BUILD_NAME=""
FILE_PATH=""
if [ "${ARCHITECTURE}" = "x86_64" ] || [ "${ARCHITECTURE}" = "amd64" ]; then
ARCHITECTURE="amd64"
BUILD_NAME="${DEB_AMD64_BUILDER}"
FILE_PATH="${DEB_BUILDER_DOCKERFILE}/${ARCHITECTURE}"
else
echo "Invalid architecture. Choose: amd64 (x86_64 is accepted too)"
return 1
fi
build_deb ${BUILD_NAME} ${FILE_PATH} || return 1

return 0
}

help() {
echo
echo "Usage: $0 [OPTIONS]"
echo
echo " -a, --architecture <arch> [Optional] Target architecture of the package [amd64]."
echo " -r, --revision <rev> [Optional] Package revision. By default: 1."
echo " -s, --store <path> [Optional] Set the destination path of package. By default, an output folder will be created."
echo " --reference <ref> [Optional] wazuh-packages branch to download SPECs, not used by default."
echo " --dont-build-docker [Optional] Locally built docker image will be used instead of generating a new one."
echo " --future [Optional] Build test future package x.30.0 Used for development purposes."
echo " -h, --help Show this help."
echo
exit $1
}


main() {
while [ -n "$1" ]
do
case "$1" in
"-h"|"--help")
help 0
;;
"-a"|"--architecture")
if [ -n "$2" ]; then
ARCHITECTURE="$2"
shift 2
else
help 1
fi
;;
"-r"|"--revision")
if [ -n "$2" ]; then
REVISION="$2"
shift 2
else
help 1
fi
;;
"--reference")
if [ -n "$2" ]; then
REFERENCE="$2"
shift 2
else
help 1
fi
;;
"--dont-build-docker")
BUILD_DOCKER="no"
shift 1
;;
"--future")
FUTURE="yes"
shift 1
;;
"-s"|"--store")
if [ -n "$2" ]; then
OUTDIR="$2"
shift 2
else
help 1
fi
;;
*)
help 1
esac
done

build || clean 1

clean 0
}

main "$@"
71 changes: 71 additions & 0 deletions stack/dashboards/deb/builder.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/bin/bash

# Wazuh package builder
# Copyright (C) 2021, Wazuh Inc.
#
# This program is a free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public
# License (version 2) as published by the FSF - Free Software
# Foundation.

set -ex
# Script parameters to build the package
target="wazuh-dashboards"
architecture=$1
release=$2
future=$3
spec_reference=$4
directory_base="/usr/share/wazuh-dashboards"

if [ -z "${release}" ]; then
release="1"
fi

if [ "${future}" = "yes" ];then
version="99.99.0"
else
if [ "${spec_reference}" ];then
version=$(curl -sL https://raw.githubusercontent.com/wazuh/wazuh-packages/${spec_reference}/VERSION | cat)
else
version=$(cat /root/VERSION)
fi
fi

# Build directories
build_dir=/build
pkg_name="${target}-${version}"
pkg_path="${build_dir}/${target}"
sources_dir="${pkg_path}/${pkg_name}"

mkdir -p ${sources_dir}/debian

# Including spec file
if [ "${spec_reference}" ];then
curl -sL https://github.com/wazuh/wazuh-packages/tarball/${spec_reference} | tar zx
cp -r ./wazuh*/stack/dashboards/deb/debian/* ${sources_dir}/debian/
cp -r ./wazuh*/* /root/
else
cp -r /root/stack/dashboards/deb/debian/* ${sources_dir}/debian/
fi


# Generating directory structure to build the .deb package
cd ${build_dir}/${target} && tar -czf ${pkg_name}.orig.tar.gz "${pkg_name}"

# Configure the package with the different parameters
sed -i "s:VERSION:${version}:g" ${sources_dir}/debian/changelog
sed -i "s:RELEASE:${release}:g" ${sources_dir}/debian/changelog
sed -i "s:export INSTALLATION_DIR=.*:export INSTALLATION_DIR=${directory_base}:g" ${sources_dir}/debian/rules

# Installing build dependencies
cd ${sources_dir}
mk-build-deps -ir -t "apt-get -o Debug::pkgProblemResolver=yes -y"

# Build package
debuild --rootcmd=sudo -b -uc -us

deb_file="${target}_${version}-${release}_${architecture}.deb"

cd ${pkg_path} && sha512sum ${deb_file} > /tmp/${deb_file}.sha512

mv ${pkg_path}/${deb_file} /tmp/
11 changes: 11 additions & 0 deletions stack/dashboards/deb/debian/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
wazuh-dashboards (VERSION-RELEASE) unstable; urgency=low

* More info: https://documentation.wazuh.com/current/release-notes/

-- Wazuh, Inc <[email protected]> Sat, 04 Dec 2021 14:04:26 +0000

wazuh-dashboards (4.2.5-1) UNRELEASED; urgency=low

* More info: https://documentation.wazuh.com/current/release-notes/

-- Wazuh, Inc <[email protected]> Mon, 15 Nov 2021 16:47:07 +0000
1 change: 1 addition & 0 deletions stack/dashboards/deb/debian/compat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8
12 changes: 12 additions & 0 deletions stack/dashboards/deb/debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Source: wazuh-dashboards
Section: admin
Priority: extra
Maintainer: Wazuh, Inc <[email protected]>
Build-Depends: debhelper (>= 9), libcap2-bin
Standards-Version: 4.0.0
Homepage: https://www.wazuh.com

Package: wazuh-dashboards
Architecture: any
Depends: debconf, adduser, curl, tar, libcap2-bin
Description: Wazuh dashboard is a user interface and visualization tool for security-related data. This Wazuh central component enables exploring, visualizing, and analyzing the stored security alerts generated by the Wazuh server. Wazuh dashboard enables inspecting the status and managing the configurations of the Wazuh cluster and agents as well as creating and managing users and roles. In addition, it allows testing the ruleset and making calls to the Wazuh API. Documentation can be found at https://documentation.wazuh.com/current/getting-started/components/wazuh-dashboards.html
22 changes: 22 additions & 0 deletions stack/dashboards/deb/debian/copyright
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
This work was packaged for Debian by:

Wazuh, Inc <[email protected]> on Sat, 04 Dec 2021 14:04:26 +0000

It was downloaded from:

https://www.wazuh.com

Copyright:

GNU General Public License version 2.

License:

GNU General Public License version 2.

The Debian packaging is:

Copyright (C) 2021 Wazuh, Inc <[email protected]>

and is licensed under the GPL version 2,
see "/usr/share/common-licenses/GPL-2".
54 changes: 54 additions & 0 deletions stack/dashboards/deb/debian/postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/sh
# postinst script for wazuh-dashboards
# Copyright (C) 2021, Wazuh Inc.
#
# This program is a free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public
# License (version 2) as published by the FSF - Free Software
# Foundation.

set -e

export NAME=wazuh-dashboards
export CONFIG_DIR=/etc/"${NAME}"
export INSTALLATION_DIR=/usr/share/"${NAME}"
export LOG_DIR=/var/log/"${NAME}"
export PID_DIR=/run/"${NAME}"


# Setting Owner and group of own folders
mkdir -p ${PID_DIR}
mkdir -p ${LOG_DIR}
chown -R "${NAME}":"${NAME}" "${LOG_DIR}"
chown -R "${NAME}":"${NAME}" "${PID_DIR}"


case "$1" in
configure)
setcap 'cap_net_bind_service=+ep' "${INSTALLATION_DIR}"/node/bin/node
if [ -f "${INSTALLATION_DIR}"/"${NAME}".restart ]; then
rm -f "${INSTALLATION_DIR}"/"${NAME}".restart
if command -v systemctl > /dev/null 2>&1 && systemctl > /dev/null 2>&1 ; then
systemctl daemon-reload > /dev/null 2>&1
systemctl restart wazuh-dashboards.service > /dev/null 2>&1
elif command -v service > /dev/null 2>&1 && service wazuh-dashboards status 2>/dev/null | grep "running" > /dev/null 2>&1; then
okynos marked this conversation as resolved.
Show resolved Hide resolved
service wazuh-dashboards restart > /dev/null 2>&1
fi
fi

;;


abort-upgrade|abort-remove|abort-deconfigure)

;;


*)
echo "postinst called with unknown argument \`$1'" >22
exit 1
;;

esac

exit 0
Loading