Skip to content

Commit

Permalink
Fix offline installation workflow in deb system
Browse files Browse the repository at this point in the history
  • Loading branch information
Enaraque committed Dec 19, 2024
1 parent 7b88367 commit 127c9e8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 24 deletions.
26 changes: 4 additions & 22 deletions .github/actions/offline-installation/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,6 @@ function check_file() {

}

function check_shards() {

retries=0
until [ "$(curl -s -k -u admin:admin "https://127.0.0.1:9200/_template/wazuh?pretty&filter_path=wazuh.settings.index.number_of_shards" | grep "number_of_shards")" ] || [ "${retries}" -eq 5 ]; do
sleep 5
retries=$((retries+1))
done

if [ ${retries} -eq 5 ]; then
echo "ERROR: Could not get the number of shards."
exit 1
fi
curl -s -k -u admin:admin "https://127.0.0.1:9200/_template/wazuh?pretty&filter_path=wazuh.settings.index.number_of_shards"
echo "INFO: Number of shards detected."

}

function dashboard_installation() {

install_package "wazuh-dashboard"
Expand Down Expand Up @@ -101,14 +84,14 @@ function download_resources() {
bash "${ABSOLUTE_PATH}"/wazuh-install.sh -dw "${sys_type}" -d "${1}"
echo "INFO: Downloading the resources..."

curl -sO https://packages.wazuh.com/4.10/config.yml
curl -sO https://packages-dev.wazuh.com/${2}/config.yml
check_file "config.yml"

sed -i -e '0,/<indexer-node-ip>/ s/<indexer-node-ip>/127.0.0.1/' config.yml
sed -i -e '0,/<wazuh-manager-ip>/ s/<wazuh-manager-ip>/127.0.0.1/' config.yml
sed -i -e '0,/<dashboard-node-ip>/ s/<dashboard-node-ip>/127.0.0.1/' config.yml

curl -sO https://packages.wazuh.com/4.10/wazuh-certs-tool.sh
curl -sO https://packages-dev.wazuh.com/${2}/wazuh-certs-tool.sh
check_file "wazuh-certs-tool.sh"
chmod 744 wazuh-certs-tool.sh
./wazuh-certs-tool.sh --all
Expand Down Expand Up @@ -175,7 +158,6 @@ function filebeat_installation() {
fi

sleep 10
check_shards
eval "filebeat test output"
if [ "${PIPESTATUS[0]}" != 0 ]; then
echo "ERROR: The Filebeat installation has failed."
Expand All @@ -185,9 +167,10 @@ function filebeat_installation() {
}

function indexer_initialize() {
/usr/share/wazuh-indexer/bin/indexer-security-init.sh

retries=0
until [ "$(cat /var/log/wazuh-indexer/wazuh-cluster.log | grep "Node started")" ] || [ "${retries}" -eq 5 ]; do
while ! grep -E "\[node-[0-9]+\] Node 'node-[0-9]+' initialized" /var/log/wazuh-indexer/wazuh-cluster.log && [ "${retries}" -lt 5 ]; do
sleep 5
retries=$((retries+1))
done
Expand All @@ -196,7 +179,6 @@ function indexer_initialize() {
echo "ERROR: The indexer node is not started."
exit 1
fi
/usr/share/wazuh-indexer/bin/indexer-security-init.sh

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ABSOLUTE_PATH="$( cd $(dirname ${0}) ; pwd -P )"

check_system
install_dependencies
download_resources $1
download_resources $1 $2

indexer_installation
echo "INFO: Wazuh indexer installation completed."
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/offline-installation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ on:
default: "pre-release"

env:
WAZUH_VERSION: 4.10
REPOSITORY: ${{ github.event_name == 'pull_request' && 'pre-release' || inputs.REPOSITORY }}

jobs:
Expand Down Expand Up @@ -62,7 +63,7 @@ jobs:
run: cp $GITHUB_WORKSPACE/wazuh-install.sh $GITHUB_WORKSPACE/.github/actions/offline-installation/wazuh-install.sh

- name: Run script
run: sudo bash $GITHUB_WORKSPACE/.github/actions/offline-installation/offline-installation.sh ${{ env.REPOSITORY}}
run: sudo bash $GITHUB_WORKSPACE/.github/actions/offline-installation/offline-installation.sh ${{ env.REPOSITORY}} ${{ env.WAZUH_VERSION }}

Test-offline-installation-rpm:
runs-on: ubuntu-latest
Expand Down

0 comments on commit 127c9e8

Please sign in to comment.