diff --git a/dev-tools/build-packages/base/generate_base.sh b/dev-tools/build-packages/base/generate_base.sh index c0a59b727d6..2ea2ddbed2b 100755 --- a/dev-tools/build-packages/base/generate_base.sh +++ b/dev-tools/build-packages/base/generate_base.sh @@ -53,7 +53,7 @@ build() { # Validate and download files to build the package valid_url='(https?|ftp|file)://[-[:alnum:]\+&@#/%?=~_|!:,.;]*[-[:alnum:]\+&@#/%=~_|]' echo - echo "Downloading files..." + echo "Downloading plugins..." echo mkdir -p $tmp_dir cd $tmp_dir @@ -72,6 +72,10 @@ build() { clean 1 fi + echo + echo "Downloading dashboards..." + echo + if [[ $base =~ $valid_url ]]; then if [[ $base =~ .*\.zip ]]; then if ! curl --output wazuh-dashboard.zip --silent --fail "${base}"; then @@ -81,7 +85,7 @@ build() { echo "Extracting Wazuh Dashboard base" unzip -q wazuh-dashboard.zip -d . rm wazuh-dashboard.zip - mv $(ls | grep opensearch-dashboard) wazuh-dashboard.tar.gz + mv $(ls | grep wazuh-dashboard) wazuh-dashboard.tar.gz fi else if ! curl --output wazuh-dashboard.tar.gz --silent --fail "${base}"; then @@ -94,6 +98,10 @@ build() { clean 1 fi + echo + echo "Downloading security plugin..." + echo + if [[ $security =~ $valid_url ]]; then if ! curl --output applications/security.zip --silent --fail "${security}"; then echo "The given URL or Path to the Wazuh Security Plugin is not working: ${security}" diff --git a/dev-tools/build-packages/build-packages.sh b/dev-tools/build-packages/build-packages.sh new file mode 100644 index 00000000000..4c9f3a9410b --- /dev/null +++ b/dev-tools/build-packages/build-packages.sh @@ -0,0 +1,175 @@ +#!/bin/bash + +app="" +base="" +revision="1" +security="" +version="" +all_platforms="no" +deb="no" +rpm="no" +tar="no" +output="$( cd $(dirname $0) ; pwd -P )/output" + +current_path="$( cd $(dirname $0) ; pwd -P )" + +build_tar() { + echo "Building tar package..." + cd ./base + # bash ./generate_base.sh -a $app -b $base -s $security -v $version -r $revision + + name_package_tar = $(ls ./output) + + if [ "$tar" == "yes" ]; then + echo $(pwd) + mv $current_path/base/output/$name_package_tar $output/$name_package_tar + fi + cd ../ +} + +build_deb() { + echo "Building deb package..." + cd ./deb + # bash ./launcher.sh -v $version -r $revision -p file://$current_path/base/output/$name_package_tar + cd ../ +} + +build_rpm() { + echo "Building rpm package..." + cd ./rpm + # bash ./launcher.sh -v $version -r $revision -p file://$current_path/base/output/$name_package_tar + cd ../ +} + + +build() { + name_package_tar="wazuh-dashboard-$version-$revision-linux-x64.tar.gz" + + if [ ! -d "$output" ]; then + mkdir -p $output + fi + + if [ "$all_platforms" == "yes" ]; then + deb="yes" + rpm="yes" + tar="yes" + fi + + build_tar + cd $current_path + + if [ $deb == "yes" ]; then + echo "Building deb package..." + build_deb + fi + + if [ $rpm == "yes" ]; then + echo "Building rpm package..." + build_rpm + fi +} + +help() { + echo + echo "Usage: $0 [OPTIONS]" + echo " -a, --app Set the location of the .zip file containing the Wazuh plugin." + echo " -b, --base Set the location of the .tar.gz file containing the base wazuh-dashboard build." + echo " -s, --security Set the location of the .zip file containing the wazuh-security-dashboards-plugin." + echo " -v, --version Set the version of this build." + echo " --all-platforms Build for all platforms." + echo " --deb Build for deb." + echo " --rpm Build for rpm." + echo " --tar Build for tar." + echo " -r, --revision [Optional] Set the revision of this build. By default, it is set to 1." + echo " -o, --output [Optional] Set the destination path of package. By default, an output folder will be created." + echo " -h, --help Show this help." + echo + exit $1 +} + +# ----------------------------------------------------------------------------- + +main() { + while [ -n "${1}" ]; do + case "${1}" in + "-h" | "--help") + help 0 + ;; + "-a" | "--app") + if [ -n "$2" ]; then + app="$2" + shift 2 + else + help 1 + fi + ;; + "-s" | "--security") + if [ -n "${2}" ]; then + security="${2}" + shift 2 + else + help 0 + fi + ;; + "-b" | "--base") + if [ -n "${2}" ]; then + base="${2}" + shift 2 + else + help 0 + fi + ;; + "-v" | "--version") + if [ -n "${2}" ]; then + version="${2}" + shift 2 + else + help 0 + fi + ;; + "-r" | "--revision") + if [ -n "${2}" ]; then + revision="${2}" + shift 2 + fi + ;; + "--all-platforms") + all_platforms="yes" + shift 1 + ;; + "--deb") + deb="yes" + shift 1 + ;; + "--rpm") + rpm="yes" + shift 1 + ;; + "--tar") + tar="yes" + shift 1 + ;; + "-o" | "--output") + if [ -n "${2}" ]; then + output="${2}" + shift 2 + fi + ;; + *) + echo "help" + + help 1 + ;; + esac + done + + if [ -z "$app" ] | [ -z "$base" ] | [ -z "$security" ] | [ -z "$version" ]; then + help 1 + fi + + build || exit 1 + + exit 0 +} + +main "$@"