Skip to content

Commit

Permalink
fix: fixed install script
Browse files Browse the repository at this point in the history
  • Loading branch information
stephane-segning committed Sep 16, 2024
1 parent a212b2f commit 5ca6de1
Showing 1 changed file with 42 additions and 11 deletions.
53 changes: 42 additions & 11 deletions scripts/setup-agent.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,64 @@ GROUP=${GROUP:-"wazuh"}
WAZUH_MANAGER=${WAZUH_MANAGER:-'master.wazuh.adorsys.team'}
WAZUH_AGENT_VERSION=${WAZUH_AGENT_VERSION:-'4.8.2-1'}
WAZUH_AGENT_NAME=${WAZUH_AGENT_NAME:-}
# Define text formatting
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[1;34m'
BOLD='\033[1m'
NORMAL='\033[0m'

# Function for logging with timestamp
log() {
local LEVEL="$1"
shift
local MESSAGE="$*"
local TIMESTAMP
TIMESTAMP=$(date +"%Y-%m-%d %H:%M:%S")
echo "$TIMESTAMP [$LEVEL] $MESSAGE"
}

# Logging helpers
info_message() {
log INFO "$*"
}

error_message() {
log ERROR "$*"
}

# Step 0: Ensure Curl and JQ are installed
if ! (curl -SL --progress-bar https://raw.githubusercontent.com/ADORSYS-GIS/wazuh-agent/main/scripts/deps.sh | sudo sh) >/dev/null 2>&1; then
echo "Failed to ensure deps"
info_message "Ensuring dependencies are installed"
if ! (curl -SL --progress-bar https://raw.githubusercontent.com/ADORSYS-GIS/wazuh-agent/main/scripts/deps.sh | sudo bash) 2>&1; then
error_message "Failed to ensure deps"
exit 1
fi

# Step 1: Download and install Wazuh agent
if ! (curl -SL --progress-bar https://raw.githubusercontent.com/ADORSYS-GIS/wazuh-agent/main/scripts/install.sh | LOG_LEVEL=$LOG_LEVEL OSSEC_CONF_PATH=$OSSEC_CONF_PATH WAZUH_MANAGER=$WAZUH_MANAGER sudo sh) >/dev/null 2>&1; then
echo "Failed to install wazuh-agent"
info_message "Installing Wazuh agent"
if ! (curl -SL --progress-bar https://raw.githubusercontent.com/ADORSYS-GIS/wazuh-agent/main/scripts/install.sh | LOG_LEVEL=$LOG_LEVEL OSSEC_CONF_PATH=$OSSEC_CONF_PATH WAZUH_MANAGER=$WAZUH_MANAGER sudo bash) 2>&1; then
error_message "Failed to install wazuh-agent"
exit 1
fi

# Step 2: Download and install wazuh-cert-oauth2-client
if ! (curl -SL --progress-bar https://raw.githubusercontent.com/ADORSYS-GIS/wazuh-cert-oauth2/main/scripts/install.sh | LOG_LEVEL=$LOG_LEVEL OSSEC_CONF_PATH=$OSSEC_CONF_PATH APP_NAME=$APP_NAME WOPS_VERSION=$WOPS_VERSION sudo sh) >/dev/null 2>&1; then
echo "Failed to install 'wazuh-cert-oauth2-client'"
info_message "Installing wazuh-cert-oauth2-client"
if ! (curl -SL --progress-bar https://raw.githubusercontent.com/ADORSYS-GIS/wazuh-cert-oauth2/main/scripts/install.sh | LOG_LEVEL=$LOG_LEVEL OSSEC_CONF_PATH=$OSSEC_CONF_PATH APP_NAME=$APP_NAME WOPS_VERSION=$WOPS_VERSION sudo bash) 2>&1; then
error_message "Failed to install 'wazuh-cert-oauth2-client'"
exit 1
fi

# Step 3: Download and install yara
if ! (curl -SL --progress-bar https://raw.githubusercontent.com/ADORSYS-GIS/wazuh-yara/main/scripts/install.sh | sudo sh) >/dev/null 2>&1; then
echo "Failed to install 'yara'"
info_message "Installing yara"
if ! (curl -SL --progress-bar https://raw.githubusercontent.com/ADORSYS-GIS/wazuh-yara/main/scripts/install.sh | sudo bash) 2>&1; then
error_message "Failed to install 'yara'"
exit 1
fi

# Step 4: Download and install snort
if ! (curl -SL --progress-bar https://raw.githubusercontent.com/ADORSYS-GIS/wazuh-snort/main/scripts/install.sh | sudo bash) >/dev/null 2>&1; then
echo "Failed to install 'snort'"
info_message "Installing snort"
if ! (curl -SL --progress-bar https://raw.githubusercontent.com/ADORSYS-GIS/wazuh-snort/main/scripts/install.sh | sudo bash) 2>&1; then
error_message "Failed to install 'snort'"
exit 1
fi
fi

0 comments on commit 5ca6de1

Please sign in to comment.